• 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: Keystroke question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keystroke question


  • Subject: Re: Keystroke question
  • From: Shane Stanley <email@hidden>
  • Date: Wed, 25 Nov 2015 12:15:06 +1100

On 24 Nov 2015, at 6:37 AM, Steve Mills <email@hidden> wrote:

Also keen in mind that any modifier keys the user might be holding when the script runs will be added to the "keystroke" command. That continually annoys me when I launch scripts via DragThing that type in my password or whatever, but I don't release the "launch that script" keys quickly enough.

Assuming you always use at least one of command or control, you could have your scripts pause until both are up. So start your scripts with something like:

use framework "Foundation"

set theMask to current application's NSCommandKeyMask as integer
set otherMask to current application's NSControlKeyMask as integer
repeat
set theFlag to current application's NSEvent's modifierFlags() as integer
if ((theFlag div theMask) mod 2) = 0 and ((theFlag div otherMask) mod 2) = 0 then exit repeat -- both keys up
delay 1.0E-3
end repeat

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: 
 >Keystroke question (From: Robert Poland <email@hidden>)
 >Re: Keystroke question (From: "Stockly, Ed" <email@hidden>)
 >Re: Keystroke question (From: Bill Cheeseman <email@hidden>)
 >Re: Keystroke question (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: Keystroke question
  • Next by Date: Re: How to get the number of items in a selected Folder ?
  • Previous by thread: Re: Keystroke question
  • Next by thread: Re: Keystroke question
  • Index(es):
    • Date
    • Thread