Jump to content

Disable Simultaneous Button Presses


Recommended Posts

Hi guys, hope it's ok for me to ask this question because I had a look around and couldn't find any other threads covering the same thing.

I was wondering if it's possible to make a script so that when you press 2 specific keys on your keyboard together then nothing registers, however if you press them individually then they work as normal.

I tried a script of the form:

While 1

If _IsPressed('31')=1 AND _IsPressed('32')=1 Then

Send("{1 UP}")

Send("{2 UP}")

EndIf

WEnd

but the problem is that when I release the 1 key, I want it to send the 2 key that I'm still holding down. I thought about adding some more IsPressed checks to see if I'm still holding a key but those all fail too because of the Send Up commands.

Simply put I want to be able to press 1 or 2, but if I press both nothing gets sent, but when I release one of the keys the end other continues sending as normal.

Sorry if I didn't explain very clearly, really I'm hoping there's just some simple command that I'm overlooking but any help or suggestions that I can look into would be great, thanks for your help.

 

Link to comment
Share on other sites

Welcome to the forum. :bye:

Hope this helps.
 

#include <Misc.au3>
_HotKey("{ESC}")
_HotKey("{1}")
_HotKey("{2}")
Func _HotKey($hotkey = "")
    Switch @HotKeyPressed
        Case "{ESC}"
            Exit MsgBox(64 + 262144, Default, "Exit", 1)
        Case "{1}"
            If _IsPressed("32") Then Return
            Beep(1000, 100)
        Case "{2}"
            If _IsPressed("31") Then Return
            Beep(2000, 100)
        Case Else
            If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed)
            If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.")
    EndSwitch
EndFunc   ;==>_HotKey

While Sleep(100) ; here should be your application.
WEnd ; meanwhile, here is a dummy loop.
Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

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