Hi,
I´m new to Apple Script and i tried a little code. It works but the pressed “y” is always written in the code. The “y” is a shortcut for the App where I want to use the code. Can anyone help me?
Thanks
P.S. Sorry for my bad english…
tell application "Loop Editor" to activate
repeat 5 times
tell application "System Events" to keystroke "y"
tell application "System Events" to key code 36
delay 0.5
tell application "System Events" to tell process "Loop Editor" to key code 125
delay 0.5
end repeat
y
y
Model: Mac Mini 2014 16GB
Browser: Safari 600.6.3
Operating System: Mac OS X (10.10)
Yeah, you can’t do that. If your app has like a text field, then when you press “y” it will show up in the text field. What you need to do is add a modified like for instance the command key. Then, Command + “y” would be your keyboard shortcut. Otherwise, without the modifier the text field takes precedence.
When you set your shortcuts you should look in your system preferences for the existing shortcuts. Go to Apple>System Preferences>Keyboard>Shortcuts and look through all the existing shortcuts. Study that.
Are you saying that the "y"s are being typed into Script Editor rather than into Loop Editor? If so, you may need to activate Loop Editor again or tell System Events to set the process’s frontmost to true:
tell application "Loop Editor" to activate
tell application "System Events"
set frontmost of application process "Loop Editor" to true
repeat 5 times
keystroke "y"
key code 36
delay 0.5
key code 125
delay 0.5
end repeat
end tell
According to the hype on its Web site, Loop Editor has “full AppleScript support”. Is there anything in its AppleScript dictionary which may do what you want without having to resort to keystrokes?