Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unregistering the Alt-Tab hotkey in Windows 7

I think this problem should be easy to solve, and I'm bringing it here because I really feel like I've looked everywhere for a solution.

My code is written in C# and should simply over write the Alt-Tab hotkey. This line works in XP but return false in 7:

RegisterHotKey(handle, ID__ALT_TAB, MOD_ALT, VK_TAB)); 

I know that Windows 7 now requires that I unregister the hotkey before I can register my new one, and this is where the problem lies. When I check on the last error code I get code 1409, meaning the hotkey already exists. However if I call this line before the one above:

UnregisterHotKey(handle, ID__ALT_TAB)); 

That line fails and the last error code is set to 1419, meaning no such hotkey exists. These lines do work in XP, and I am able to register a hotkey and then unregister it. I beleive it is because I am attempting to unregister a hotkey with the wrong ID, as ID_ALT_TAB is self defined. I havent been able to find the correct ID of the Windows level Alt-Tab HotKey. Any help or general pointers would be greatly appreciated.

like image 924
Ward Avatar asked Jul 20 '10 12:07

Ward


1 Answers

I don't think there is a way to do this. Not to mention, even if you manage to somehow register your hotkey overtop of the existing one, what happens when your application exits? Suddenly, there's no Alt-Tab at all.

Rather, I'd go with another shortcut to trigger your replacement. Maybe Ctrl-Alt-Tab?

like image 70
Mike Caron Avatar answered Oct 20 '22 22:10

Mike Caron