ShadowOps Posted June 5, 2010 Share Posted June 5, 2010 Is it possible for a custom function to only be triggered when the mouse is being held down? Would HotKeySet be used at all? Link to comment Share on other sites More sharing options...
ajit Posted June 5, 2010 Share Posted June 5, 2010 #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(250) If _IsPressed("01", $dll) Then yourfunction() WEnd DllClose($dll) Ajit Link to comment Share on other sites More sharing options...
ShadowOps Posted June 5, 2010 Author Share Posted June 5, 2010 This doesn't quite fully work... I am trying to make the mouse automatically click one time a second, but once I hold the mouse button in, it always clicks once a second, even if I let go... #include "Misc.au3" $dll = DllOpen("user32.dll") While 1 sleep(1000) If _IsPressed("01", $dll) then Click() WEnd DllClose($dll) func Click() while 1 MouseClick("primary") wend endfunc Link to comment Share on other sites More sharing options...
GEOSoft Posted June 5, 2010 Share Posted June 5, 2010 (edited) Try this (untested). func Click() while 1 If NOT _IsPressed("01", $dll) then exitloop MouseClick("primary") Sleep(1000) wend endfunc Edit: Changed the order of calls in the function. Edited June 5, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ShadowOps Posted June 5, 2010 Author Share Posted June 5, 2010 This should work... Hold on... #include "Misc.au3" $dll = DllOpen("user32.dll") While 1 sleep(1000) If _IsPressed("01", $dll) then Click() WEnd func Click() while 1 If NOT _IsPressed("01", $dll) then exitloop MouseClick("primary") Sleep(1000) wend endfunc DllClose($dll) Link to comment Share on other sites More sharing options...
ShadowOps Posted June 5, 2010 Author Share Posted June 5, 2010 Nope, nothing's working... Link to comment Share on other sites More sharing options...
GEOSoft Posted June 5, 2010 Share Posted June 5, 2010 (edited) another try then and again untested. You might have to uncomment the MouseUp() line #include "Misc.au3" $dll = DllOpen("user32.dll") While 1 sleep(1000) If _IsPressed("01", $dll) then Click() WEnd func Click() while _IsPressed("01", $dll) MouseClick("primary") Sleep(1000) wend ;MouseUp( "primary" ) endfunc DllClose($dll) NM That won't work either because you are trying to click the same button that is already triggering the function(). Using the Right button to trigger the function works #include "Misc.au3" $dll = DllOpen("user32.dll") While 1 sleep(1000) If _IsPressed("02", $dll) then If Click() Then ExitLoop EndIf WEnd func Click() while _IsPressed("02", $dll) If MouseClick("primary") Then ConsoleWrite("mouse clicked" & @CRLF) Sleep(1000) wend Return 1 endfunc DllClose($dll) Edited June 5, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ShadowOps Posted June 5, 2010 Author Share Posted June 5, 2010 Still doesn't work... Whatever though. I was just wondering, what is the name of the command that moves the mouse to certain coordinates? Link to comment Share on other sites More sharing options...
GEOSoft Posted June 5, 2010 Share Posted June 5, 2010 Amazingly enough it's MouseMove() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ShadowOps Posted June 5, 2010 Author Share Posted June 5, 2010 Huh. Link to comment Share on other sites More sharing options...
JohnOne Posted June 5, 2010 Share Posted June 5, 2010 lol at changing both the mouse buttong on the scipt again Anyway your code works fine with the same button. #include "Misc.au3" $dll = DllOpen("user32.dll") While 1 sleep(100) If _IsPressed("01", $dll) then Click() WEnd func Click() while _IsPressed("01", $dll) Mousemove(700,400,10) Sleep(1000) Mousemove(600,400,10) wend ;MouseUp( "primary" ) endfunc DllClose($dll) AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ShadowOps Posted June 5, 2010 Author Share Posted June 5, 2010 How can I disable the mouse for the duration of my script, without it being stuck in a forever loop? This is how I plan to disable it: While MouseMove (@DesktopWidth, @DesktopHeight, 0) Wend But if I do that, the rest of my script can't run while the mouse is disabled... Link to comment Share on other sites More sharing options...
DW1 Posted June 5, 2010 Share Posted June 5, 2010 (edited) How can I disable the mouse for the duration of my script, without it being stuck in a forever loop? This is how I plan to disable it: While MouseMove (@DesktopWidth, @DesktopHeight, 0) Wend But if I do that, the rest of my script can't run while the mouse is disabled... Can you explain this question a bit better? I am not entirely sure what you are asking. For the mouse click script though, I think this should work for you: #include "Misc.au3" $dll = DllOpen("user32.dll") While 1 Sleep(1000) If _IsPressed("01", $dll) Then If Click() Then ExitLoop EndIf WEnd Func Click() While _IsPressed("01", $dll) MouseUp("primary") If MouseDown("primary") Then ConsoleWrite("mouse clicked" & @CRLF) Sleep(1000) WEnd Return 1 EndFunc ;==>Click DllClose($dll) EDIT: Same script as what George gave you, just had to add a mouseup() and change mouseclick() to MouseDown(). When using mouse click, you are telling it to press down and release, so even though you still have the button held down, your script released it. With MouseDown() it never tells it that the button was released. You lifting your finger is the only thing that triggers the release. Hope that makes sense. Edited June 5, 2010 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
JohnOne Posted June 5, 2010 Share Posted June 5, 2010 But then the mouse is not clicking. he wants to click while he holds the button down, the code that GEO posted does exactly that. AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
DW1 Posted June 5, 2010 Share Posted June 5, 2010 (edited) But then the mouse is not clicking. he wants to click while he holds the button down, the code that GEO posted does exactly that. Yes, it IS clicking, did you try it? It clicks. The one that GEO posted, leaves the loop after ONE click. The one he posted where you hold down the right mouse button to click the left, worked fine, but was not what was requested. EDIT: HAHA, I guess it would serve a better point when I paste the correct code LOL. Sorry JohnOne, you are indeed right, that one DOES NOT WORK. I have edited the previous code to match this as well. Here is the one I meant to, and thought I did, paste: #include "Misc.au3" $dll = DllOpen("user32.dll") While 1 Sleep(1000) If _IsPressed("01", $dll) Then If Click() Then ExitLoop EndIf WEnd Func Click() While _IsPressed("01", $dll) MouseUp("primary") If MouseDown("primary") Then ConsoleWrite("mouse clicked" & @CRLF) Sleep(1000) WEnd Return 1 EndFunc ;==>Click DllClose($dll) Edited June 5, 2010 by danwilli v120 1 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
ShadowOps Posted June 6, 2010 Author Share Posted June 6, 2010 Lol, Thanks Guys! 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