Increment pressed number in loop? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Darkmaster006
Posts: 5
Joined: 05 Sep 2022, 02:38

Increment pressed number in loop?

03 May 2024, 17:04

Hello there! Basically, I've got this code:

Code: Select all

 #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


F4::
bToggle := !bToggle
If bToggle
    SetTimer , TheLoop , 200 ; This is 200 ms
Else
    SetTimer , TheLoop , Off
Return
#Requires AutoHotkey v2.0

TheLoop:

Send , {Down}
        sleep, 400
Send , {0} (+n)
        sleep, 400
Send , {Down}
        sleep, 400
Return
What I would like is for it to press 0 (or 00, 000) the first time, then 1, then 2, 3, 4, 5... 10, 11, 12... 20... and so on, each time it is done. Any help is appreciated. Thank you!
User avatar
mikeyww
Posts: 27161
Joined: 09 Sep 2014, 18:38

Re: Increment pressed number in loop?  Topic is solved

03 May 2024, 17:23

Code: Select all

#Requires AutoHotkey v1.1.33.11
#MaxThreadsPerHotkey 2
n := 0
SoundBeep 1500

F3::
If on := !on
 Loop {
  Send {Down}
  Sleep 400
  Send % n++
  Sleep 400
  Send {Down}
  Sleep 400
 }
Reload
Return
Darkmaster006
Posts: 5
Joined: 05 Sep 2022, 02:38

Re: Increment pressed number in loop?

03 May 2024, 21:17

mikeyww wrote:
03 May 2024, 17:23

Code: Select all

#Requires AutoHotkey v1.1.33.11
#MaxThreadsPerHotkey 2
n := 0
SoundBeep 1500

F3::
If on := !on
 Loop {
  Send {Down}
  Sleep 400
  Send % n++
  Sleep 400
  Send {Down}
  Sleep 400
 }
Reload
Return
Thank you very much, mikey; with some adjustments to what I wanted to do, this worked wonders!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, Bing [Bot], OrangeCat and 99 guests