Controlling Mouse Movement/Click Speed?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 159
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Controlling Mouse Movement/Click Speed?

Post by RNIB » Fri Sep 30, 2016 2:49 pm

This is a macro I'm trying to write to automate an on screen audio jog wheel with a physical one. What this does is when I move the jog wheel back once I hear the audio running backwards slowly, if I move it back again I hear the audio running backwards a bit faster, move it back again and I hear the audio a bit faster again. The same happens if I move the jog wheel forward. Equally if im moving backwards at the 3rd speed and move the jog wheel forward it slows the audio down to the 2nd speed and from the 2nd to the 1st.

The way it does this is my moving the mouse to the onscreen jog wheel at 1094,750, performing a left mouse click and then dragging the mouse either up or down.


This is my code so far:

Code: Select all

OnEvent>Key_Down,R,5,JogBack1
OnEvent>Key_Down,F,5,JogForward1
OnEvent>Key_Down,X,5,Stop
Label>mainloop
  Wait>0.02
Goto>mainloop

Srt>JogBack1
SetFocus>SADiE6 Radio Producer - Shuttle Pro Test.edl
Wait>0.2
MouseMove>1094,750
LDown
MouseMove>1094,800
OnEvent>Key_Down,F,5,BackForward
OnEvent>Key_Down,R,5,JogBack2
End>JogBack1

Srt>JogBack2
SetFocus>SADiE6 Radio Producer - Shuttle Pro Test.edl
Wait>0.2
MouseMove>1094,750
MouseMove>1094,850
OnEvent>Key_Down,F,5,JogBack1
OnEvent>Key_Down,R,5,JogBack3
End>JogBack2

Srt>JogBack3
SetFocus>SADiE6 Radio Producer - Shuttle Pro Test.edl
Wait>0.2
MouseMove>1094,750
MouseMove>1094,900
OnEvent>Key_Down,F,5,JogBack2
End>JogBack3

SRT>JogForward1
SetFocus>SADiE6 Radio Producer - Shuttle Pro Test.edl
Wait>0.2
MouseMove>1094,750
LDown
MouseMove>1094,700
OnEvent>Key_Down,R,5,ForwardBack
OnEvent>Key_Down,F,5,JogForward2
End>JogForward1

SRT>JogForward2
SetFocus>SADiE6 Radio Producer - Shuttle Pro Test.edl
Wait>0.2
MouseMove>1094,750
MouseMove>1094,650
OnEvent>Key_Down,R,5,JogForward1
OnEvent>Key_Down,F,5,JogForward3
End>JogForward2

SRT>JogForward3
SetFocus>SADiE6 Radio Producer - Shuttle Pro Test.edl
Wait>0.2
MouseMove>1094,750
MouseMove>1094,600
OnEvent>Key_Down,R,5,JogForward2
End>JogForward3

Srt>Stop
LUP
End>Stop

Srt>BackForward
LUP
LDOWN
GoSub>JogForward1
Goto>mainloop
End>BackForward

Srt>ForwardBack
LUP
LDOWN
GoSub>JogBack1
Goto>mainloop
End>ForwardBack
I have two problems with it at the moment which may or may not be related.

Problem 1:
If I move the jog wheel forward 1 step I here the audio moving forward slowly as expected and when I move the jog wheel back 1 step the audio stops which is what it should do as it's releasing the left mouse button. In reverse this is not the case. If I move the jog wheel back 1 step I hear the audio moving backwards slowly but if I then move the mouse forward it doesnt stop but instead moves to moving forwards slowly.

Problem 2:
There are times when changing direction, in particular from a forward direction to a backwards one where the audio stops moving but I can still see the mouse moving up and down the screen. This leads me to believe that a LUP has occurred but not the corresponding LDOWN or, if the LDOWN has happened it's happened before the mouse was in the correct position. Eventually if I move the jog wheel slowly enough I can get the audio to move forward again but never backwards until I stop the macro and start again.

I can't see any difference between the forwards and backwards code so can't understand why it works in one direction but not the other. But is there a more accurate/faster way of controlling the mouse that might avoid any timing issues?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Controlling Mouse Movement/Click Speed?

Post by Marcus Tettmar » Tue Oct 04, 2016 8:26 am

Not sure if this helps but you could try calling the Win32 API function mouse_event directly via LibFunc if you want finer control of mouse events:

https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts