rmkbow Posted February 9, 2011 Share Posted February 9, 2011 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. Link to comment Share on other sites More sharing options...
Varian Posted February 9, 2011 Share Posted February 9, 2011 #include <Misc.au3> $Dll = DllOpen("user32.dll") Global $MyFunctionHasBeenRun = False ;some code If _IsPressed(01, $Dll) Then _MyFunction() ;left mousae button clicked Func _MyFunction() If $MyFunctionHasBeenRun Then Return ;skips function if Flag is True ;som code $MyFunctionHasBeenRun = True ;sets Flag to True so function will not run again EndFunc Link to comment Share on other sites More sharing options...
Tvern Posted February 9, 2011 Share Posted February 9, 2011 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 Link to comment Share on other sites More sharing options...
rmkbow Posted February 9, 2011 Author Share Posted February 9, 2011 ah, awesome. I didn`t think of implementing it like that. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now