Jump to content

Recommended Posts

Posted

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

Posted (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 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.
Posted

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?

 

Posted (edited)

As close as you can get to 'multi' threading:

#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 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.

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...