Click down Mouse and move. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Click down Mouse and move.

05 May 2021, 11:27

Hello, I'm new here.

I may need help on these.

I have a Rotary encoder which I keybind to F21(CCw) and F22(CW).
If I rotate to CCW, I wanted to click down at a certain mouse position and move mouse Left by 2 pixel. or at CW, Click down at mouse position and move mouse Right by 2 pixel.

Will this work?

Code: Select all

F21::
SendEvent {Click 131, 737, down}
MouseGetPos, x, y
MouseMove, x-3, y
SendEvent {Click, , , Up}
return

F22::
SendEvent {Click 131, 737, down}
MouseGetPos, x, y
MouseMove, x+3, y
SendEvent {Click, , , Up}
return
[Mod edit: [code][/code] tags added.]

I am using it on Davinci resolve color page.

Thanks in advance.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.  Topic is solved

05 May 2021, 11:34

Did it work when you tested it?

An alternative if you are interested: relative mouse movements can also be achieved with the "R" option. This does not require retrieving the mouse position first.

Code: Select all

MouseMove, -3, 0,, R
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

05 May 2021, 11:54

Doesn't seem to work.

Code: Select all

F21::
SendEvent {Click 134, 739, down}
sleep, 10
MouseMove, -3, 0
SendEvent {Click, , , Up}
return

F22::
SendEvent {Click 134, 739, down}
sleep, 10
MouseMove, +3, 0
SendEvent {Click, , , Up}
return
[Mod edit: [code][/code] tags added.]

I wanted to click down for 5 seconds at mouse pos, while down, I want to move the mouse. does it need loop or something?
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

05 May 2021, 12:00

mikeyww wrote:
05 May 2021, 11:34
Did it work when you tested it?

An alternative if you are interested: relative mouse movements can also be achieved with the "R" option. This does not require retrieving the mouse position first.

Code: Select all

MouseMove, -3, 0,, R
I can't make it work.
I just wanted to hold click at Mouse Pos with say 2 seconds, while held down move the mouse by +3 or -3 pixels. Does it need loop or timer? I don't know.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.

05 May 2021, 14:18

Code: Select all

F21::MouseClickDrag, L, 134, 739, 131, 739
F22::MouseClickDrag, L, 134, 739, 137, 739
For your method:

You used: MouseMove, +3, 0

I used: MouseMove, 3, 0,, R

See the difference in the syntax?
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

06 May 2021, 02:51

Code: Select all

F21::MouseClickDrag, L, 134, 739, 131, 739
F22::MouseClickDrag, L, 134, 739, 137, 739
Thank you.

While this is clever but can I separate the Click down hold and then mouse move?
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

06 May 2021, 04:26

This is working in my setup right now. When I press hold F1 it is clicking on the Mouse Position of the Temperature in the Color page and I can Adjust values by the rotary encoder F21(CCW) , F22(CW)
I want to be able to merge mouse click and Mouse move into one Key Press. in my case to my Rotary encoder F21/F22

Code: Select all

F1:: ;TEMPERATURE
WinMaximize, ahk_class Qt5QWindowIcon  ;Davinci Resolve Color
SendEvent {Click 131, 770, down}
keywait, F1
SendEvent {Click, , , Up}
return

F21::
MouseMove, -1, 0,, R
return

F22::
MouseMove, +1, 0,, R
return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.

06 May 2021, 04:37

Your method works for that.

Code: Select all

F21::
F22::
Click, 134 739 D
Sleep, 10
MouseMove, A_ThisHotkey = "F21" ? -3 : 3, 0,, R
Click, U
Return
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

07 May 2021, 03:04

Thank you so much. This script works fine when I turn the Knob slowly, But when I turn normal or faster... the Script doesn't work or it simply double-clicking thus resetting the value to the initial state. I wanted to be able to hold down the mouse click first before executing the mouse move. Give the hold down maybe 1 second so the mouse can perform movement while the mouse is held down.
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

07 May 2021, 03:06

In my working script above I am holding down mouse click position and then use the rotary to move the mouse.

Mouse click down

Mouse move - / +

Mouse CLick Up
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.

07 May 2021, 04:57

I do not have this knob to test, but perhaps you want the following.

Code: Select all

incr := 3
F21::
F22::
Click, 134 739 D
Sleep, 10
While GetKeyState(A_ThisHotkey)
 MouseMove, A_ThisHotkey = "F21" ? -1 * incr : incr, 0,, R
Click, U
Return
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

07 May 2021, 10:31

I found this script to be working. But I can't get it to lower less than 6 pixel mouse movement.

Code: Select all

F21:: ;TEMP
SendEvent {Click 131, 767, down}
MouseMove, -6, 0,, R
Sleep, 10
keywait, F21
SendEvent {Click, , , Up}
return

