On Aug 2, 2011, at 5:32 PM, Shane Stanley wrote: So open AppleScript Editor in Lion and choose File -> New From Template -> Cocoa-AppleScript Applet.app. Include the handler Alex posted above, so your script is like this:
So I did that ...
on run if checkModifier_(me) then -- "option" key is down display dialog "Option key down" else display dialog "Option key up" end if end run
on checkModifier_(sender) set theMask to current application's NSAlternateKeyMask as integer set theFlag to current application's NSEvent's modifierFlags() as integer return ((theFlag div theMask) mod 2) as boolean end checkModifier_
and it works! ... but it won't quit. I have to quit manually before I can run it again. (I must be missing something new in Lion AppleScript) And it also works in 10.6.8.
And, I suspect that if I look at the output of NSAlternateKeyMask and NSEvent's modifierFlags I will see something that will let me include 'shift', 'command', 'control' &c. (?)
|