MouseMove Simple Problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
leumas1960

MouseMove Simple Problem

23 Aug 2017, 12:16

I have a simple problem, yet it doesn't seem to have a simple solution.

Basically, I just want to use MouseMove using variables like so:

MouseMove, CoordX, CoordY

But it simply doesn't do anything, no error level change, no move. I verified that the variables were correctly assigned beforehand (to CoordX = 260 and CoordY = 1025). Hopefully it's something simple because I'm tired :D
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: MouseMove Simple Problem

24 Aug 2017, 00:13

Use %% aruond your variable

Code: Select all


#Persistent

CoordX = 260
CoordY = 1025


w::  ; press w to move
MouseMove, %CoordX%, %CoordY%

return
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: MouseMove Simple Problem

24 Aug 2017, 01:24

for me this also works:

Code: Select all

CoordX = 260
CoordY = 1025

w:: ; press w to move
    MouseMove, CoordX, CoordY
Return
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: MouseMove Simple Problem

24 Aug 2017, 01:47

@wolf_II:
Interesting , why does that work?
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: MouseMove Simple Problem

24 Aug 2017, 01:59

https://autohotkey.com/docs/commands/MouseMove.htm
docs wrote:The x/y coordinates to move the mouse to, which can be expressions.
Whenever a command is able to accept function-style syntax, you will find the phrase "which can be expressions" in the documentation. Note that this applies to only the parameter where it is mentioned. MouseMove has a last parameter called "R", and although all preceeding parameters may be expressions, the final one may not.

When there is not mentioning of "may" be expression, you can still "force" it to accept expressions by putting a % and a whitespace character. I'm sure you have done that.
When a parameter CAN NOT accept an expression (voluntarily or otherwise), this is also documented.

Finally, when you want to pass a parameter to a command in command-style, you use %s around variables, like in good old MSDOS batch.
Last edited by wolf_II on 24 Aug 2017, 02:01, edited 1 time in total.
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: MouseMove Simple Problem

25 Aug 2017, 07:11

wolf_II wrote: [...]
Whenever a command is able to accept function-style syntax, you will find the phrase "which can be expressions" in the documentation.
[...]
That's interesting. I didn't know that previously. Well, thanks for sharing!

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: downstairs, xrocket and 281 guests