I am trying to send keystrokes to a VisualBoyAdvance application using AppleScript, but I cannot get it to work.
My code is still like this:
tell application "VisualBoyAdvance"
activate
tell application "System Events"
keystroke "k"
end tell
end tell
When I say VisualBoyAdvance directly, I get this error:
error "VisualBoyAdvance got an error: Can’t get keystroke \"k\"." number -1728 from keystroke "k"
I tried to pass VisualBoyAdvance directly, and I also tried using key code 40, but I still can't get it to work. Oddly enough, this works:
tell application "VisualBoyAdvance"
activate
tell application "System Events"
keystroke "d" using {command down}
end tell
end tell
But this is the key combination that appears in the menu bar, so I assume it will be a little different.
How can I use AppleScript to simulate a keystroke and make the application respond to it? If I cannot use AppleScript for this, what else can I use?