Alt Tab overlay Win32 identificator
Asked Answered
G

1

8

I'm mapping events coming from an external sensor (e.g. a keypad) to keyboard shortcuts and I would like to switch applications using the Fast switch overlay window ( i.e. Alt-Tab menu"), but I want to keep showing the switch menu until an application is chosen.

Basically, what am I doing is this :

if(notInSwitchMenu) 
{   // Alt-Tab keystroke, but Alt remains pressed : the menu is still visible
    Press(VK_MENU); 
    Press(VK_TAB); 
    Release(VK_TAB);
}
else
{

    if(event1) //Tab keystroke : next app
    {
        Press(VK_TAB);
        Release(VK_TAB) ;
    } 
    else if(event2) //Shift-Tab keystroke  : previous app
    { 
        Press(VK_SHIFT); 
        Press(VK_TAB);
        Release(VK_TAB);
        Release(VK_SHIFT) 
    }
    else if(event3) // we get out of the menu : the selected app has the focus.
    {
        Release(VK_MENU);
    } 
}

The Press and Release simply call SendInput with the right properties.

My problem is that I don't know a robust method to determine if the user is currently in the Alt-Tab program list. Do anyone know how to identify the Alt-Tab overlay menu with the Win32 API ?

Genseric answered 12/10, 2012 at 15:20 Comment(4)
Do you know, that using Ctrl+Alt+Tab once will force the list to stay opened until you choose an application?Cockle
The EVENT_SYSTEM_SWITCHSTART/EVENT_SYSTEM_SWITCHEND events tell you when the Alt+Tab window appears and disappears.Dharana
@Raymond Chen answer that as an answer.Allograph
In your particular case, you know when you press the alt key, just keep a flag in there to knwo when your app is still holding down the alt key.Whitecollar
D
9

The EVENT_SYSTEM_SWITCHSTART/EVENT_SYSTEM_SWITCHEND events tell you when the Alt+Tab window appears and disappears.

Dharana answered 12/10, 2012 at 18:57 Comment(3)
To elaborate, use SetWinEventHook to receive these events.Cowen
Can anyone attach an example?Plasterboard
@Plasterboard as far as I know EVENT_SYSTEM_SWITCHSTART/EVENT_SYSTEM_SWITCHEND does not work correctly since Windows 10. You can try this solution instead https://mcmap.net/q/1468376/-the-system-events-event_system_switchstart-and-event_system_switchend-works-in-windows-7-but-not-in-windows-10Parisi

© 2022 - 2024 — McMap. All rights reserved.