Disabling keys

Blitz3D Forums/Blitz3D Beginners Area/Disabling keys

Nike(Posted 2010) [#1]
How would I make my program be the front window all the time, and not be minamized by alt + tab, the windows key, or ctrl + alt + delete?


_PJ_(Posted 2010) [#2]
In short, you would need to access the Windows API functionality - with this, you can check whether or not your program has focus, and restore that focus if necessary.

In order to make use of the Windows API, you will need to use a 'decls' file for windows dlls such as advapi32.dll

If you need more details, let me know, and I'll get back to this :)

It's most likely not possible to disable the use of ctrl+alt+del or ctrl+shift+esc but also this isn't such a bad thing, as without being able to do so may result in a bug locking your computer up.


Yasha(Posted 2010) [#3]
It's explicitly not possible to block Ctrl+Alt+Del; Windows won't let your program recognise it in the first place (it's a special combination).

There are two things (that I think are important) to consider here:

1) Blitz3D isn't really the tool to use for system management tasks.

2) If you're writing a game, never attempt to block the user from accessing their computer normally. This is a surefire way to guarantee no sales and a bad rep.


Warner(Posted 2010) [#4]
Just a minor point, but beside ALT+CTRL+DELETE, there is also CTRL+SHIFT+ESCAPE, at least under my version Vista. I use that combination far more often.


_PJ_(Posted 2010) [#5]
Yep, I mentioned ctrl+hiift+esc earlier. I use this more often too, not only because it only needs one hand ^^ but also because it opens the task manager (in XP at least) to the "processes" tab rather than the default "applications" tab.


Nike(Posted 2010) [#6]
I was creating a computer lock where a flash drive would be the "key". If it is taken out of the computer, a blitz becomes full screen and black saying locked, but when it goes back in, it goes back to a smaller size. So it would not be possible to keep the program as the main target and can only be closed if the flash drive is in or computer is shut down or just disable the alt key?


Matty(Posted 2010) [#7]
As probably mentioned earlier, blitz not the best language for such a 'computer lock'. I'd hate to lose my USB key and then just have a large paper weight on my desk.


Nike(Posted 2010) [#8]
The other way to unlock your computer is to turn it off by hitting the power button or unplugging. You would then need a password to log-in.


Fernhout(Posted 2010) [#9]
I am a PLC and SCADA programmer and do Blitz3D in my spare time. Witch i do not have much, but anyway. Even under XP Vista or 7 you can only lock the computer from using CTRL+Alt+Esc or Del, if you have the server edition or the Profesional edition. (XP the server. And then you have to get the full administratior right to do it. You can write a script then that disable that combination.

It we make a SCADA on a computer we do not want the user to go behind the scade. And that is only possible using that combination of key's. But we ue the server edition and lock that out. Nothing wil happen on the screen. Not even the task manager wil come up. If they are ready and want to shut down the computer then they need a password to open a popup that they can use to close donw the computer. And even then Graphworx wil first unlink its path to the PLC and then disconnect from other servers if that is done then the computer is shuting down.

In the past user on companies did play on the computer and slow down the proces on the PLC. The communication between the computer and the PLC wil slow down if the computer have thing to do. and the events of requesting information is putting on a stack. We found that out by testing the pinball on the older windows versions. That piece of program use a lot of task resources so communication was slowing down.

Now we lock all that kind of program out and preventing user to open the taskbar and or open the start. And when it is possible to do it anyway we lock out all the functions of start even the shut down command.


_PJ_(Posted 2010) [#10]
Interesting stuff, I'm curious though, what about 3rd party task management programs?


Serpent(Posted 2010) [#11]
If you'd want to do something like this, you could try hiding all visible windows when the program recognises that the USB is out and show them all again when Blitz recognises that the USB is back in... Hiding and showing windows isn't that complicated (note that the taskbar, start menu, and desktop icons count as windows so they would be hidden as well).

If your program kept checking for windows that appear (e.g. task manager) you should stop the user from doing anything with the computer, unless they switch user and kill your process.

However there are ways to hide your program from windows so it won't show up in the processes list in task manager...

All-in-all: You could stump the basic computer user with such a program, but, as others have said, Blitz3D isn't really the program for it. You could continuously hide windows, but it would be messy and I'm sure an advanced user would find a way around it.


USB Detection: The only thing I could think of is to scan for USB devices and then check the contents of a secret file that should be on the 'key'...