Loop Error in AutoHotkey -
i'm trying make script push space every 50ms every time press key. want loop continuously. here code:
loop { ^p:: send, {space} sleep, 50 return }
assuming want start ctrl+p, have put loop inside hotkey execution body:
^p:: loop { send, {space} sleep, 50 } return note: it's programming style end hotkeys return, please know return never reached! (never-ending loop)
for activating , deactivating space sending, might want use settimer like:
#persistent active := false ^p:: if(active) settimer, sendspace, off else settimer, sendspace, 50 active := !active return sendspace: send {space} return i don't know why it's not working. when press again nothing happens , continues pressing space.
since it's working me, guess cpu/ram blame. i'll quote answer question here: sendinput won't work @ high speed :
looks me autohotkey bug likely, or wrongly sent {space}s because ram can't handle heavy programs enough.
things can think of try:
buy better computer.
use
setbatchlines, 1ms(in beginning of script), making script sleep 20ms each millisecond , therefore consuming less cpu. might clear autohotkey's mind.setkeydelay, 50might help.
sometimes, pressed down modifier such ctrl or alt, slows down windows drastically. @ least case under windows vista. might wanna rid of ^ (ctrl) , change hotkey plain p:: hotkey, example.
if still no option you, try this:
#persistent active := false ^p:: settimer, sendspace, 50 hotkey, p, stopsendspace, on return sendspace: send {space} return stopsendspace: settimer, sendspace, off hotkey, p, stopsendspace, off return this behave above (activation ctrl+p again), deactivation happens p (no ctrl), without overriding default behaviour
Comments
Post a Comment