1

I currently use the following script in order to switch applications with the mouse wheel:

MButton::AltTabMenu
WheelDown::AltTab
WheelUp::ShiftAltTab

This allows me to click the mouse wheel, then roll the wheel to select the desired application, then click again to switch to it.

However, there are some applications that require me to click the mouse wheel (i.e. SketchUp in order to orbit).

How can I automatically disable/bypass this set of macros only when the SketchUp application is in the foreground (i.e. the window has the focus)?

According to the official docs, the AltTabMenu function is only valid when paired directly with a hotkey on the same line (i.e. MButton::AltTabMenu), so I can't use WinGetTitle and an IF statement to selectively call AltTabMenu.

Currently I simply disable AutoHotKey when I am using SketchUp, but this gets annoying because my AHK script also contains several other shortcuts/key remappings that I use frequently.

Thanks for any insight.

Ryan Griggs
  • 2,457
  • 2
  • 35
  • 58

3 Answers3

1

Summarizing the the solutions the wonderful AHK community already provided, here is my take on this issue:

MButton::Send , ^!{tab}  ; this sets wheel click to open the AltTab menu


#IfWinActive SketchUp ; you may need to adjust the window name here
MButton::return   ; ignore the hotkey defined above if SketchUp is active


#IfWinActive ahk_class MultitaskingViewFrame  ; Indicates that the alt-tab menu is present on the screen. The below hotkeys are used then to tab through the windows
WheelDown::Send, !{tab}
WheelUp::Send, +!{tab}
MButton::Send, {Enter}
#IfWinActive
Yane
  • 807
  • 8
  • 16
  • Hmmm, it appears you've duplicated the solution portion of my answer, just fitting it to OP's exact scenario. I prefer the 'teach a man to fish . . .' approach, but to each, their own. – EJE May 03 '19 at 17:40
  • I actually combined all the information from the comments and answers that you and @J. G. provided, ( you the wonderful AHK community I mention in the answer ;) ). And try to give the exact solution (explained as detailed as possible at the moment)because someone else might find it useful in the future. – Yane May 06 '19 at 08:01
0

I believe you can get the desired effect without using the special alt-tab commands. Instead, you can map ^!{tab} to MButton.

This test snippet worked for me:

#If WinActive( "Untitled" ) ; new, unsaved notepad window
MButton::Send , a
#If
MButton::Send , ^!{tab}
EJE
  • 1,868
  • 2
  • 8
  • 18
-1

Overwrite the hotkey at the bottom when you are in the SketchUp window

J. G.
  • 1,922
  • 1
  • 11
  • 21
  • Do you mean using `#If` with the SketchUp window? I tried this with notepad but it still made the alt-tab window show. – EJE May 02 '19 at 19:21
  • yeah, I just meant to overwrite the special hotkey at the bottom with the normal hotkey – J. G. May 02 '19 at 21:23
  • @EvanElrod From the documentation >...Currently, all special Alt-tab actions must be assigned directly to a hotkey as in the examples above (i.e. they cannot be used as though they were commands). **They are not affected by #IfWin or #If**... – Yane May 03 '19 at 11:38
  • @Yane I am aware of this and saw and read this in the original post, but tested it out anyway to see the viability of this approach since it was only four lines of code. To be clear, this was not to put the `AltTabMenu` command under the #If-directive, but instead to redefine `MButton` to something else later in the script with the #If-directive. Regardless, this is not my solution. – EJE May 03 '19 at 11:47