0

I need to make a custom hotkey for the alt-tab function. I'm doing this with SendInput by sending the corresponding keys, and it works fine.

However, if a hotkey already includes the alt key, the program only needs to press and release tab; but doing so causes the alt-tab menu to get stuck on screen even, and the only way to make it go away is to close my program. How could that possibly happen, and what does closing my program have to do with the menu disappearing?

On the other hand, sending (alt down)(tab down)(tab up)(alt up) keys regardless of whether alt is already down works in all cases, but I can't rely on this behavior for other reasons.

I'm using WinXP if that helps, I haven't tried it on the Win7 computer yet.

riv
  • 6,846
  • 2
  • 34
  • 63
  • 1
    This is troublesome, keyboard state is a per-process property and you cannot find out what the keyboard state is for whatever process happens to own the foreground window. It will not match yours. So you are probably doing something wrong, we can't see it. – Hans Passant Dec 28 '13 at 23:00
  • Yet how does that cause the alt-tab window to get stuck on the screen? I have checked that all my program does is send the (tab down)(tab up) input. More strangely, why does closing the program make it disappear? – riv Dec 28 '13 at 23:18
  • Why don't you just use the full set of key press? You said that it "works in all cases". What are the other reasons? – manuell Dec 29 '13 at 13:28

2 Answers2

0

Had a similar problem caused by doing PostMessage WM_KEYDOWN, VK_TAB, in an event triggered by operator clicking ALT-N to cancel an action. The ALT key was thus still down when the tab was sent. Since our code never sends a WM_KEYUP, it must have confused Win XP. Left the alt-tab menu on the screen until the application exited.

0

I don't know if this related, but Alt+Ctrl+Tab causes the menu to stuck, just like if Alt would stick when press Alt+Tab. So may be you are sending Ctrl signal somehow.

klm123
  • 12,105
  • 14
  • 57
  • 95