Sign in to follow this  
Followers 0
Garanator

How do I disable keys from working?

8 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

In the !b whats the ! for? Sorry this is my third day using autoit?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Well I tested my script with blockinput on a WinXP and it still doesn;t work that well. Do you know anything else i can try. That hotkeyset function still allows me to hit b which screws up my script. Any other things I can try?

Share this post


Link to post
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

Share this post


Link to post
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...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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
Sign in to follow this  
Followers 0