Insert other action when toggle loop is still on going

Get help with using AutoHotkey and its commands and hotkeys
Batsmaru0410
Posts: 11
Joined: 19 Jan 2019, 12:25

Insert other action when toggle loop is still on going

24 Oct 2020, 07:44

Hi, I have "a" key bound to toggle loop to continues send "a" key every 300 millisecond, and another key bound to send "b" 5 times.


What I wish to accomplish is when the loop that is sending "a" is ongoing, anytime I press "b" key, it will pause "a" and insert "bbbbb" in that ongoing string without having to toggle(stop) the "a" key in the first place.

For example the output should be: aaaaaaabbbbbbaaaaaaaaaaa (5 "b"s are inserted whenever the"b" key is pressed, and "a" continues automatically afterwards)

I have tried to add "critical" but it didn't work.

Code: Select all


a::
	
 	if (HitToggle1 := !HitToggle1){
		SetTimer, Hita, 300
		GoSub, Hita		
	} else {
		SetTimer, Hita, Off
	}
  	return
  
Hita:
	ControlSend, ahk_parent, a, Notepad
	sleep 200


	return


b:: 	
	ControlSend, ahk_parent, b, Notepad
	sleep 200
	ControlSend, ahk_parent, b, Notepad
	sleep 200	
	ControlSend, ahk_parent, b, Notepad
	sleep 200	
	ControlSend, ahk_parent, b, Notepad
	sleep 200	
	ControlSend, ahk_parent, b, Notepad
	sleep 200		
	
	return
	
	
	
User avatar
mikeyww
Posts: 4003
Joined: 09 Sep 2014, 18:38

Re: Insert other action when toggle loop is still on going

24 Oct 2020, 07:58

Read about hotkey modifier symbols. Precede your a and b hotkeys with $ so that your Send commands will get through.
$ = This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. The $ prefix is equivalent to having specified #UseHook somewhere above the definition of this hotkey.
The following script illustrates the difference. You can try pressing a and b.

Code: Select all

$a::Send a
b::Send b

Return to “Ask For Help”

Who is online

Users browsing this forum: AutohotkeyproNL, DaveT1, dreamery16, return, songdg, zvit and 55 guests