Is it possible to have an applet that does one thing when you click it and does something else when you click it while holding down a key (shift key, control key, etc)? is it possible to write that into the script somehow? any ideas would help, thanks.
If you don’t mind using a third-party OSAX, Jon’s Commands has a ‘keys pressed’ command that returns a list of strings representing the keys being held down at the time:
keys pressed
--> {"Command", "Shift"}
You could use an ‘if’ clause to test for key presses and branch to the appropriate routine. Note, though, that although it’s possible to write the required code, it’s not always possible to run an applet while holding down certain keys - the Control key, for example.
Hi,
This uses Jon’s Commands scripting addition 'keys pressed" command:
property key_list : {“Shift”, “Command”, “Option”}
on run
set keys_pressed to (keys pressed)
set key_count to (count keys_pressed)
if (key_count is 0) then
say “No keys were pressed.”
else if (key_count is 1) and (keys_pressed is in key_list) then
say (keys_pressed as string)
end if
end run
Note that you cannot run an app by clicking on the icon when the control key is pressed. You can also run scripts from the contextual menu.
gl,