Jump to content

How do I disable keys from working?


Recommended Posts

I have a couple of keys I want to disable while my script runs to make sure that the scripts runs right. I need to disable esc, alt + anything, windows key, b, c, t, and w. Could someone just show me an example of how to disable one i can figure out the rest ty.

I learn better from examples then from saying use command hotkeyset or whatever.

Garanator

Link to comment
Share on other sites

You can't disable the Windows key or any built-in shortcuts involving it, and while you can disable combinations of ALT+Something, you can't block the ALT key by itself (look in the help files on HotKeySet for details). Here's an example of how to disable ALT+B:

HotKeySet("!b","_Dummy")

;The rest of your script goes here

Func _Dummy()
   ;This is a useless function
EndFunc

If your script is dependent on the user not doing anything while it's running, it might be a better idea to use BlockInput, which kills the mouse and everything on the keyboard except Ctrl-Alt-Del.

Edited by Sokko
Link to comment
Share on other sites

Wow I really like that blockinput. Thanks for the help

Edit: nvm that blockinput isn't that great it just locks everything up and barely runs the script is there any other way I can get rid of user commands? I want to get rid of the keys for the user but want them to work for the script so does this hotkeyset work?

Edited by Garanator
Link to comment
Share on other sites

The ! in !b means 'the next key should be sent as Alt+key'. Check out Send() for further info on other modifiers.

According to the help file, BlockInput() has issues under Windows 98 and ME in that it can't send simulated input (Send() etc.) while BlockInput() is active.

Link to comment
Share on other sites

No it doesn't:

; Disable the B key
HotkeySet("b", "Nothing")
; Disable Shift+B
HotkeySet("+b", "Nothing")

; Provide a method of testing
InputBox("Test", "Enter the word 'Bob':")

; A function that does nothing
Func Nothing()
EndFunc
Link to comment
Share on other sites

You can't disable the Windows key or any built-in shortcuts involving it, and while you can disable combinations of ALT+Something, you can't block the ALT key by itself (look in the help files on HotKeySet for details). Here's an example of how to disable ALT+B:

HotKeySet("!b","_Dummy")

;The rest of your script goes here

Func _Dummy()
  ;This is a useless function
EndFunc

If your script is dependent on the user not doing anything while it's running, it might be a better idea to use BlockInput, which kills the mouse and everything on the keyboard except Ctrl-Alt-Del.

if you're tricky enough you can block any key/keys except the function key on a laptop, even the ctrl alt delete can be kind of blocked (depending on the sleep in the loop and the rate the keys are pressed). i've posted a few solutions to similar problems, so i don't want to write the code again, basically, you can use _IsPressed() to see what keys are being pressed and respond accordingly. if an alt key is pressed, send an {ALTUP} and an {ESCAPE}, same for windows key, and for the regular alpha keys, just hotkey out any that you don't want used as in the examples provided. also i'd suggest checking this forum for solutions, because as i said, there have been many examples given for this same problem, except possibly different keys...
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...