Use Send {NumpadAdd} to trigger Keywait in another running script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
clarkj0388
Posts: 13
Joined: 11 Aug 2022, 18:50

Use Send {NumpadAdd} to trigger Keywait in another running script

Post by clarkj0388 » 02 Nov 2022, 18:29

I have a control panel that I'd like to send {NumpadAdd} to trigger another script that is in a Keywait, NumpadAdd, D.

My scripts work fine when I use the actual NumPadAdd button, but it's not working when I hit the GuiButton that runs:

Code: Select all

SendNumPadAdd:
SetTitleMatchMode, 1
Winactivate, PianoTrivia
WinWaitActive, PianoTrivia
Send {NumpadAdd down}
Sleep 20
Send {NumpadAdd up}
return
I've tried lots of different versions... Activating the window, not activating the window, SendRaw +, SendInput {NumpadAdd}.
I've tried with down, without down, without up, etc... KeyboardHook installed, and not installed.

I don't think I should HAVE to even activate the window, to have it triggered, as the physical NumpadAdd key works without the window activated just fine.

There's something I'm missing, where Send {Numpad Add} doesn't actually work the same as poking the keystroke.

Help.
Last edited by gregster on 02 Nov 2022, 19:17, edited 1 time in total.
Reason: Topic moved from the AHK v2 'Ask For Help' section.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Use Send {NumpadAdd} to trigger Keywait in another running script

Post by mikeyww » 02 Nov 2022, 19:36

Script that is in a KeyWait?
Trigger KeyWait?
Different versions?
Have it triggered?
Control panel?
GuiButton?
Poking the keystroke?

I haven't a clue what any of this is, nor do I find it in your post.

Gosub can be used to call a labeled subroutine in your script.

clarkj0388
Posts: 13
Joined: 11 Aug 2022, 18:50

Re: Use Send {NumpadAdd} to trigger Keywait in another running script

Post by clarkj0388 » 11 Nov 2022, 02:26

A script that is waiting at:

KeyWait, NumpadAdd

for a {+} input from the number pad. As I explained, it's working fine with the physical keystroke, but not when I generate the keystroke from a gui in another script with a gui button that sends NumpadAdd.
I've tried all the different versions of Send... SendInput, SendEvent, etc. Nothing working. I've tried #InstallKeyboardHook... I'm just throwing things at the wall at this point.

I used the word ControlPanel, but it's just a Gui I created with dozens of buttons on it, that I'm using to keep track of scoring, launch questions, launch a leaderboard etc. This is the only button that I'm having issues not working as I see.
Screenshot 2022-11-10 232515.jpg
Screenshot 2022-11-10 232515.jpg (232.01 KiB) Viewed 206 times
Yes, I use GoSub all the time, and maybe I should have created one giant script to do all of this, but I started with each "screen" of a trivia game being it's own script, and using my "Control Panel" to launch each script as needed. So each button launches a question of a certain category, prints out a small chit on a receipt printer on stage with the question for the host to preview, and then waits for the NumpadAdd key that the host triggers from the stage to launch the visual question on the screens around the stage. I just want to be able to send the same Numpad Add keystroke from my "Control Panel" in case the host forgets it.

I'm remoting into the stage computer from my laptop. The stage screens are using the primary monitor, and the "Control Panel" is on the secondary monitor. Unfortunately, I can't send the NumpadAdd key physically from my laptop due to the remote connection, so I thought second best would be to click a Gui, Button on my "Control Panel" to Send, NumpadAdd, but it's not triggering the other script waiting in the Keywait, NumpadAdd. Since the "Control Panel" gui is running in parallel on the same machine, I thought I could trigger the other script by sending a keystroke.] It is working fine from a physical usb number pad device on the stage however.

I've tried activating the script that is in the keywait, before sending the keystroke, but that doesn't fix the problem, still doesn't work. They physical numberpad doesn't need the script that's in a keywait to be activated, so I'm missing something else somewhere.

I sometimes don't know the right words to describe the problem, kind of like I don't know the right questions to ask...

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Use Send {NumpadAdd} to trigger Keywait in another running script

Post by mikeyww » 11 Nov 2022, 06:23

I'm not sure that your idea works with KeyWait-- others here may have suggestions or may know more-- but you can trigger a hotkey in another script, or you can send a message from one script to another. Breaking your subroutine into two parts via a hotkey might be an easy way to simulate what you are trying to do.

Post Reply

Return to “Ask for Help (v1)”