problem with script im doing

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Pasteless
Posts: 1
Joined: 16 Jan 2022, 19:31

problem with script im doing

Post by Pasteless » 16 Jan 2022, 19:37

So i have this code right here:

Code: Select all

RIGHT := 20
LEFT := -20

	~d::
	while GetKeyState("d")
	{
	DllCall("mouse_event", uint, 1, int, RIGHT, int, 0, uint, 0, int, 0)
	Sleep 1
	}
	return

	~a::
	while GetKeyState("a")
	{
	DllCall("mouse_event", uint, 1, int, LEFT, int, 0, uint, 0, int, 0)
	Sleep 1
	}
	return

return
Its supposed to turn slightly to the left when i hold a and slightly to the right when i press d
Everything works fine in itself but i wish i could sort of have a bind for all of that. What i want is so the code i wrote only does its thing when im holding my mouse button (XButton1).
As and example i would be typing normaly right now with "a" and "d" and my mouse would not turn it self but when im holding down the mouse button i specified it would start turning if i hold a and d.
Ive attempted to do it with a while but it doesnt work, unless i did it wrong.

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

Re: problem with script im doing

Post by mikeyww » 16 Jan 2022, 20:47

Code: Select all

MAG := 20

XButton1 & ~d::
While GetKeyState("d", "P") {
 DllCall("mouse_event", uint, 1, int, MAG, int, 0, uint, 0, int, 0)
 Sleep, 1
}
~XButton1::Return
 
XButton1 & ~a::
While GetKeyState("a", "P") {
 DllCall("mouse_event", uint, 1, int, -MAG, int, 0, uint, 0, int, 0)
 Sleep, 1
}
Return

Post Reply

Return to “Ask for Help (v1)”