jotty Posted June 28, 2019 Posted June 28, 2019 I am new with AutoIT and scripting in general, but I'm having a TON of fun with it. Easy to learn and do stuff! I'm having an issue where I wrote a function in a separate file, and when I call it in my script it'll loop until I wrangle my PC back into my control.. haha. This is my function code: StartJH() Func StartJH() MouseClick("left", 39, 334, 2) sleep(10000) MouseClick("left", 1366, 732) Sleep(1500) MouseClick("left", 900, 628) sleep(1000) Send($pw) sleep(1000) MouseClick("left", 959, 698) Sleep(2000) EndFunc I then am running a separate file that just has: #include <C:\Users\jott1\Desktop\jottyhelper\helperfuncs.au3> StartJH() Why does this thing never ever stop looping? I know I'm missing something.. At any rate I tossed a 1 in the parameters, so it was StartJH(1) in the main file and it solved the problem - was this the correct solution though? I've never encountered that in my limited programming experience. Thanks a bunch for helping me improve at AutoIT!
Subz Posted June 28, 2019 Posted June 28, 2019 Is that the full code, because you don't have any loops in it.
Subz Posted June 28, 2019 Posted June 28, 2019 Did you leave the StartJH() at the top of your udf? That would make it run twice.
jotty Posted June 28, 2019 Author Posted June 28, 2019 12 hours ago, Subz said: Is that the full code, because you don't have any loops in it. Yes the top block of code is in a file I’m keeping separate for functions I’m writing. I am running a separate file (the block of code beneath) that simply calls it. I know it doesn’t have loops - yet it seems to loop again and again.. 12 hours ago, Subz said: Did you leave the StartJH() at the top of your udf? That would make it run twice. Yes I did. It’s a separate file. I called the function to test it without anything else in the file, and it kept going and going. I am quite sure it ran more than twice. I had to kill the script to make it stop. Why would it run twice like you’ve said?
Subz Posted June 28, 2019 Posted June 28, 2019 The helperfuncs.au3 should only have the function, in your first post you called the function as well so it would have run once in the include and then again in your second script. If you add debugging to your code you can detect how many times it runs, basic example: ;~ HelperFunc.au3 Global $g_bDebug = False, $g_iDebug = 0 Func StartJH() MouseClick("left", 39, 334, 2) sleep(10000) MouseClick("left", 1366, 732) Sleep(1500) MouseClick("left", 900, 628) sleep(1000) Send($pw) sleep(1000) MouseClick("left", 959, 698) Sleep(2000) If $g_bDebug = True Then $g_iDebug += 1 MsgBox(4096, "StartJH", "Run: " & $g_iDebug) EndIf EndFunc In your second script: #include "HelperFunc.au3" ;~ Needs to reside in the same folder as this script $g_bDebug = True ;~ Enable debugging - change to false to disable debugging StartJH()
jotty Posted June 28, 2019 Author Posted June 28, 2019 Yeah so just to be more clear - helperfuncs.au3 has the written out function, and then I'm running another script called something like JottyHelper.au3 with nothing more than StartJH() that is looping infinitely. Debugging aside - is there something you can point out that would be making it loop? Thank you!
Network_Guy Posted June 29, 2019 Posted June 29, 2019 your code is working fine for me helperfunc.au3 ;StartJH() ===============> i comment this Func StartJH() MouseClick("left", 39, 334, 2) sleep(10000) MouseClick("left", 1366, 732) Sleep(1500) MouseClick("left", 900, 628) sleep(1000) ; Send($pw) =========> dont know $pw so i comment it sleep(1000) MouseClick("left", 959, 698) Sleep(2000) MsgBox(0,"","Finish !") ; ===> i added this msgbox EndFunc second script #include <HelperFunc.au3> StartJH() test those without any modification , if no loop occurs then check your full code or post it here .
Subz Posted June 29, 2019 Posted June 29, 2019 You're clearly not sending through the full code since $pw has to be defined somewhere, I've already told you there is no loop in the code you've posted, so either post the full code or debug your code, to find out if it is looping. If it is looping the function would between While/Wend, For/Next, Do/Until or you're calling the function within another function causing an internal loop.
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