Trying to improve my script. How do you code mousemove and clicking at the same time? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lifehuh
Posts: 8
Joined: 14 Jun 2020, 21:25

Trying to improve my script. How do you code mousemove and clicking at the same time?

Post by lifehuh » 27 Jan 2023, 09:06

Sorry, it is just a newbie question.
I wonder how I could combine mousemove and clicking together.
For example, I am doing a vertical mousemove like :

MouseClick, left, posx, posy
posy := posy+100

I had set this to move posy 5 times vertically then move onto next line.

And today, i want to modify this code to allow the script to run as:

1. keep clicking left button
2. and mousemove from line to line.

User avatar
mikeyww
Posts: 26942
Joined: 09 Sep 2014, 18:38

Re: Trying to improve my script. How do you code mousemove and clicking at the same time?  Topic is solved

Post by mikeyww » 27 Jan 2023, 09:46

Hello,

The click moves the mouse before clicking. That is the purpose of specifying the coordinates.

The "Relative" parameter option is detailed in the documentation. It might be what you want here.

Code: Select all

#Requires AutoHotkey v1.1.33
Loop 5 {
 Click 0 100 Rel
 Sleep 200
}
If you are a newbie, you can use the current version of AutoHotkey.

Code: Select all

#Requires AutoHotkey v2.0
Loop 5 {
 Click '0 100 Rel'
 Sleep 200
}

lifehuh
Posts: 8
Joined: 14 Jun 2020, 21:25

Re: Trying to improve my script. How do you code mousemove and clicking at the same time?

Post by lifehuh » 27 Jan 2023, 16:51

mikeyww wrote:
27 Jan 2023, 09:46
Hello,

The click moves the mouse before clicking. That is the purpose of specifying the coordinates.

The "Relative" parameter option is detailed in the documentation. It might be what you want here.

Code: Select all

#Requires AutoHotkey v1.1.33
Loop 5 {
 Click 0 100 Rel
 Sleep 200
}
If you are a newbie, you can use the current version of AutoHotkey.

Code: Select all

#Requires AutoHotkey v2.0
Loop 5 {
 Click '0 100 Rel'
 Sleep 200
}
Hi Mikeyww,

Thanks for your quick reply on this, I tested your code and it is similar result to what I have got at the moment. But yours is more like a simplified code with the same result. Thanks!

However, I just came out with this new thought like, how do we do like "left clicking 10 times per second" + "moving the mouse from A to Z". And the distance between A to Z have spots like B, C, D, E....etc

It is like setting the mouse macros to hold left click to create a left clicking of 10 times per second, and move the mouse around.

Coz the above code let me click every single spot like A, B,C one by one, and it is slow. I am just thinking if there is a faster way.

User avatar
mikeyww
Posts: 26942
Joined: 09 Sep 2014, 18:38

Re: Trying to improve my script. How do you code mousemove and clicking at the same time?

Post by mikeyww » 27 Jan 2023, 17:51

Indeed, to speed things, decrease the sleep!

To move the mouse: MouseMove

Post Reply

Return to “Ask for Help (v1)”