increase and decrease value Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
castielo
Posts: 3
Joined: 21 Mar 2023, 11:54

increase and decrease value

Post by castielo » 21 Mar 2023, 12:21

i'm new to AHK and still learning
i want to make a script that increase a value and when reach a certain number the function change to decrease the value

Code: Select all

var := 20

$F11::
if (var = 0)
var+=2
if (var <= 20)
var-=2
send %var%
return
can i get some help

User avatar
RDC
Posts: 112
Joined: 29 Jan 2023, 10:22

Re: increase and decrease value

Post by RDC » 21 Mar 2023, 13:00

Try...

Code: Select all

^T:: 

value := 0
max_value := 10
increment := 1

loop
{
    if (value < max_value)
    {
        value += increment
    }
    else
    {
        increment := -1
        value -= 1
    }
    
MsgBox %value% 	 ; Do something with the value here.

    if (value = 0)
    {
        break
    }
        sleep 1000 	 ; wait for 1 second before the next iteration
}
Return

teadrinker
Posts: 4347
Joined: 29 Mar 2015, 09:41
Contact:

Re: increase and decrease value  Topic is solved

Post by teadrinker » 21 Mar 2023, 13:22

Code: Select all

value := 0

minValue := 0
maxValue := 20
increment := 2
Return

$F11::
   Send % value . " "

   value += increment

   if (value = minValue || value = maxValue)
      increment := -increment
Return

castielo
Posts: 3
Joined: 21 Mar 2023, 11:54

Re: increase and decrease value

Post by castielo » 21 Mar 2023, 13:45

@RDC thankyou
@teadrinker this work very well, thank you so much

Post Reply

Return to “Ask for Help (v1)”