Jump to content

disabling keys on the keyboard?


Recommended Posts

is there a way to disable particular keys on the keyboard,

such as every keys expect the a-z, 0-9, enter, backsapce , shift?

The only thing that i'm taking another rout is that if they press on other buttons such as f1-f12 or tab, caplocks, crtl, then a msgbox pops up.

Oh, and can you disable the start menu key on the keyboard too?

Link to comment
Share on other sites

Base on what Volly said...

HotkeySet("{F11}","_Nothing") ;F11 as example
Func _Nothing()
EndFunc
This is good method to block some specified key you need, but if need to block all keys, try this:

BlockInput

--------------------------------------------------------------------------------

Disable/enable the mouse and keyboard.

BlockInput ( flag )

Parameters

flag 1 = Disable user input

0 = Enable user input

Return Value

None.

Remarks

If BlockInput is enabled, the Alt keypress cannot be sent!

The table below shows how BlockInput behavior depends on the Windows version; however, pressing Ctrl+Alt+Del on any platform will re-enable input due to a Windows API feature.

Link to comment
Share on other sites

is there a way to disable particular keys on the keyboard,

such as every keys expect the a-z, 0-9, enter, backsapce , shift?

The only thing that i'm taking another rout is that if they press on other buttons such as f1-f12 or tab, caplocks, crtl, then a msgbox pops up.

Oh, and can you disable the start menu key on the keyboard too?

This should get you started. Run it uncompiled in Scite to get the output. There are some keys you can not set as hotkeys there are also some you'll need to add in manually to what I have created below.

Start menu key can't be blocked without an external dll, however you can trap the key with if _isPressed() and resend the Windows key up to close the start menu

$hotkeysBlocked = ""

HotKeySet ("^!a","Quit")

For $i = 33 to 47
Hotkeyset(Chr($i),"_Nothing")
$hotkeysBlocked &=Chr($i)
Next

For $i = 58 to 64
    Hotkeyset(Chr($i),"_Nothing")
    $hotkeysBlocked &=Chr($i)
Next

For $i = 91 to 96
    Hotkeyset(Chr($i),"_Nothing")
    $hotkeysBlocked &=Chr($i)
Next

For $i = 123 to 127
    Hotkeyset(Chr($i),"_Nothing")
    $hotkeysBlocked &=Chr($i)
Next

Msgbox(0,"",$hotkeysBlocked & " Blocked" & @crlf & "Click OK then try typing and see which charaters you can type blocked ones will be written to the Scite console" & @crlf & "'Use CTRL + ALT + a' to exit" & @crlf)



While 1
    
    sleep(100)
    
WEnd



Func _Nothing()
    ConsoleWrite ("Blocked " & @HotKeyPressed & @crlf)
EndFunc

Func Quit()
    Exit
EndFunc

IS pressed stuff

#include <Misc.au3>
if  _IsPressed("5B") OR _IsPressed("5c") Then send("{LWIN UP}{RWIN UP}{ESC}")
Edited by ChrisL
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...