F22:: ;TEMP
SendEvent {Click 131, 767, down}
MouseMove, 6, 0,, R
Sleep, 10
keywait, F22
SendEvent {Click, , , Up}
return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.

07 May 2021, 11:14

I do not have a way to test, but you might have a timing issue with the "key wait", as I'm not sure how the knob works in the setting of your script's key wait. You might need to add a sleep or do some testing on how key wait is being handled. In scripts with the standard mouse wheel, it is common for the wheel to generate multiple activations in fast succession.
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

08 May 2021, 14:19

Question. Can I set Timer to the Mouse CLick Down? say 3 Seconds. and While it is held down I can Adjust the Mouse move Left or RIght then Click up before return.
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

08 May 2021, 14:20

and or cancel timer if no mouse move activity within 200mili seconds
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.

08 May 2021, 15:12

Code: Select all

#SingleInstance Force
#InstallMouseHook
SetTimer, Clicky, -3000
SoundBeep, 1000
Return
Clicky:
SoundBeep, 1500
If (A_TimeIdleMouse > 200)
 Return
Click, D
MouseMove, 30, 0,, R
Click, U
Return
Different:

Code: Select all

#SingleInstance Force
#InstallMouseHook
threshold := 200
SoundBeep, 1000
Click, D
SetTimer, Check, %threshold%
SetTimer, Done, -3000
Return
Check:
If (A_TimeIdleMouse < threshold)
 Return
Done:
SetTimer, Check, Off
SetTimer, Done, Off
If (A_TimeIdleMouse < threshold)
 MouseMove, 30, 0,, R
Click, U
SoundBeep, 1500
Return
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

09 May 2021, 01:17

I can't seem to make it work. is this how to implement it?

Whereas F15 and F16 are my Rotary CCW/CW.

Thank you so much for your help.

Code: Select all

#SingleInstance Force
#InstallMouseHook


F15::
F16::
threshold := 200
SoundBeep, 1500
Click, D
SetTimer, Check, %threshold%
SetTimer, Done, -3000
return
Check:
If (A_TimeIdleMouse < threshold)
	return
Done:
SetTimer, Check, Off
SetTimer, Done, Off
If (A_TimeIdleMouse < threshold)
 MouseMove, -30, 0,, R
Click, U
SoundBeep, 2500
Return
Last edited by gregster on 09 May 2021, 01:28, edited 1 time in total.
Reason: [code] tags added. Please use them yourself, next time. Thank you!
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.

09 May 2021, 04:23

Your explanation of the timer is not clear. Perhaps you can explain in more detail, and also describe an example of what should happen in the script.
arbibarbarona
Posts: 63
Joined: 05 May 2021, 10:19

Re: Click down Mouse and move.

09 May 2021, 08:12

It's like this. As I have explained in my above post... I have a rotary encoder for F21 (CCW) and F22(CW)

In my past code I can press down a key to be able to click at mouse coordinate.
While F1 for example is held down... I can then turn the Rotary dial Counter-clockwise or clockwise (F21/F22) to increase/decrease mouse pos values.
Then Release/ Held up F1 to finish. I wanted to be able to eliminate the need to press down F1 but instead, incorporate that Comand under F1 to the rotary encoder (F21/F22)
I Figure out the Mouse Click hold down needs to be timed so mouse move can act then release when no mouse move is done.

This is my Separate mouse click and Mouse move Script (which work)

Code: Select all

F1:: ;TEMPERATURE
WinMaximize, ahk_class Qt5QWindowIcon  ;Davinci Resolve Color
SendEvent {Click 131, 770, down}
keywait, F1
SendEvent {Click, , , Up}
return

F21::
MouseMove, -1, 0,, R
return

F22::
MouseMove, 1, 0,, R
return

This one example you showed me works but I can't get to lower than 6 pixel increase or decrease values 

F21::
F22::
Click, 134 739 D
Sleep, 10
MouseMove, A_ThisHotkey = "F21" ? -6 : 6, 0,, R
Click, U
Return

So my commands should be like this

Left click down x,y pos (timed 3 seconds)
Mouse Move Increase/decrease values
Left Click Up

else if no mouse move in 300 milliseconds
Left Click Up
Last edited by gregster on 09 May 2021, 11:31, edited 1 time in total.
Reason: [code] tags added, again. Please use them yourself, next time. Thank you!
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Click down Mouse and move.

09 May 2021, 08:41

Code: Select all

F21::
F22::
If !go
 Click, 134 739 D
go := True
MouseMove, A_ThisHotkey = "F21" ? -3 : 3, 0,, R
SetTimer, Stop, -300
Return
Stop:
Click, U
go := False
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 160 guests