Multiple Clicks with Scroll

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
srt
Posts: 14
Joined: 16 Mar 2024, 08:38

Multiple Clicks with Scroll

27 May 2024, 00:34

The code is supposed to click at multiple points on the screen based on the scroll counter .
However it is not getting executed.
What's missing?

Code: Select all

;Multiple Clicks with  Scroll  
counter := 0

+WheelUp::

    While (counter <= 4)
    {
        

        ; Increment the counter
        counter++

        if counter == 1 
            ; MsgBox, This is iteration number %counter%
   
            Click, 150, 1020 Left, 2



        if counter == 2 

            Click, 60, 1020 Left, 2
    

        if counter == 3 
        ; MsgBox, This is iteration number %counter%

            Click, 180, 95 Left, 2


        if counter == 4 

            Click, 1670, 95 Left, 2
         


        ; Exit the loop if the counter reaches 5
        if (counter > 4)
        {  counter := 0
            Break
        }
    }
Rohwedder
Posts: 7776
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Multiple Clicks with Scroll

27 May 2024, 04:44

Hallo,
replace all == by = or use brackets.
Try:

Code: Select all

counter := 2
q::
If counter = 2 ; works
	MsgBox, counter = 2
Return
w::
If counter == 2 ; does not work
	MsgBox, counter == 2
Return
e::
If (counter == 2) ; works
	MsgBox, (counter == 2)
Return
See https://www.autohotkey.com/docs/v1/lib/IfEqual.htm

Code: Select all

IfEqual, Var , Value          ; if Var = Value
IfNotEqual, Var , Value       ; if Var != Value
IfLess, Var , Value           ; if Var < Value
IfLessOrEqual, Var , Value    ; if Var <= Value
IfGreater, Var , Value        ; if Var > Value
IfGreaterOrEqual, Var , Value ; if Var >= Value
there is if Var = Value
but not if Var == Value
srt
Posts: 14
Joined: 16 Mar 2024, 08:38

Re: Multiple Clicks with Scroll

28 May 2024, 00:10

Thanks ...however this should be flagged as an error.
Rohwedder
Posts: 7776
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Multiple Clicks with Scroll

28 May 2024, 00:26

Why an error message? A check for numerical value is successfully performed:

Code: Select all

q::
If 2 == counter 
	MsgBox, 2 == counter `nhas a numerical value <> 0
Else MsgBox, 2 == counter `nhas no numerical value <> 0
Return
AutoHotkey v1.1 is a wild mix of legacy and expression syntax. I like this but I can still remember my initial difficulties.
Beginners are advised to use AutoHotkey v2.0 with pure expression syntax.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], DecimalTurn and 149 guests