Oops.
It was easy to clean the given script.
Here is the new version.
use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" -- for NSEvent
delay 3 set {optionState, controlState, commandState, shiftState} to my checkModifiers:{"shift", "command"} display dialog "optionState = " & optionState & linefeed & "controlState = " & controlState & linefeed & "commandState = " & commandState & linefeed & "shiftState = " & shiftState
on checkModifiers:keyList set theResults to {false, false, false, false} set theFlag to current application's NSEvent's modifierFlags() as integer if keyList contains "option" then set theMask to current application's NSAlternateKeyMask as integer set item 1 of theResults to ((theFlag div theMask) mod 2) ≠ 0 end if if keyList contains "control" then set theMask to current application's NSControlKeyMask as integer set item 2 of theResults to ((theFlag div theMask) mod 2) ≠ 0 end if if keyList contains "command" then set theMask to current application's NSCommandKeyMask as integer set item 3 of theResults to ((theFlag div theMask) mod 2) ≠ 0 end if if keyList contains "shift" then set theMask to current application's NSShiftKeyMask as integer set item 4 of theResults to ((theFlag div theMask) mod 2) ≠ 0 end if return theResults end checkModifiers:
Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) mercredi 30 novembre 2016 12:34:41
|