MouseMove parameters invalid in AHK v2.0.2

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
bmcclure
Posts: 31
Joined: 29 May 2018, 22:11
Location: West Virginia, USA
Contact:

MouseMove parameters invalid in AHK v2.0.2

Post by bmcclure » 27 Mar 2023, 11:19

I'm trying to convert an AHKv1 script to v2 that involves calling the MouseMove function.

In AHKv1, the function looked like:

Code: Select all

MouseMove, 1, 1, 0, R
I've tried doing this in AHKv2 several different days, but it isn't working.

Code: Select all

MouseMove(1, 1, 0, "R")
MouseMove 1, 1, 0, "R"
MouseMove(1, 1)
MouseMove 1, 1
In AHKv2 (zip version of current release), all of these calls receive "Error: Too many parameters passed to function." But the documentation clearly states it has 2 required parameters and 2 optional parameters, so I think both of those calls should be valid.

Am I doing something wrong, or is there a bug related to MouseMove in the current AHKv2 release?

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

Re: MouseMove parameters invalid in AHK v2.0.2

Post by mikeyww » 27 Mar 2023, 11:26

No problem here.

Code: Select all

#Requires AutoHotkey v2.0
F3::MouseMove 1, 1, 0, "R"
When you install AHK v2, I recommend using the standard installer with the default options.

bmcclure
Posts: 31
Joined: 29 May 2018, 22:11
Location: West Virginia, USA
Contact:

Re: MouseMove parameters invalid in AHK v2.0.2

Post by bmcclure » 27 Mar 2023, 11:30

Hm, you're right, if I include only the MouseMove line in my script, it works, but when it's in the context of my larger script I get the error about too many parameters for MouseMove.

Thank you for confirming! I'm troubleshooting further now, if I still have an issue I'll post the minimal script that produces the error.

bmcclure
Posts: 31
Joined: 29 May 2018, 22:11
Location: West Virginia, USA
Contact:

Re: MouseMove parameters invalid in AHK v2.0.2

Post by bmcclure » 27 Mar 2023, 11:35

I figured out what I did. It was entirely an error on my part of course.

In my AHKv1 script, the SetTimer label was MouseMove. When I converted the script to AHKv2, I changed the label into a function without considering that I was overwriting the MouseMove function. Since it has 0 parameters, that explains my error.

I should have included more context initially. For the record if someone else ever makes this mistake, this was the code that broke it:

Code: Select all

SetTimer(MouseMove, 5000)

MouseMove() {
    MouseMove(1, 1, 0, "R")
    MouseMove(-1, -1, 0, "R")
}
Obviously, that code can't work, but I was just completely overlooking it.

Thanks again for the quick reply, it pointed me to the solution!

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

Re: MouseMove parameters invalid in AHK v2.0.2

Post by mikeyww » 27 Mar 2023, 11:37

You are welcome.

To avoid confusion (and bugs!), I try to avoid creating any variable, object, or function name that is already used by AHK.

Along these lines, some people use "Ex" as a convenient suffix, short for "Extended". Example: MouseMoveEx.

Post Reply

Return to “Ask for Help (v2)”