Disable Windows keyboard?

Just starting out? Need help? Post your questions and find answers here.
Jimbo_H
Enthusiast
Enthusiast
Posts: 103
Joined: Mon May 10, 2004 7:37 pm
Location: West Yorkshire, England

Disable Windows keyboard?

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
roachofdeath
User
User
Posts: 78
Joined: Sun Apr 24, 2005 3:22 am

Post by roachofdeath »

You could just block all unput entirely:

Code: Select all

Procedure block()
 BlockInput_(1)
endprocedure

Procedure unblock()
 BlockInput_(0)
endprocedure
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Sorry, i think i misunderstood the initial question :?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

The BlockInput function blocks keyboard and mouse input events from reaching applications. :roll:
Jimbo_H
Enthusiast
Enthusiast
Posts: 103
Joined: Mon May 10, 2004 7:37 pm
Location: West Yorkshire, England

Post 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
Post Reply