To Idle or Not to Idle

Hi everyone,

I have a script that’s nearly completed but has slightly one annoying element - it cannot identify and close a pop-up window only ONCE inside an idle block that ends with a return. To make matters worse this pop-up window doesn’t have an identifiable name (it’s simply part of the program the script is controlling). What I’m trying to avoid is using a repeat command (within the run block) since it consistently locks up on me and cannot exit after identifying application exists. For example, this is what I have thus far, which works but loops the key code 76 (enter) command:

property k_application : “Student Network Signin”

on run
– runs script during menu interface
end run

on idle

tell application “System Events” to process k_application exists
if result then
tell application “System Events”
key code 76
end tell
end if
– rest of idle block
return 2

end idle

The k_application is consistently active during idling so how else can I work this? I’m sure the repeat function can be tamed inside the run block, but how? Or is there a way to have a command within an idle block only run once? There doesn’t seem to be any other identifiable applications to trigger this action and make it an if/then instance.

Thank you,
Antnee

A pop-up window in k_application will be window 1 and you have to send the keycode to the application’s process.

Hi Adam,

I too originally thought to close window 1 of k_application but it doesn’t necessarily relay the command (k_application evidently sees the pop-up and the application itself as a single window…i know, messed up, but it’s an extremely old school application that is java based for elementary students).

Nonetheless I figured it out by placing a repeat command outside of the idle block and within the end of the run sector.

Thank you for replying though. :slight_smile:

Antnee