Hey guys i know this is simple but ive kinda forgotten
how would i make a applescript that can press keys in the specfied app or is it possible to tell it to press a menu item
Hey guys i know this is simple but ive kinda forgotten
how would i make a applescript that can press keys in the specfied app or is it possible to tell it to press a menu item
This activates TextEdit and presses the z key:
tell application "TextEdit" to activate
tell application "System Events" to keystroke "z"
Hereâs how youâd launch commands (in this case, select all):
tell application "System Events" to keystroke "a" using command down
so what do i do if i want to do cmd+shift+a i tried this with no luck
tell application âMultiAlarmâ to activate
tell application âSystem Eventsâ to keystroke âaâ using command down and shift down
Youâre close. Try:
tell application "MultiAlarm" to activate
tell application "System Events" to keystroke "a" using command down & shift down
This syntax should also work
tell application "System Events" to keystroke "a" using {command down, shift down}
tell application "System Events" to keystroke "q" using {command down, shift down}
how would i make the script press the log out button?
cheers
tell application "System Events" to keystroke return
That should do the trick, I think
Chris
You donât really need to use keystrokes to invoke a logout, dgorjup31 - since System Eventsâ Power Suite allows you to do this directly. (Itâs generally a good idea, wherever possible, to use GUI scripting only as a last resort.)
Itâs probably also worth making sure the logout dialog has appeared before attempting to confirm the action. So hereâs another way to do the job:
tell application "System Events"
log out
tell button "Log Out" of window 1 of process "loginwindow"
repeat until exists
delay 0.1
end repeat
click
end tell
end tell