flat assembler
Message board for the users of flat assembler.

Index > Windows > How can I prevent ALT-TAB and CTRL_ESC?

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 08 Jul 2006, 10:53
I need to create a full screen app that does not allow the user to switch to another process.

I want to make it such that only CTRL-ALT-DEL (a special windows key combo) can stop the program.

I need to support WIN95 and up.

The program is a standard GUI app with a message loop. I tried blocking the various WM_KEYDOWN, WM_SYSKEYDOWN etc. after a GetMessage but without success.

Is there a way to do it?
Post 08 Jul 2006, 10:53
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 08 Jul 2006, 23:08
I'm not sure, but SetWindowsHookEx might work. Question

Sorry I can't say for sure, but I've never used it to trap keystrokes.

HTH
Post 08 Jul 2006, 23:08
View user's profile Send private message Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 09 Jul 2006, 01:49
using a hook you can trap all except ctrl + alt + del i think. search the boards for one of my example posts. another member had posted a better one too. my example worked only on nt systems, not win9x though
Post 09 Jul 2006, 01:49
View user's profile Send private message Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 09 Jul 2006, 01:58
Post 09 Jul 2006, 01:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 09 Jul 2006, 12:11
Thanks for the tips cod3b453 and coconut.

However the WH_KEYBOARD hook works for the Windows key but fails for CTRL-ESC and ALT-TAB.

There must be a way to do it?
Post 09 Jul 2006, 12:11
View user's profile Send private message Visit poster's website Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 09 Jul 2006, 13:54
did you try wh_keyboard_ll
Post 09 Jul 2006, 13:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 09 Jul 2006, 15:02
Quote:
did you try wh_keyboard_ll
Yeah, the result was the same for both keyboard hooks.
Post 09 Jul 2006, 15:02
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 09 Jul 2006, 15:26
I found some old source which disabled the CTRL+ALT+DEL sequence but only under win9x:
Code:
        invoke  SystemParametersInfo, SPI_SCREENSAVERRUNNING, 1, 1, 0 ; disables CTRL+ALT+DEL

        invoke  SystemParametersInfo, SPI_SCREENSAVERRUNNING, 0, 1, 0 ; enables CTRL+ALT+DEL    
But here's a definition from Win32 API Reference:
Quote:
SPI_SCREENSAVERRUNNING Windows 95 only: Used internally; applications should not use this flag.
I have no access to win9x and could not check if it actually works. On my XP it does not, but of course it's 9x only solution, so check this on 9x machine.
Post 09 Jul 2006, 15:26
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 10 Jul 2006, 07:51
Reverend wrote:
disabled the CTRL+ALT+DEL
If I disable CTRL+ALT+DEL also then the user has no way of exiting the program. I didn't want to be so restrictive. My intention is just to stop accidental exiting, but deliberate stopping with CTRL+ALT+DEL is desirable so the computer can be returned to normal use at the end of the day.
Post 10 Jul 2006, 07:51
View user's profile Send private message Visit poster's website Reply with quote
white_wight



Joined: 03 Feb 2006
Posts: 24
white_wight 10 Jul 2006, 15:37
Use WS_EX_TOOLWINDOW extended style.

Or, if you want the taskbar not being used at all, you could FindWindow it with class name 'Shell_TrayWnd', and then SW_HIDE it.
Post 10 Jul 2006, 15:37
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 10 Jul 2006, 19:27
The problem is those key combinations will probably be filtered by windows, so I can only suggest that you create an app window without a close option and create a hotkey CTRL+ALT+[KEY] that is the only way to stop the program.
Post 10 Jul 2006, 19:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 10 Jul 2006, 23:06
white_wight wrote:
WS_EX_TOOLWINDOW extended style.
I used WS_POPUP and use the desktop window as the parent. This creates a full screen window without any non-client area. That way I can place whatever is needed for control anywhere in the window. The only thing left to do is to disable the keyboard functions for switching to other tasks.
Post 10 Jul 2006, 23:06
View user's profile Send private message Visit poster's website Reply with quote
white_wight



Joined: 03 Feb 2006
Posts: 24
white_wight 12 Jul 2006, 22:56
Quote:
The only thing left to do is to disable the keyboard functions for switching to other tasks.

So you're might be writing some kind of alternative shell (the default shell for Win is explorer.exe), then you have only to change it in your registry. Save this:
Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Shell"="C:\\Path\\To\\Your.exe"    

as whatever.reg and execute. After reboot the system will use your program as a shell.
Post 12 Jul 2006, 22:56
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 13 Jul 2006, 00:36
Quote:
So you're might be writing some kind of alternative shell
Not really. The program is being given away to the participants at an upcoming seminar, so I have no control over how it might be installed. So for that reason I can't make a VXD or alternate shells etc. Indeed any installation procedure would probably be too much to handle for most of the attendees. Therefore it has to be very simple, just click to run and forget.
Post 13 Jul 2006, 00:36
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.