Page 1 of 1

While running a script, how do I activate a hotkey which is defined in the same file in another location?

Posted: 13 Jun 2019, 08:50
by t4akawolf
Is this possible?

The following is my rough intention:

Code: Select all

hotkey1:: (action)

hotkey2:: (action)

hotkey3:: (action)

hotkey4:: (action) and also if conditionA, call hotkey1, else if conditionB, call hotkey2, else call hotkey3
I don't want to be inefficient and redefine the first three actions within hotkey4 again. I'm sure there's a right way to achieve this; could anyone please tell me?

Re: While running a script, how do I activate a hotkey which is defined in the same file in another location?

Posted: 13 Jun 2019, 09:09
by Rohwedder
Hallo,
try:

Code: Select all

1::MsgBox, 1
2::MsgBox, 2
3::MsgBox, 3
4::
IF A_PriorHotkey between 1 and 3
	Goto,% A_PriorHotkey
Return

Re: While running a script, how do I activate a hotkey which is defined in the same file in another location?  Topic is solved

Posted: 13 Jun 2019, 09:37
by t4akawolf
Oh, I didn't see your response. I was researching in the meanwhile and I came back to report that I worked it out by using Labels and goto. As follows:

Code: Select all

Label1:
hotkey1:: (action)

Label2:
hotkey2:: (action)

Label3:
hotkey3:: (action)

Label4:
hotkey4:: (action) and also if conditionA, goto Label1, else if conditionB, goto Label2, else goto Label3
I really appreciate your response, though :)