Disable Windows Key

BlitzMax Forums/BlitzMax Programming/Disable Windows Key

Chugs40(Posted 2007) [#1]
Does any one have any code to disable the windows key. To Prevent minimize.


GfK(Posted 2007) [#2]
Why not...
If AppSuspended()
'wait til Not AppSuspended()
EndIf



grable(Posted 2007) [#3]
You could use windows hooks, heres an example using a low-level keyboard hook that disables the left WIN key and the right WIN key as long as the hook is active.

see Windows Hooks for more info.

hook.c

Compile dll:
gcc -shared hook.c -o hook.dll

Hook.bmx

test.bmx
SuperStrict

Import "Hook.bmx"

If LoadHook( "hook.dll") Then
	Print "Hook is loaded."
	If InitHook( WH_KEYBOARD_LL, "keyboard_hook") Then
		Notify "Hook is active, waiting for termination"		
	Else
		Print "error:InitHook() failed"
	EndIf
Else
	Print "error:LoadHook() failed"
EndIf
FreeHook()



GfK(Posted 2007) [#4]
I don't know what any of that does. Will the user still be able to right-click on the task bar and select 'show desktop'? Because that minimises everything thats open.

Its far better to get your program to recognise and operate safely in a minimised state, than trying to stop the user minimising it in the first place.


grable(Posted 2007) [#5]
You should do both, its not very fun to drop out of the game just because you hit the wrong key.

Other things that could be disabled are the Accessibility keys. (they are allso annoying ;)

EDIT: yeah the ShowDesktop menu will probably still work.


FlameDuck(Posted 2007) [#6]
What GfK says. People who mess up Windows deserve to watch Tomb Raider in hell for all eternity.

Other things that could be disabled are the Accessibility keys.
You're supposed to disable those yourself, if you don't need them.


Chugs40(Posted 2007) [#7]
Thanx for all the replies/code guys, I will try these.
I don't want to completely do away with minimizing. It's just an option for certain things!

I can get my apps to minimize and maximize alright - The only problem i seem to have is while minimized the music still plays! So i need to trap the input and pause/disable the sound channel during that time.


GfK(Posted 2007) [#8]
The only problem i seem to have is while minimized the music still plays! So i need to trap the input and pause/disable the sound channel during that time.
AppSuspended() is what you need.


Chugs40(Posted 2007) [#9]
Thanx Gfk...

I will try this...


Chugs40(Posted 2007) [#10]
Well thats worked well so far, I am now patching and updating my latest 3 Bmax game releases!

I may post them in the Showcase later for testing and feedback :)

Thanx again everyone!