define hotkey with modifier in loop

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kurti
Posts: 1
Joined: 21 Jul 2018, 04:27

define hotkey with modifier in loop

21 Jul 2018, 04:36

I'm sorry if this is a stupid question, but I can't find the solution for the life of me.

I have a loop that defines a hotkey for each character a-z:

Loop, 26
Hotkey, % Chr(A_Index + 64), DoSomething

What I can't figure out is how to do this with a modifier symbol, e.g. "+" (Shift), so that the hotkey is only triggerd when I have Shift pressed together with the character.
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: define hotkey with modifier in loop

21 Jul 2018, 05:17

Code: Select all

Loop, 26
{
	key := % Chr(A_Index + 64)
	Hotkey, %key%, DoSomething
	Hotkey, +%key%, DoSomethingElse
}
return

DoSomething:
DoSomethingElse:
	MsgBox, % A_ThisHotkey
return
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: define hotkey with modifier in loop

21 Jul 2018, 18:01

You can simply concatenate.

Code: Select all

Loop, 26
    Hotkey, % "+" Chr(A_Index + 64), DoSomething
key := % Chr(A_Index + 64)
This is tolerated by the program, but invalid. The percent sign should be removed.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 212 guests