using mouse move and it slighty go more left than back to original?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
FlickZ
Posts: 28
Joined: 06 Oct 2020, 17:02

using mouse move and it slighty go more left than back to original?

26 Sep 2021, 06:50

So i'm using this code -

Code: Select all

move_5px:
	MouseGetPos, xpos, ypos
	MouseMove, -5, 0, 10, R
	Sleep, 100
	MouseMove, xpos, ypos
Return
And it goes like a pixel more to the left? Every like 20 seconds it is more to the left than the original coords. what am I doing wrong?
User avatar
mikeyww
Posts: 26849
Joined: 09 Sep 2014, 18:38

Re: using mouse move and it slighty go more left than back to original?

26 Sep 2021, 06:57

Code: Select all

Gosub, move_5px
Return

move_5px:
CoordMode, Mouse
MouseGetPos, x1, y1
MouseMove, -5, 0, 10, R
Sleep, 100
MouseMove, x1, y1
MouseGetPos, x2, y2
MsgBox, 64, Coordinates, Old:  (%x1%,%y1%)`nNew: (%x2%,%y2%)
Return
If the mouse moves further due to a manual move, then the coordinates may change. Some mouse devices are unstable and do generate moves with the smallest of vibrations.
FlickZ
Posts: 28
Joined: 06 Oct 2020, 17:02

Re: using mouse move and it slighty go more left than back to original?

26 Sep 2021, 08:52

mikeyww wrote:
26 Sep 2021, 06:57

Code: Select all

Gosub, move_5px
Return

move_5px:
CoordMode, Mouse
MouseGetPos, x1, y1
MouseMove, -5, 0, 10, R
Sleep, 100
MouseMove, x1, y1
MouseGetPos, x2, y2
MsgBox, 64, Coordinates, Old:  (%x1%,%y1%)`nNew: (%x2%,%y2%)
Return
If the mouse moves further due to a manual move, then the coordinates may change. Some mouse devices are unstable and do generate moves with the smallest of vibrations.
Thank you very much, can I prevent that or I must buy new mouse? :D
User avatar
mikeyww
Posts: 26849
Joined: 09 Sep 2014, 18:38

Re: using mouse move and it slighty go more left than back to original?

26 Sep 2021, 09:32

1. See if this script works.
2. If not, switch mouse; re-test.

My output:

image210926-1033-001.png
Script output
image210926-1033-001.png (7.92 KiB) Viewed 512 times

It seems almost impossible that this script would yield different coordinates, unless the mouse is moving quite wildly. You can post the results here.
FlickZ
Posts: 28
Joined: 06 Oct 2020, 17:02

Re: using mouse move and it slighty go more left than back to original?

26 Sep 2021, 09:34

mikeyww wrote:
26 Sep 2021, 09:32
1. See if this script works.
2. If not, switch mouse; re-test.
Also, in the game I must use this -

Code: Select all

		DllCall("mouse_event", uint, 1, int, -10, int, 0), ahk_id %id%
I have there ahk_id %id but it isnt doing it in the game (window it self) Can I do it with anything else?
Every else code like -

Code: Select all

				ControlSend, , {w down}, ahk_id %id%
			Sleep, % rnd(35000, 65000)
				ControlSend, , {d down}, ahk_id %id%
			Sleep, % rnd(250, 600) 
Is working in game...
User avatar
mikeyww
Posts: 26849
Joined: 09 Sep 2014, 18:38

Re: using mouse move and it slighty go more left than back to original?

26 Sep 2021, 10:11

QUESTION #1: Does my script work in Notepad?

QUESTION #2: Does your script work in Notepad?

QUESTION #3: What is your script?
FlickZ
Posts: 28
Joined: 06 Oct 2020, 17:02

Re: using mouse move and it slighty go more left than back to original?

26 Sep 2021, 12:07

mikeyww wrote:
26 Sep 2021, 10:11
QUESTION #1: Does my script work in Notepad?

QUESTION #2: Does your script work in Notepad?

QUESTION #3: What is your script?
1) yes
2) yes
But not working in game

3) The one that I posted.
User avatar
mikeyww
Posts: 26849
Joined: 09 Sep 2014, 18:38

Re: using mouse move and it slighty go more left than back to original?

26 Sep 2021, 12:23

QUESTION #4. When you display the value of id, what are you seeing?

QUESTION #5. On what line of your script is id defined?

QUESTION #6. What is your DLL call supposed to do?

Tips: https://autohotkey.com/board/topic/111737-how-to-make-ahk-work-in-most-games-the-basics/

If your entire script works outside your game, then you probably need the tips.

The DLL call does not work with a WinTitle in that manner. A relative mouse move moves the mouse from its current position. The window makes no difference.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mapcarter, OrangeCat and 244 guests