Having issues with the y axis

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
luffyhill27
Posts: 2
Joined: 06 Aug 2022, 21:00

Having issues with the y axis

Post by luffyhill27 » 06 Aug 2022, 21:36

Made a script to move the mouse cursor with my arrow key. Wanted to add the option where if you push a certain letter it would go to certain spots on the screen. For some reason only the x axis is works. All the letters go to the very top of the screen and not where the Y axis is set. Not sure how to fixes this issue. I'm super new to all of this. Also is there anyway to eliminate the PressDelay? All I want is no matter how you long you hold down the arrow key, it would only go 175 pixels.

Code: Select all

SetBatchLines -1

IncrementValue = 175
typeOfMove = "R"
MouseDelay = 0
keyPressDelay := 200


D::
S::
A::
Left::
Right::
Up::
Down::

    Loop, 

    {

        If (A_ThisHotkey = "Down"){

            xVal := 0, yVal := IncrementValue
			typeOfMove = R
        }
        If (A_ThisHotkey = "Up"){

            xVal := 0, yVal = -IncrementValue
			typeOfMove = R
        }
        If (A_ThisHotkey = "Left"){

            xVal := -IncrementValue, yVal = 0
			typeOfMove = R
        }
        If (A_ThisHotkey = "Right"){

            xVal := IncrementValue, yVal = 0
			typeOfMove = R
        }
		If (A_ThisHotkey = "D"){

            xVal = 2500, yVal = 100
			typeOfMove = ""
			}
		If (A_ThisHotkey = "A"){

            xVal = 1357, yVal = 150
			typeOfMove = ""
        	}
			If (A_ThisHotkey = "S"){

            xVal = 1205, yVal = 978
			typeOfMove = ""
        	}
			
        If GetKeyState(A_ThisHotKey, "P"){

            MouseMove, %xVal%, %yVal%,%MouseDelay%,%typeOfMove%
			Sleep keyPressDelay
		}
        Else{
            Break
        }

    }

return

Esc::ExitApp

User avatar
boiler
Posts: 16772
Joined: 21 Dec 2014, 02:44

Re: Having issues with the y axis

Post by boiler » 06 Aug 2022, 23:26

You can’t have multiple assignments on the same line unless the first one uses the expression assignment operator :=. In some places you did that, but in others you didn’t. There may be other issues with your code, but that’s one problem.

See comma operator.

luffyhill27
Posts: 2
Joined: 06 Aug 2022, 21:00

Re: Having issues with the y axis

Post by luffyhill27 » 07 Aug 2022, 14:52

boiler wrote: You can’t have multiple assignments on the same line unless the first one uses the expression assignment operator :=. In some places you did that, but in others you didn’t. There may be other issues with your code, but that’s one problem.

See comma operator.
Thanks Boiler that fixed my issue.

Post Reply

Return to “Ask for Help (v1)”