Jump to content

Recommended Posts

Posted

How would I go about using ispressed to call a function only once. But after the button is de-pressed, it is immediately available again.

or is this not possible.

Posted

Varian pretty much answered this, but as I made the examples:

Blocking version:

#include <misc.au3>
Global $DLLUser32 = DllOpen("user32.dll")

While 1
    If _IsPressed("01", $DLLUser32) Then _TestFunc()
    ConsoleWrite(".") ;dots indicate the main loop is looping
    Sleep(100)
WEnd

Func _TestFunc()
    ConsoleWrite(@CRLF & "_TestFunc()!" & @CRLF)
    While _IsPressed("01", $DLLUser32)
        Sleep(20)
    WEnd
EndFunc

non-blocking:

#include <misc.au3>
Global $fRun
Global $DLLUser32 = DllOpen("user32.dll")

While 1
    If _IsPressed("01", $DLLUser32) Then
        If $fRun Then
            _TestFunc()
            $fRun = False
        EndIf
    Else
        $fRun = True
    EndIf
    ConsoleWrite(".")  ;dots indicate the main loop is looping
    Sleep(100)
WEnd

Func _TestFunc()
    ConsoleWrite(@CRLF & "_TestFunc()!" & @CRLF)
EndFunc

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...