problems controlling the mouse with scripts or Keyboard Maestro

Joined
Aug 10, 2016
Messages
28
Reaction score
0
Points
1
I'm trying to control the mouse and running into the same problematic behavior whether I use AppleScript or Keyboard Maestro, which suggests there is something about OS X that affects both. I am hoping that the experts here on OS X development might be able to offer suggestions about what could be wrong, and generally what might be the hope for the solution.

I want to automate certain mouse functions. One thing I want to do is to have a script (or Keyboard Maestro) simulate a left mouse button press -- and *hold* -- while I move the mouse. This will create a drag action.

I want to use this in Photoshop for painting.

I have tried doing this in Keyboard Maestro. I also tried using AppleScript together with the shell program "MouseTools".

In both cases the behavior is the same. What happens *in Photoshop* (while painting) is this. When the script or KM does the "left button down" action, a spot of paint appears. This means that Photoshop has registers the left button press. Then I start to move the mouse. At this point the painting cursor moves, so PS is registering the mouse movement. However, no line of paint appears. Then after moving the mouse some distance and I cause a "left button release" action to take place, suddenly a line of paint (forming a direct linear connection from teh original mouse location to the final location) appears.

There is similar behavior when trying to simulate drags in the AppleScript editor. Normally when dragging over text in the editor, it is highlighted. When I use my script or KM to simulate a drag, a very similar thing happens. I do the following (1) cause the left button down and hold to take place, (2) move the mouse, (3) cause the "left button release" to take place. During step 2, no highlight appears. Then in step 3, suddenly all the text between the initial and final locations is highlighted.

Here is the AppleScript code I am using to test this

Code:
set mouseToolsPath to (path to home folder as text) & "bin:MouseTools"

delay 3 -- 3 seconds after starting the script to move the mouse where you want

do shell script quoted form of POSIX path of mouseToolsPath & " -leftClickNoRelease"

delay 3

do shell script quoted form of POSIX path of mouseToolsPath & " -releaseMouse"
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top