Simple Question: How do I make my hotkey lines neater

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Class1
Posts: 39
Joined: 28 Sep 2017, 02:51

Simple Question: How do I make my hotkey lines neater

20 Oct 2017, 00:56

Code: Select all

CustomHotkey = A
Hotkey, %CustomHotkey%, CustomHotkey
Hotkey, +%CustomHotkey%, CustomHotkey
Hotkey, !%CustomHotkey%, CustomHotkey
Hotkey, ^%CustomHotkey%, CustomHotkey

CustomHotkey:
SendInput, {C down}
SendInput, {C up}
I was wondering if there's a way to make one line out of the 4 lines. ?

Any help would be appreciated
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Simple Question: How do I make my hotkey lines neater

20 Oct 2017, 01:03

Using the * prefix,

Code: Select all

CustomHotkey = A
Hotkey, *%CustomHotkey%, CustomHotkey

CustomHotkey:
SendInput, {C down}
SendInput, {C up}
Return
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Simple Question: How do I make my hotkey lines neater

20 Oct 2017, 01:04

You can use a for loop. Eg,

Code: Select all

CustomHotkey = A
for k, modifier in ["","+","!","^"]
	Hotkey, % modifier CustomHotkey, CustomHotkey
return	; Return here to avoid running the CustomHotkey routine on script starup.

CustomHotkey:
	SendInput, {C down}
	SendInput, {C up}
return
Also, see auto-execute section.
Cheers.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat and 289 guests