Jump to content
Sign in to follow this  
gamepin126

_IsPressed behaving weirdly?

Recommended Posts

gamepin126

Using this code, and if you start pressing buttons fast enough it starts acting really weirdly. I was playing a game and got disconnected because of spamming (not intended). It started started acting as if I held the button down permanently, I wasn't. Then it'd start sending things I didn't want to be sent.

#include <misc.au3>
Dim $i[3] = ["2", "1", "0"]
$dll = DllOpen("user32.dll")
$c = 0
While 1
    If _IsPressed("62", $dll) Then ;numpad 2
            $c = 2
    ElseIf _IsPressed("65", $dll) Then ; numpad 5
            $c = 1
    ElseIf _IsPressed("68", $dll) Then ; numpad 8
            $c = 0
    Else
        $c = -1
    EndIf
    If $c > -1 Then
        Send("{ENTER}")
        Sleep(50)
        Send("Sending # " & $i[$c])
        Sleep(50)
        Send("{ENTER}")
        Sleep(100)
        $c = -1
    EndIf

    Sleep(100)
WEnd

The output if you hit the keys fast...

8885
Sending 1
1282
5Sending 0#include <misc.au3>
Dim $i[3] = ["2", "1", "0"]
$dll = DllOpen("user32.dll")
$active = 1
$c = 0
While 1

    If $active Then
        If _IsPressed("62", $dll) Then
                $c = 2
        ElseIf _IsPressed("65", $dll) Then
                $c = 1
        ElseIf _IsPressed("68", $dll) Then
                $c = 0
        Else
            $c = -1
        EndIf
        If $c > -1 Then
            Send("{ENTER}")
            Sleep(50)
            Send("Sending # " & $i[$c])
            Sleep(50)
            Send("{ENTER}")
            Sleep(100)
            $c = -1
        EndIf
    EndIf
    Sleep(100)
WEnd
2
5
2Sending 1852
58285

It varies, sometimes it'll just sit there and spam endlessly, other times it'll just say like "Sleep(50)" and continue doing what it's doing, or spit out my whole script. Is this a known issue, when I searched it didn't come up with anything like this.

Edited by gamepin126

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.