Tuesday, October 23, 2018

#1 2018-06-06 08:57:21 am

AlexM
Member
From:: Denver, CO
Registered: 2011-12-05
Posts: 33

Script that holds down modifier key until trackpad movement stops

My current script functions like this and gives me a set amount of time for me to make a gesture with my trackpad:

Applescript:

tell application "System Events"
   
   key down {control}
   
   delay 1
   
   key up {control}
   
end tell

Instead of the timed delay, I need the 'key up' only delayed while I move my cursor with the trackpad to form a gesture.  When I finish the gesture by lifting my finger off the trackpad I need the "key up" after it being 'key down' while I'm gesturing.  Something like this:


(The parts in bold tags aren't code, it's just explaining what I'd like the actual code to do there)

Applescript:

tell application "System Events"
   
   key down {control}

[b]repeat until "trackpad event starts and stops"[/b]

[b]if no trackpad event after 0.5 seconds then key up[/b]
   
   key up {control}
   
end tell

Is something like this possible with AppleScript?

Last edited by AlexM (2018-06-06 08:58:11 am)

Offline

 

#2 2018-06-06 11:33:05 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 315

Re: Script that holds down modifier key until trackpad movement stops

Shane Stanley provided an example of a script waiting for a mouse click here: https://macscripter.net/viewtopic.php?id=44549
I don't know ASObjC well enough to know if it's possible to wait for a gesture or to try to adapt this script, but perhaps it would be a useful example to you or anyone else trying to help.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#3 2018-06-09 04:12:26 pm

AlexM
Member
From:: Denver, CO
Registered: 2011-12-05
Posts: 33

Re: Script that holds down modifier key until trackpad movement stops

Thank you for the link.  That shows it may be possible, but I'm having trouble making sense of which parts of the script I would use.  Thanks again for the lead though!

Offline

 

#4 2018-06-09 09:16:52 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5454

Re: Script that holds down modifier key until trackpad movement stops

t.spoon wrote:

Shane Stanley provided an example of a script waiting for a mouse click here:



That applies to a very specific set of circumstances, which don't apply here.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#5 2018-06-10 01:47:49 pm

AlexM
Member
From:: Denver, CO
Registered: 2011-12-05
Posts: 33

Re: Script that holds down modifier key until trackpad movement stops

Thank you for the clarification.  That said, do you know if this is possible with AppleScript?  And, if so, could you point me to the right direction to implement?

Offline

 

#6 2018-06-10 05:30:26 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5454

Re: Script that holds down modifier key until trackpad movement stops

AlexM wrote:

do you know if this is possible with AppleScript?



I'd be very surprised if it were.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#7 2018-07-20 02:46:10 pm

AlexM
Member
From:: Denver, CO
Registered: 2011-12-05
Posts: 33

Re: Script that holds down modifier key until trackpad movement stops

Thanks for the input, Shane.  After some more thinking on it, I remembered this tool.

https://www.bluem.net/en/projects/cliclick/

This might work with AppleScript?

Offline

 

#8 2018-08-08 11:15:29 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 315

Re: Script that holds down modifier key until trackpad movement stops

Clicclick or MouseTools run with "do shell script," (http://www.hamsoftengineering.com/codeS … Tools.html), Applescript Toolbox (https://astoolbox.wordpress.com/), and running Python code from Applescript can all control mouse movements/clicks.

But I thought you were looking for code to wait until you had completed a trackpad gesture, and trigger the execution of more code upon completion.

If you're just looking to automate the mouse via code, that is very doable. It's waiting until a gesture is completed that none of us seem to have a solution to.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)