Wednesday, May 27, 2009

Activate Alt-Tab Switching With Just Your Mouse [Autohotkey Tip]

Source: http://feeds.gawker.com/~r/lifehacker/full/~3/5PgNHfj2Jrk/activate-alt+tab-switching-with-just-your-mouse

Windows only: Reader Zarek writes in with an excellent tip for switching between open windows using just the mouse—all it takes is a couple of lines of AutoHotkey code.

The script binds one of your extra mouse buttons combined with the mouse wheel to activate Alt-Tab or Shift-Alt-Tab, depending on which way you are scrolling the mouse. To set this up for yourself, you'll need to create a new AutoHotkey script or paste the following into your existing one to activate your 5th mouse button:

XButton2 & WheelDown::AltTab
XButton2 & WheelUp::ShiftAltTab

If you would rather use the 4th button, you can substitute XButton1 in the code where you see XButton2. If your mouse doesn't have any extra buttons, Zarek still has you covered—this solution will activate Alt-Tab using the middle mouse button combined with the scroll wheel—although it's a little more difficult to use and (one commenter notes that it makes the middle mouse button not work correctly, so use this one with caution).

Update: yourbuddypal in the comments notes that you need a tilde at the beginning of the line, per this AutoHotkey forum post. Thanks!

~MButton & WheelDown::AltTab
~MButton & WheelUp::ShiftAltTab

Where this tip becomes really useful is for readers using Windows 7—once you've activated the Alt-Tab dialog you can simply hold your mouse over ! any of t he preview thumbnails to see the entire window through Aero Peek—very useful when you have too many applications running at once. Thanks, Zarek!

For more AutoHotkey fun, read how to turn any action into a keyboard shortcut, or turn your capslock key into a dedicated minimize button. Got your own useful AutoHotkey trick for managing open windows? Care to share your scripting skills with the rest of the class? Dazzle us in the comments with your wisdom.