Disable alt-tab task switching

Is it possible to disable alt-tab or the windows key in SDL? I know
it’s possible to do by using SetWindowsHookEx, but I’m hoping there’s an
easier way with DirectInput.

Matthew Mastracci wrote:

Is it possible to disable alt-tab or the windows key in SDL? I know
it’s possible to do by using SetWindowsHookEx, but I’m hoping there’s an
easier way with DirectInput.

After examining the SDL library code, it doesn’t look possible right out
of the box. I would imagine that it would be best in SDL_WM_GrabInput -
maybe another flag? I’ll probably be patching my local version of SDL,
but it would be great if I could get this in the main version.

If I put in some sort of extension for SDL, would it be accepted? Where
would it be best to put it? Because SDL already resides in a DLL, it’s
much easier to put the low-level keyboard hook in there…

I know why you would want to disable ALT-TAB, because it could interferer with
the normal operation of your game… surfaces lost and all…But what would
happen if you did disable the ALT-TAB and your game crashed? Windows would
lock up. The user would be left no option apart from rebooting their PC.
Which is bad.

I think that instead of restricting what the user can do with their PC, the
programmer should make sure that the game does not go insane when something
weird happens to the system.

It is true that the coder cannot possible code for every eventuality when it
comes to a users system, it is always nice to see a game that behaves
responsibly when weird things happen.

Don’t get me wrong here, I’m not saying that you’re wrong, I’m just offering
my opinion as a user.

All the best

JasonOn Wednesday 24 April 2002 11:23 pm, Matthew Mastracci wrote:

Is it possible to disable alt-tab or the windows key in SDL? I know
it’s possible to do by using SetWindowsHookEx, but I’m hoping there’s an
easier way with DirectInput.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thing is, even if you disable Alt-Tab, you don’t eliminate the
problem of lost surfaces and the like, because your user could get an
IM, or an email popup happens, or almost anything else. There are a
zillion ways for your program to lose control under Windows, and you
need to be able to cope with them. So if you want to disable Alt-Tab
to avoid writing all that code, it won’t help enough.

If you want to disable alt-tab because it might be a valid key
combination for your user to hit as part of gameplay, my suggestion
is that you change the design so it isn’t and make the game do the
Right Thing when it’s hit.

I’ve seen many people try this over the last five years, and I’m not
aware of anyone who’s actually succeeded. Sorry. :frowning:

Kent

On Sun, 28 Apr 2002 01:31:15 +0100, Jason Farmer scribbled:>I know why you would want to disable ALT-TAB, because it could

interferer with the normal operation of your game… surfaces lost
and all…But what would happen if you did disable the ALT-TAB and
your game crashed? Windows would lock up. The user would be left no
option apart from rebooting their PC. Which is bad.

I think that instead of restricting what the user can do with their
PC, the programmer should make sure that the game does not go insane
when something weird happens to the system.

It is true that the coder cannot possible code for every eventuality
when it comes to a users system, it is always nice to see a game
that behaves responsibly when weird things happen.

Don’t get me wrong here, I’m not saying that you’re wrong, I’m just
offering my opinion as a user.

On Wednesday 24 April 2002 11:23 pm, Matthew Mastracci wrote:

Is it possible to disable alt-tab or the windows key in SDL? I
know it’s possible to do by using SetWindowsHookEx, but I’m hoping
there’s an easier way with DirectInput.


Kent Quirk, CTO, CogniToy
@Kent_Quirk
http://www.cognitoy.com

Actually, the biggest reason I need to disable ALT-TAB is to pass it to
the server as a keystroke. I’m actually trying to wire up VNC to use
SDL as a backend. No matter what, though, the user can ALWAYS
ctrl+alt+del out of a game (there’s no real way to stop this under
Win32, besides crashing the box ;)).

I was curious, though, whether people might possibly use something like
this in games as well. I know that while playing Tribes I would often
end up accidentally alt-tabbing out of the game (I had a jetpack on the
alt-key and would occasionally press tab for scores). Annoying, if you
ask me. :wink:

I’d like to have some way to block most, if not all, WM keystrokes. It
might even be possible to pass an SDL event to the application whenever
a WM keystroke event happens and the app can decide what to do at
that point with it…

Overall, it ends up being a pretty significant change to some of the DI
input handing.

Do you have any suggestions as how to responsibly handle this
functionality? I know it shouldn’t be on by default, but it would be a
nice-to-have thing for those (like me) who actually need the ALT-TAB for
something useful.

Jason Farmer wrote:> I know why you would want to disable ALT-TAB, because it could interferer with

the normal operation of your game… surfaces lost and all…But what would
happen if you did disable the ALT-TAB and your game crashed? Windows would
lock up. The user would be left no option apart from rebooting their PC.
Which is bad.

I think that instead of restricting what the user can do with their PC, the
programmer should make sure that the game does not go insane when something
weird happens to the system.

It is true that the coder cannot possible code for every eventuality when it
comes to a users system, it is always nice to see a game that behaves
responsibly when weird things happen.

Don’t get me wrong here, I’m not saying that you’re wrong, I’m just offering
my opinion as a user.

All the best

Jason

On Wednesday 24 April 2002 11:23 pm, Matthew Mastracci wrote:

Is it possible to disable alt-tab or the windows key in SDL? I know
it’s possible to do by using SetWindowsHookEx, but I’m hoping there’s an
easier way with DirectInput.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

See my previous message- it’s not necessarily for gaming, but I thought
it could be handy for people who wanted to disable things like the
Windows key. As I said before, people can always ctrl+alt+delete out
of an application, fullscreen or not, keyboard filtered or not, so
you’ll always need to be aware of losing your surface.

BTW, I’ve got it working under NT4SP3/2000/XP with a low level keyboard
proc. There’s something different you need to do for Win95/98 and
something else totally different for NT4SP1-2. Unfortunately, I don’t
know how best to handle getting the events into the SDL event queue for
things like the tab key. It’s a bit hacky right now. Still
investigating…

Kent Quirk wrote:> Thing is, even if you disable Alt-Tab, you don’t eliminate the

problem of lost surfaces and the like, because your user could get an
IM, or an email popup happens, or almost anything else. There are a
zillion ways for your program to lose control under Windows, and you
need to be able to cope with them. So if you want to disable Alt-Tab
to avoid writing all that code, it won’t help enough.

If you want to disable alt-tab because it might be a valid key
combination for your user to hit as part of gameplay, my suggestion
is that you change the design so it isn’t and make the game do the
Right Thing when it’s hit.

I’ve seen many people try this over the last five years, and I’m not
aware of anyone who’s actually succeeded. Sorry. :frowning:

Kent

On Sun, 28 Apr 2002 01:31:15 +0100, Jason Farmer scribbled:

I know why you would want to disable ALT-TAB, because it could
interferer with the normal operation of your game… surfaces lost
and all…But what would happen if you did disable the ALT-TAB and
your game crashed? Windows would lock up. The user would be left no
option apart from rebooting their PC. Which is bad.

I think that instead of restricting what the user can do with their
PC, the programmer should make sure that the game does not go insane
when something weird happens to the system.

It is true that the coder cannot possible code for every eventuality
when it comes to a users system, it is always nice to see a game
that behaves responsibly when weird things happen.

Don’t get me wrong here, I’m not saying that you’re wrong, I’m just
offering my opinion as a user.

On Wednesday 24 April 2002 11:23 pm, Matthew Mastracci wrote:

Is it possible to disable alt-tab or the windows key in SDL? I
know it’s possible to do by using SetWindowsHookEx, but I’m hoping
there’s an easier way with DirectInput.