Page 1 of 1

Disable Windows keyboard?

Posted: Thu Nov 10, 2005 3:08 pm
by Jimbo_H
Hi all,

I'm writing a small program for my son (2yrs old) who loves bashing the keyboard and he's sort of getting the hang of moving the mouse around.

The problem I have is that when he hits the keys, it invariably causes the program to either quit, crash or for Windows to change the focus to another app.

My question is: How can I disable the whole keyboard with the exception of CTRL+ALT+DEL and ESC?

I saw an earlier post about someone wanting to disable the Windows key. One suggestion was to use the API to filter out keypresses. Great idea if you have any clue how the API works. I'm too dumb to understand the API!!! :-)

Cheers,
Jim

Posted: Thu Nov 10, 2005 5:52 pm
by Psychophanta
Hi, your kid wants a PC for himself, that's why his behaviour, :P :wink:
At the moment you can use this:

Code: Select all

If InitKeyboard()=0 Or InitSprite()=0
  MessageRequester("Error", "Can't open DirectX", 0)
  End
EndIf

hWnd.l=OpenWindow(0,300,300,500,300,#PB_Window_SystemMenu|#PB_Window_TitleBar,"")
If hWnd.l=0
  MessageRequester("Error","Something fails",0)
  End
EndIf

If OpenWindowedScreen(hWnd.l,300,300,500,300,1,0,0)=0
  MessageRequester("Error","Something fails",0)
  End
EndIf

Repeat
  ExamineKeyboard()
  Delay(20)
Until KeyboardPushed(#PB_Key_LeftShift) And KeyboardPushed(#PB_Key_Delete) And KeyboardPushed(#PB_Key_LeftAlt) And KeyboardPushed(#PB_Key_RightShift)
NOTE: Push and hold the keys in the sort after 'Until' command (this is: LeftShift, then Delete, then LeftAlt, and then RightShift)

Posted: Thu Nov 10, 2005 5:57 pm
by roachofdeath
You could just block all unput entirely:

Code: Select all

Procedure block()
 BlockInput_(1)
endprocedure

Procedure unblock()
 BlockInput_(0)
endprocedure

Posted: Thu Nov 10, 2005 6:00 pm
by Psychophanta
Sorry, i think i misunderstood the initial question :?

Posted: Thu Nov 10, 2005 7:30 pm
by Droopy
The BlockInput function blocks keyboard and mouse input events from reaching applications. :roll:

Posted: Fri Nov 11, 2005 9:12 am
by Jimbo_H
Thanks for the replies :)

I'm going integrate the code posted into my program to see how it works. As the program is mouse driven, I do need that to work.

Thank you again.

Jim