Hotkey that uses last used key

Get help with using AutoHotkey and its commands and hotkeys
Jay Meazy
Posts: 5
Joined: 20 Jul 2019, 17:02

Hotkey that uses last used key

20 Jul 2019, 17:06

Hello, this autohotkey isn't doing anything or returning any errors

Code: Select all

if WinExist('blabla")
#InstallKeybdHook
htky = %A_PriorKey%
DeL:: 
Pause, toggle
Loop, {
ControlSend, ahk_parent, %htky%, blabla
Sleep 50
}
EDIT: i lied, it does toggle pause, but doesn't run loop, the foundation of the script works, i use it with my other ones, but something with A_priorkey isn't working
trust_me
Posts: 83
Joined: 29 Jul 2017, 10:46

Re: Hotkey that uses last used key

21 Jul 2019, 09:36

What happens if you replace htky = %A_PriorKey% with htky = a ( or the key you want to send ) ?

You can also remove the ahk_parent if the previous suggestion does not work and use the control name or nothing so it will send it to the main window.
Jay Meazy
Posts: 5
Joined: 20 Jul 2019, 17:02

Re: Hotkey that uses last used key

21 Jul 2019, 11:58

thanks for your reply, the reason i wanted to use A_priorkey is because in the game i play there's different situations where i want to use different hotkeys, so what i want the script to do is take the last key i use before i enable it and make it spam that, i generally use f1, f2, f4, f6
trust_me
Posts: 83
Joined: 29 Jul 2017, 10:46

Re: Hotkey that uses last used key

21 Jul 2019, 13:17

If you use F1 you have to send {f1} so in controlsend {%htky%} .So it gets a bit complicated if you use different keys and function keys !

see https://www.autohotkey.com/docs/commands/Send.htm

{F1} - {F24} Function keys. For example: {F12} is the F12 key.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHK_user, Bing [Bot], Google [Bot], PebblyBeachBum, zcw1030 and 48 guests