Lost AppleScript keystroke and code modifiers

Ask for help with ScummVM problems

Moderator: ScummVM Team

Post Reply
User avatar
raina
Posts: 233
Joined: Thu Jan 12, 2006 12:31 pm
Location: Oulu, Finland
Contact:

Lost AppleScript keystroke and code modifiers

Post by raina » Mon May 06, 2013 6:59 pm

I am trying to have a bit of fun with creating a launcher icon for King's Quest IV SCI on OS X. As you might know, the game starts with the copy protection, so I thought I'd pop up the answer key excerpt from the KQ collection manual in a Quick Look window next to ScummVM for quick lookup. No need to rummage the cupboard for the manual or manually open PDFs for each game session. Neat, huh? And so far so good. But then there's the fine tuning.

The next step would be for the game to automatically go full screen when the Quick Look window is closed (after it's not needed anymore) for improved immersion.

The problem is with sending the appropriate key codes to ScummVM from AppleScript. Assuming this basic script structure

Code: Select all

tell application "ScummVM"
	activate
	tell application "System Events"
		key code 52 using option down
	end tell
end tell
AppleScript is supposed to send to ScummVM, the key code 52 (enter) with the option (alt) key pressed. But only the enter goes through, as evidenced by first typing something in the parser and after running the script, the game reacting to the typed string.

For an example where the script works as expected, here

Code: Select all

tell application "ScummVM"
	activate
	tell application "System Events"
		keystroke "i" using control down
	end tell
end tell
This brings up the inventory, as if Ctrl+I was pressed. But then again this doesn't

Code: Select all

tell application "ScummVM"
	activate
	tell application "System Events"
		key code 96 using control down
	end tell
end tell
The key code for F5 is received alright, but the Control modifier seems to be omitted seeing as how the game brings up the Save Game menu, not the ScummVM main menu.

So, the modifiers seem to work to a degree with keystrokes but not so much with key codes. And I was unable to get anything with Alt/Option to register. I am pretty new to AppleScript so I don't know if I'm missing something here but is there something I or ScummVM should be doing differently to get the sent keys to register right? Any ideas?

Post Reply