how to run subroutine(?) if key is held down

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ugochick
Posts: 31
Joined: 23 Mar 2021, 19:35

how to run subroutine(?) if key is held down

24 Jun 2021, 10:16

I know I dont have the terminology right, but I was wondering if someone might be able to help.

I have this script, and it's almost PERFECT. It does everything I want. The only change I want to make is, when ^+0 is Held down, it sends the tilde key (which is believe is represented like this: {vkC0}).

So, when hotkey is pressed once, it toggles between b and e
When it's double pressed, it sends i
when it's held down, it acts as if the tilde key is being held down.


Is there a way to modify my script to make it do this?

Thank you so much for your consideration!!

Code: Select all

#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1

Menu Tray, Add, silent, silent


return 

silent:
	Menu, Tray, ToggleCheck, silent
	Menu, Tray, Enable, silent ; Also enables the next test since it can't undo the disabling of itself.
	Menu, Tray, Add, silent ; Similar to above.

	Check1 := !Check1
return 


^+0:: 


	If (A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey <= 800){
		SetTimer,Cut,Off
		send, i
		KeyWait, LButton, D
		Sleep, 200
		Send, b
		
	(A_TimeSinceThisHotkey > 500)
	Send vkC0

	} else SetTimer,Cut,-50



Cut:
	Send, % (Toggle := !Toggle) ? "b" : SendE()
	return

	SendE() {
		global Check1
		Send, e
		if !Check1
			SoundBeep, 750, 100
		return
	}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, vvdee and 299 guests