akapas
February 6, 2004, 9:19pm
#1
Can anyone tell me how I can eliminate (hit OK) an error message in an application?
I have the application starting up and it updates from a central location, then I want the script to wait (got that), then the application provides a message that it has finished updating and it will restart, and I want to hit ok with the script, wait for it to restart then quit.
Thanks.
Rob
February 6, 2004, 9:59pm
#2
Is the OK button the default button? If so, something like this might work if you have GUI scripting enabled.
tell application "your app" to activate
tell application "System Events" to keystroke return
– Rob
akapas
February 6, 2004, 11:57pm
#4
Didn’t work. Any other suggestions?
akapas
February 7, 2004, 1:46am
#6
How do I know if GUI scripting is enabled or how do I enable it?
Btw, does this work in OS X?
Rob
February 7, 2004, 2:04am
#7
GUI scripting is included in Panther. In Jaguar (10.2.3 or later), you’ll need to install System Events version 1.2 [d/l ]. It is beta software but it hasn’t caused problems on my machine. To enable UI scripting, go to the Universal Access pref pane and “Enable access for assistive devices”. Once installed, check the dictionary of System Events to see what can be done. If you plan to do more than casual UI scripting, I recommend PreFab UI Browser .
– Rob
akapas
February 7, 2004, 2:13am
#8
I have 10.1 and 10.2 on our machines, so this is not gonna work.
Rob
February 7, 2004, 2:28am
#9
You might take a look at Extra Suites . Among other goodies, it offers the following:
Input Commands :
ES type key: simulate typing a key on the keyboard
ES type key string – the key to press. Special keys include “tab”, “enter”, etc. Refer info for full list
[command boolean] – hold down the command key
[option boolean] – hold down the option key
[shift boolean] – hold down the shift key
[control boolean] – hold down the control key
ES type string: simulate typing a string of text
ES type string string – the string to type.
[use clipboard boolean] – use the clipboard to type faster
ES move mouse: move the cursor to a new location
ES move mouse list – where to place the cursor
[locally boolean] – move relative from it’s current location
ES click mouse: press the mouse
ES click mouse
[double click boolean] – double click the mouse
[command boolean] – hold down the command key
[option boolean] – hold down the option key
[shift boolean] – hold down the shift key
[control boolean] – hold down the control key
ES command down: is the command key pressed?
ES command down
Result: boolean – true if the key is down, false if it’s not
ES option down: is the option key pressed?
ES option down
Result: boolean – true if the key is down, false if it’s not
ES shift down: is the shift key pressed?
ES shift down
Result: boolean – true if the key is down, false if it’s not
ES control down: is the control key pressed?
ES control down
Result: boolean – true if the key is down, false if it’s not
ES keys down: what keys were pressed
ES keys down
Result: list – a list of the keys pressed
ES mouse down: is the mouse button pressed?
ES mouse down
Result: boolean – true if the mouse button is down, false if it’s not
ES mouse location: position of the cursor on the screen
ES mouse location
Result: list – position as list of {across, down}
I think it will work on 10.1 and later and it offers a way to distribute scripts to users without requiring them to pay the license fee.
– Rob
I know this is a late response to the question, but I found a bit of code which answered a similar question I had:
tell application "System Events"
tell process "your app"
keystroke return
end tell
end tell
Also, you’ll need to install this if you’re running Jaguar to run System Events.