Jump to content

How could I disable all user input except 1 key!


Recommended Posts

How could I disable all user input except 1 key! Kind've like BlockInput with 1 exception.

<{POST_SNAPBACK}>

use the _ispressed() UDF. Have any key nullified exept for the one you want.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

use the _ispressed() UDF.  Have any key nullified exept for the one you want.

<{POST_SNAPBACK}>

I have looked at the _ispressed() function but that just notifies you if a key was pressed, it still allows the keypress to go through. I want it to be blocked. Any other ideas?
Link to comment
Share on other sites

remove the keys from the keyboard? ha!

havent tested it, but here is a thought.

blockinput

then..

use the iskeypressed function.

and if the key you want is pressed, then unblock input lol

and send that key.

not sure if the iskeypressed will detect keystrokes when input is blocked, but its just an idea

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

How could I disable all user input except 1 key! Kind've like BlockInput with 1 exception.

<{POST_SNAPBACK}>

set all keys but one as a hotkey("{keys}","_wait")

Func _wait()

sleep(10)

Endfunc

If every key but one is set as a hotkey to the function _wait() then when those keys are pressed all it does is sleep for 10 milli secs.

.

Link to comment
Share on other sites

Maybe give this a try

#include <GUIConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <String.au3>



$My_GUI=GUICreate("My GUI",400,200,50,50)
$Button1= GUICtrlCreateButton("Test", 30,30,100,30)
GUICtrlCreateLabel("This is a 1 button testing program", 50,140)


GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button1
            Call("Set_num")
    EndSelect
WEnd


Func Set_num()
$Num_ans = InputBox("Set Key", "Please Press the selected key - ONLY" & @CRLF & @CRLF & ' The key needed is "a"' & @CRLF & @CRLF & " Give it a try.. Good luck ", ""," 1", "", "", -1, -1, 15)
    Select
        Case @error = 0;OK - The string returned is valid
            If $Num_ans ="a" Then
                MsgBox(64, "Great!", " You pressed *a*   ")
            Else
                MsgBox(64, "Sorry!", " Please try again   ")
            EndIf
            
        Case @error = 1;The Cancel button was pushed
            
        Case @error = 2;The Timeout time was reached
            
        Case @error = 3;The InputBox failed to open
            
        EndSelect
EndFunc

good luck

NEWHeader1.png

Link to comment
Share on other sites

Well you could set hotkeys for all of them.

I'm not sure if _isPressed() is called before or after the key is sent to the screen. If not then you could do

while 1

if _isPressed(20) then

hotkeyset('{space}', 'noSend')

else

hotkeyset('{space}')

endif

wend

func noSend(){}

The above is an attempt to only have one hotkey on at a time since autoit can only track up to 64 seperate declarations of hotkeys. And we all know hotkeys steal the input from other apps.

Edited by SiC_Goat

I AM ORCA!! A VERY POWERFUL WHALE!!!

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...