about Hotkeys and Send format is different

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
cgx5871
Posts: 319
Joined: 26 Jul 2018, 14:02

about Hotkeys and Send format is different

Post by cgx5871 » 23 May 2024, 15:01

for example:

Code: Select all

Hotkey "^!F1", MyFunc

MyFunc(ThisHotkey)
{
   Send ThisHotkey	;~ This is a wrong format, you must add "{", "}"
}
thishotkey is "^!F1"
What I want to Send is "^!{F1}" which is the correct way to write it.
Now they are all in V2 version,
Why can't Hotkey and Send be unified into Symbol+{*}?

Because when I use variables to convert keys, I have to replace "{", "}" with empty

Code: Select all

HK:=StrReplace(HK,"{")
			HK:=StrReplace(HK,"}")
or

Code: Select all

RegExMatch(A, "^([~+\^#!]+)([A-Za-z0-9]+)$", &match)
MsgBox match[1] '{' match[2] '}'
Parse Hotkeys to add "{" and "}"
very troublesome.

User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: about Hotkeys and Send format is different

Post by boiler » 23 May 2024, 16:22

cgx5871 wrote: Why can't Hotkey and Send be unified into Symbol+{*}?
Because they are used very differently, and having them the same as each other would make it cumbersome for 99+% of the use cases, which clearly is not worth it just to make your particular case easier. Why should we always have to put braces around all our hotkey labels just to make this one particular type of script easier? What's wrong with you having to add a line or two to this particular type of script to parse it so that everyone doesn't need to always put braces around their hotkey labels every time?

Post Reply

Return to “Ask for Help (v2)”