• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Key down (or up) events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key down (or up) events


  • Subject: Re: Key down (or up) events
  • From: Yvan KOENIG <email@hidden>
  • Date: Fri, 01 Jul 2016 23:43:39 +0200


Le 1 juil. 2016 à 23:22, John Stewart <email@hidden> a écrit :

Greetings All,

The burning question is, has anyone out there defined or have a routine for checking key states? I have a need to to change the operation of a script at launch based on modifier keys. (Where is Jon's Commands when I really need it?)

If anyone has something or can point me in the right direction I would really appreciate it!

JBS

I retrieved an old script from Shane STANLEY.

use AppleScript version "2.3"
use scripting additions
use framework "AppKit" -- for NSEvent

on checkModifier:keyName
if keyName = "option" then
set theMask to current application's NSAlternateKeyMask as integer
else if keyName = "control" then
set theMask to current application's NSControlKeyMask as integer
else if keyName = "command" then
set theMask to current application's NSCommandKeyMask as integer
else if keyName = "shift" then
set theMask to current application's NSShiftKeyMask as integer
else
return false
end if
set theFlag to current application's NSEvent's modifierFlags() as integer
if ((theFlag div theMask) mod 2) = 0 then
return false
else
return true
end if
end checkModifier:

my checkModifier:"option"


Yvan KOENIG running El Capitan 10.11.5 in French (VALLAURIS, France) vendredi 1 juillet 2016 23:43:29




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Key down (or up) events
      • From: John Stewart <email@hidden>
References: 
 >Key down (or up) events (From: John Stewart <email@hidden>)

  • Prev by Date: Key down (or up) events
  • Next by Date: Re: Key down (or up) events
  • Previous by thread: Key down (or up) events
  • Next by thread: Re: Key down (or up) events
  • Index(es):
    • Date
    • Thread