0

Is it possible in AHK to set a subroutine to trigger another subroutine by pressing its hotkey (not goSub, or GoTo)

I have a script like this...

#If (WinActive("ahk_class XXX") || WinActive("ahk_class YYY")) && !GetKeyState("Space", "P")
8:: msgbox you hit 8
7:: msgbox you hit 7
6:: msgbox you hit 6
5:: msgbox you hit 5
4:: msgbox you hit 4
3:: msgbox you hit 3
2:: msgbox you hit 2
1:: msgbox you hit 1

and I would like another hotkey g:: to trigger the 8 hotkey from within the AHK script, I know I could GoTo, but is it possible to trigger a hotkey instead?

Currently I have tried...

g Up::
SendInput{8 Down}{8 Up}
;SendInput {8 Down}{8 Up}
Return

with no result, it doesn't trigger the `8::` subroutine.

is it possible? thanks advanced.

If not possible, I have tried using GoTo, but this doesn't work...

$g::
GoTo, GoGroup1
Sleep 50
GoTo, ToolPset2
Return

GoGroup1:
some clicks
Return

ToolPset2:
some clicks
Return

cuz when pressing g it does Go to group1, but then it doesn't GoTo ToolPset2, why???

0

If you use GoSub instead of Goto, it should work.
Basically: Gosub returns, but Goto never comes back.

$g::
GoSub, GoGroup1
Sleep 50
GoSub, ToolPset2
Return

GoGroup1:
MsgBox 1
Return

ToolPset2:
MsgBox 2
Return
| improve this answer | |
  • thanks man, could you please check out this question?? superuser.com/questions/1164320/… thanksAdvanced. – litu16 Jan 6 '17 at 23:41
  • It says the question was removed!? Btw I wrote that script for hotkeys that removed the menu bars, did the key presses respond smoothly? – vafylec Jan 7 '17 at 1:22
  • Normally you send this message to either suspend or unsuspend a script, (it toggles suspend on/off): PostMessage, 0x111, 65404,,, ahk_id %hWnd%. -- This link explains how to retrieve the suspend on/off status of a script: autohotkey.com/board/topic/89284-turn-all-scripts-on-and-off/… – vafylec Jan 7 '17 at 2:08
  • yes thanks, that suspend unsuspend its done, I haven't try this question respond yet, Ill do it ASAP, thanks agian. btw can a AHK script flip horizontally (mirror horizontally) my main screen?? thanks advanced. superuser.com/questions/1164910/… – litu16 Jan 8 '17 at 21:49
  • I don't know about flipping the screen horizontally. Do you have a utility that can do this? Then maybe AutoHotkey can tell the utility to do it. – vafylec Jan 8 '17 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.