As a beginner how do I understand while loops?
While loop giving data to waveform chart OUTSIDE of the loop.
Toggle & While Loop with only 1 Hotkey
this happens because the default thread configuration prevents you from interrupting or duping another instance of a running hotkey, which also prevents you from assigning the variable. limiting them to a single thread avoids stacking hotkeys on themselves through auto-repeat and runaway loops, and other poorly implemented logic especially while hooks are not active
so you have 2 basic options, either increase thread limit through #MaxThreadsPerHotkey, or switch to timers. I prefer the latter, since timers are asynchronous and free up your keys to make any assignments or enable/disable other timers. they also have default intervals so your routines are not running balls to the wall, without any downtime your loop is really just spamming the target app with way more input than it can handle. example,
clickmonster:
Send {LButton Down}
Sleep, % Random(10,29)
Send {LButton Up}
Sleep, % Random(50,85)
return
; toggles clickmonster on/off @ 250ms interval
$=::settimer clickmonster, % (clickmonster := !clickmonster) ? "on" : "off"you generally want to avoid running persistent loops directly under hotkeys, my personal rule of thumb is if the break/return condition happens well after releasing the button that initiated this loop, put it in a timer or subroutine
More on reddit.comHow to stop While Loop after N seconds in C# (windows forms)?
Videos
While loops is kinda frustrating I'm 20 days into python and I'm stuck on loops since last 4 days