HiNoTora Posted January 2, 2014 Posted January 2, 2014 Hi guys, i have this script Sleep(3000) while 1 _FirstLoop() _SecondLoop() _ThirdLoop() Wend Func _FirstLoop() Send("a") Sleep(500) Send("b}") Sleep(500) ; first of loop Send("c") Sleep(500) Send("d") Sleep(500) EndFunc Func _SecondLoop() Send("Hello") ; Second loop Sleep(15000) EndFunc Func _ThirdLoop() Send("{HI}") ; third loop Sleep(5000) EndFunc but it dont work as i like, it does still like Sleep(3000) while 1 Send("a") Sleep(500) Send("b}") Sleep(500) Send("c") Sleep(500) Send("d") Sleep(500) Send("Hello") Sleep(15000) Send("{HI}") Sleep(5000) EndFunc what i need it to do is 3 different loops keep looping all the time, so if first loop ends it starts again and if second loop has its time arrived then it does its stuff nd so on
MilesAhead Posted January 2, 2014 Posted January 2, 2014 The functions do not contain loops. You only have a while loop. If you want CoRoutines you should use a language that supports them. Coroutines My Freeware Page
Solution Bert Posted January 2, 2014 Solution Posted January 2, 2014 no. You want multi threading. AutoIt does not support that. The Vollatran project My blog: http://www.vollysinterestingshit.com/
jdelaney Posted January 2, 2014 Posted January 2, 2014 (edited) Remove the sleeps, and use this function with the proper 2nd param values AdlibRegister Then look into helpfile:Command Line Paramaters to start second instances of scripts (To execute a single line of code, use the command, part) Edited January 2, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
HiNoTora Posted January 2, 2014 Author Posted January 2, 2014 But if i do 2 scripts While 1 Send "f" Sleep(500) Wend And second one While 1 Send "a" Sleep(5000) Wend And then i include them into 3rd script #include <Loop1.au3> #include <Loop2.au3> While 1 Send "ffff" Sleep(15000) Wend would this work? if yes how i make those work together?
jdelaney Posted January 2, 2014 Posted January 2, 2014 (edited) As close as you can get to 'multi' threading: expandcollapse popup#include <WinAPI.au3> $iPID = Run("notepad.exe") Local $hNotepad,$hTemp,$hControl While Not $hNotepad $aNotepad = WinList("[CLASS:Notepad]") For $i = 1 To UBound($aNotepad)-1 _WinAPI_GetWindowThreadProcessId($aNotepad[$i][1],$hTemp) If $hTemp=$iPID Then $hNotepad=$aNotepad[$i][1] ExitLoop EndIf Next WEnd While Not $hControl $hControl = ControlGetHandle($hNotepad,"","Edit1") WEnd AdlibRegister("Every2Seconds",2000) AdlibRegister("Every5Seconds",5000) AdlibRegister("Every11Seconds",11000) GUICreate("Close to exit") GUISetState() Do Until GUIGetMsg()=$GUI_EVENT_CLOSE Func Every2Seconds() Run(@AutoItExe & ' /AutoIt3ExecuteLine "ControlSetText(Hwnd(""' & $hNotepad & '""),"""",Hwnd(""' & $hControl & '""),ControlGetText(Hwnd(""' & $hNotepad & '""),"""",Hwnd(""' & $hControl & '"")) & ""2Sec"" & @CRLF)"') ;~ ControlSetText($hNotepad,"",$hControl,ControlGetText($hNotepad,"",$hControl) & "2Sec" & @LF) EndFunc Func Every5Seconds() Run(@AutoItExe & ' /AutoIt3ExecuteLine "ControlSetText(Hwnd(""' & $hNotepad & '""),"""",Hwnd(""' & $hControl & '""),ControlGetText(Hwnd(""' & $hNotepad & '""),"""",Hwnd(""' & $hControl & '"")) & ""5Sec"" & @CRLF)"') ;~ ControlSetText($hNotepad,"",$hControl,ControlGetText($hNotepad,"",$hControl) & "5Sec" & @LF) EndFunc Func Every11Seconds() Run(@AutoItExe & ' /AutoIt3ExecuteLine "ControlSetText(Hwnd(""' & $hNotepad & '""),"""",Hwnd(""' & $hControl & '""),ControlGetText(Hwnd(""' & $hNotepad & '""),"""",Hwnd(""' & $hControl & '"")) & ""11Sec"" & @CRLF)"') ;~ ControlSetText($hNotepad,"",$hControl,ControlGetText($hNotepad,"",$hControl) & "11Sec" & @F) EndFunc Edited January 2, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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