• 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: Is Keypressed dead forever?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is Keypressed dead forever?


  • Subject: Re: Is Keypressed dead forever?
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 30 Nov 2016 12:35:50 +0100

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



 _______________________________________________
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

References: 
 >Is Keypressed dead forever? (From: Robert Poland <email@hidden>)
 >Re: Is Keypressed dead forever? (From: Yvan KOENIG <email@hidden>)
 >Re: Is Keypressed dead forever? (From: Robert Poland <email@hidden>)
 >Re: Is Keypressed dead forever? (From: Shane Stanley <email@hidden>)
 >Re: Is Keypressed dead forever? (From: Robert Poland <email@hidden>)
 >Re: Is Keypressed dead forever? (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Is Keypressed dead forever?
  • Next by Date: Re: Is Keypressed dead forever?
  • Previous by thread: Re: Is Keypressed dead forever?
  • Next by thread: Re: Is Keypressed dead forever?
  • Index(es):
    • Date
    • Thread