Re: Is Keypressed dead forever?
Re: Is Keypressed dead forever?
- Subject: Re: Is Keypressed dead forever?
- From: Robert Poland <email@hidden>
- Date: Tue, 29 Nov 2016 16:06:47 -0700
- Z-usanet-msgid: XID196ukCXgW8352X31
Shane,
Excuse this old man but can you modify this to catch more than one of the modifier keys?
> On Nov 29, 2016, at 3:56:PM, Shane Stanley <email@hidden> wrote:
>
> On 30 Nov. 2016, at 4:50 am, Robert Poland <email@hidden> wrote:
>>
>> Now that Sierra has killed ASObjC Runner, has anyone created a way to detect which key is down?
>
> If you mean which modifier key, then you can use this:
>
> use AppleScript version "2.4"
> use scripting additions
> use framework "Foundation"
> use framework "AppKit" -- for NSEvent
>
> my checkModifier:"command"
>
> 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:
>
>
> --
> Shane Stanley <email@hidden>
> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
Robert Poland
Fort Collins, CO
_______________________________________________
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