If a given key was clicked, perform the action Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
KongKing
Posts: 76
Joined: 22 May 2022, 09:41

If a given key was clicked, perform the action

Post by KongKing » 29 Sep 2022, 10:15

Hello! How to do that, for example, I click a key
"g" and it creates a loop that sends the given text, but if I click on a key other than g it stops


Without Pause and Without Suspend


User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: If a given key was clicked, perform the action  Topic is solved

Post by mikeyww » 29 Sep 2022, 12:48

Code: Select all

$g::
SetTimer, Go, 100
Input, key, IL1, % "{LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}"
                 . "{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}"
                 . "{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}"
                 . "{Del}{Ins}{BS}{CapsLock}{NumLock}{PrintScreen}{Pause}"
SetTimer, Go, Off
Return

Go:
SendInput {Text}given text
Return

KongKing
Posts: 76
Joined: 22 May 2022, 09:41

Re: If a given key was clicked, perform the action

Post by KongKing » 30 Sep 2022, 01:35

Thanks :)

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: If a given key was clicked, perform the action

Post by Rohwedder » 30 Sep 2022, 01:51

Hallo,
or:

Code: Select all

#InstallKeybdHook
$q Up::
While, (A_PriorKey = "q") or (A_TimeIdleKeyboard > 200)
{
	SendInput, {Text}given text
	Sleep, 100
}
Return

Post Reply

Return to “Ask for Help (v1)”