0
votes

I have a new keyboard that has a split spacebar, backspace on left thumb, space on right thumb. Before getting this keyboard, I was using the short cut Ctrl+Alt+Space to open Launchy. With this new keyboard, I would ALSO like to be able to use Ctrl+Alt+Backspace.

I added the following mapping to AutoHotKey

^!BS::
MsgBox Working
SendInput ^!{Space}
return

If I have certain windows open (say Notpad), pressing Ctrl+Alt+Backspace shows the message box, and then launches the program as expected (the Launchy binding to Ctrl+Alt+Space is controlled by it's own options UI stuff). However, certain windows (e.g. Powershell) seem to swallow the SendInput part, so I will see the message box, but Launchy will not open.

What can I do to get AutoHotKey to send it's commands into the regular message queue instead of to the active window.

Note: I have already tried using various different combinations, but it doesn't seem to work.

Edit: Thanks to MCL for suggesting WinActivate which led me in the right direction. Full details below

Solution:

^!BS::
DetectHiddenWindows, on
WinActivate, Launchy
SendInput ^!{Space}
return

For some reason, certain apps were swallowing the keyboard shortcuts being generated by AHK. So Launchy never received them and didn't launch. However, DetectHiddenWindows and WinActivate followed by the regular keyboard shortcut seems to work.

1
Play around with combinations of #UseHook and #InstallKeybdHook. Put them at the top of your script. Also, you could consider just running it directly like Run, path\to\launchy.exe.MCL
Same comment as below, but this is not a shortcut to launch the app, it's a hotkey defined in the app to bring it into focus. The app is already running and is minimized to the tray.Ben Randall
How about using WinActivate instead?MCL
Success!... kind of. So I managed to get it to work, WinActivate being one important step. :) If you submit an answer I'll mark it as correct.Ben Randall
Good to hear. But sounds like not everything's cut and dried. If you want to know something else, post a new question or ask in the comments.MCL

1 Answers

0
votes

Using native AHK code to activate a window is usually the preferable option as opposed to sending keys somewhere. WinActivate will do what you want. However, you'll have to choose a suitable identifier for your window. Inspect the window with Window Spy; normally, the window class (ahk_class) is a good option. If your application only has one window, AHK_L's ahk_exe will be a good choice too.

Your code could look like this:

!BS::WinActivate, ahk_exe launchy.exe