Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Alt+Tab Action for the Mouse Wheel


  • Please log in to reply
43 replies to this topic
Brandon Pace
  • Guests
  • Last active:
  • Joined: --
Old versions of Microsoft's IntelliPoint software allowed users to assign the Alt+Tab action to the mouse wheel button. Somewhere after IntelliPoint 4.0 this functionallity was removed.

I wrote the code below to give Alt+Tab functionallity to the mouse wheel button. IntelliPoint is not required. Put the file in your startup folder to have it load every time Windows starts. For example, in Windows XP, you could place it in the folder C:\Documents and Settings\All Users\Start Menu\Programs\Startup.

Click the mouse wheel to switch to the last window viewed. Hold the mouse wheel down to switch to a window of your choice -- no scrolling required.


_______________________________________________


#NoTrayIcon
*MButton::

GetKeyState, CapsState, CapsLock, T
If CapsState = D
SetCapsLockState, Off

Send, {AltDown}{Tab}
Sleep, 200
Loop
{
GetKeyState, WheelState, MButton, P
If WheelState = D
Sleep, 400
GetKeyState, WheelState, MButton, P
If WheelState = D
Send, {Tab}
Else
{
Send, {AltUp}
Break
}
}

Send, {AltUp}

If CapsState = D
SetCapsLockState, On

_______________________________________________



Keywords: alt, tab, alt+tab, alt-tab, switch, mouse, wheel, wheel button, window, next window, last window

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Nice. If you haven't already, you might try the following as well. I find it quite convenient:

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

Click the wheel to show or hide the menu, and turn it to navigate through the menu. The wheel will still function normally whenever the Alt-Tab menu isn't visible.

ULTRA
  • Members
  • 19 posts
  • Last active: Mar 11 2012 09:39 PM
  • Joined: 15 Feb 2005
Chris, when I try to use this...

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

... it doesn't work correctly. For me it only makes the selected window
flash on the taskbar but it doesn't bring it to the top and it doesn't give focus to it.


When I use something like....

MButton::
Send, {LAlt Down}{TAB}
Sleep, 2000
Send, {LAlt Up}
return

... it does bring the selected window correctly to the top and activates it.

I looked at the source-code and I think it must have to do with this section
in hook_include.cpp:

if (alt_tab_menu_is_visible)  // Can be true even if which_alt_down is zero.
			{
				if (hotkey_id_to_fire != HOTKEY_ID_ALT_TAB_AND_MENU) // then it is MENU or DISMISS.
				{
					KeyEvent(KEYUP, which_alt_down ? which_alt_down : VK_MENU);
					if (this_key.as_modifiersLR && vk != VK_LWIN && vk != VK_RWIN && !key_up)
						KeyEvent(KEYUP, vk); // Can't send sc here since it's not defined for the mouse hook.
					alt_tab_menu_is_visible = false;
					break;
				}
			}

Anyone else having this behavior?
In a world without walls and fences who needs windows and gates?

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
It's working fine for me.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
For those WinXP users who don't know already; the Alt-Tab Replacement Powertoy really comes in handy as it shows previews of windows in Alt-Tab; something I felt like sharing :)

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
I tried that once; it was too slow for me and I like tabbed applications better than SDI's anyway.

RG
  • Members
  • 17 posts
  • Last active: Oct 26 2005 01:45 PM
  • Joined: 09 Feb 2005
This code
MButton::AltTabMenu
WheelDown::AltTab
WheelUp::ShiftAltTab 
works beautifully! I am still being amazed by this program (AutoHotkey). It is excellent!
RG

hs2
  • Members
  • 11 posts
  • Last active: Apr 03 2012 09:05 AM
  • Joined: 25 Feb 2005
This one is just the best Alt-Tabber: http://taskswitchxp.sourceforge.net/
I recommend (and use) the latest 'n greatest beta version 2.0b4: best http://sourceforge.n...s/taskswitchxp/

HS2

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
Taskswitch-XP is great, but I don't use it 'cause I've been trying to limit my resource usage lately. Also, it doesn't get along well with Windowblinds, and when an app does that, it's usually not Windowblinds that gets the boot. :wink:

Brandon Pace
  • Guests
  • Last active:
  • Joined: --
I found a script I like better than the one I posted previously. This one makes use of the AltTab function Chris suggested. Just press and hold the right mouse button and use the left button to switch between windows. It seems to work fine on Win 2k and XP.

Rbutton & LButton::AltTab
$RButton::MouseClick, right


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here is a slight variation of the above that allows anything that relies on the right mouse to be held down (such as games and right-click-drag of a file in Explorer) to continue to work. However, pressing the right mouse button will cause a right-click-down event, which might cause undesirable side-effects depending on where you click:

~Rbutton & LButton::AltTab
RButton::MouseClick, right,,,,, D
RButton up::MouseClick, right,,,,, U ; This method allows right-click-drag to work.

Sith
  • Guests
  • Last active:
  • Joined: --
Thanks Chris for sharing that script.

I was originally trying to get my middle mouse button click to switch between applications. as i rarely use the middle button click event for anything much.

Whatever I tried just wouldnt work, but I know that the middle mouse button is working, as the example from the help file worked, where I could bring up the AltTab menu with middle button click.

this is what tried to get the middle mouse button to switch apps without success;
MButton::AltTab

any ideas?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

this is what tried to get the middle mouse button to switch apps without success;
MButton::AltTab

The built-in Alt-tab actions require hotkeys that are combination of two keys (such as RControl & RShift::). By contrast, displaying the alt-tab menu/window via AltTabMenu can be assigned to an unmodified hotkey.

You may have already tried the following example, but if so perhaps you can describe how the behavior you want is different from what it gives:

; Clicking the button will display the menu and turning the wheel will navigate through it:
MButton::AltTabMenu
WheelDown::AltTab
WheelUp::ShiftAltTab

urev
  • Guests
  • Last active:
  • Joined: --
Hi!
I am searching for the following thing:

If I press the midde mouse button, the task menu appears. Scrolling the mouse wheel up and down, the focused program changes and will be selected with left or middle button mouse button or return. Right button or any other key will escape from the tast menu.

Without prior pressing the middle mouse button, the wheel up and down should behave as before (e.g. for scrolling web pages).

I don't know how to implement this behavior, but perhaps you can help me.

bye, urev

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
The following script seems close to what you want. Clicking the middle button will display the menu and turning the wheel will navigate through it. This script is not supported on Windows 9x:

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