Jump to content

Halt till two exe has finished (Novice help)


Recommended Posts

Hello,

I'm pretty new to this, so if you could help me a little with as much elaboration as possible or at least point me in the right direction.

So I would like to create a "host" file that runs two "slave" files. I would have the host file to run these slave files for a loop lets say 50 times. I would create all of the files in scite and compile the slaves.

The slaves would be like such:

Slave 1:

WinActivate("This")

Send("S")

Sleep(400)

Slave 2:

WinActivate("This")

$Pixel =0x000111
Sleep(100)
Send("P")
    Do
    $Pixel = PixelGetColor(960,249, 1)
    Until $Pixel = Dec(0x000000)
    Sleep(5000)
    Send("O")

Host:

For $repeats = 1 To 50
    WinActivate("This")
    Run("Slave1")
    Run("Slave2")
    Sleep(35000)
    Next

For

The problem is that with this kind of script the Slave 2 might not ever see this pixel and that would result in me having 50 Slave 2.exes running. 

Is there a better way to achieve my goal? I'm sure there are many but I'm a novice. Also is it possible to do the "do loop" in such order that it would wait 10 seconds for that pixel to appear and then quit if it doesn't. If I use sleep to wait it out then it's not searching for that pixel for 10 seconds, it would wait 10 seconds then continue the search. 

 

Link to comment
Share on other sites

  • Developers

No idea why one would want something like this. what exactly are you truing to accomplish here?

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I'm trying to accomplish such a feat that I would automate a part of my workflow in a program that interacts with me.

The Slave 1 would move the screen, Slave 2 does send "P" witch is a command to "search for an isolated node" in this program, once an isolated node is found the program sends me an icon that its found and this triggers the "Do loop in Slave 2" which sends keystrokes to delete it. After this the loop would continue moving and searching. 

I have also added a part to stop the screen from moving for 1,5 seconds in slave 1

$Pixel = PixelSearch(959,248,962,252,0x000000)
    If IsArray($Pixel) = True Then

        Send("T")
        Sleep(1500)

 

Link to comment
Share on other sites

maybe like this ?:

_Host()

Func _Host()
    For $repeats = 1 To 50
        WinActivate("This")
        _Slave1()
        _Slave2()
        Sleep(35000)
    Next
EndFunc   ;==>_Host


Func _Slave1()
    WinActivate("This")
    Send("S")
    Sleep(400)
EndFunc   ;==>_Slave1

Func _Slave2()
    WinActivate("This")
    Local $Pixel = 0x000111
    Sleep(100)
    Send("P")
    Do
        $Pixel = PixelGetColor(960, 249, 1)
    Until $Pixel = Dec(0x000000)
    Sleep(5000)
    Send("O")
EndFunc   ;==>_Slave2

 

Regards,
 

Link to comment
Share on other sites

5 hours ago, Trong said:

maybe like this ?:

_Host()

Func _Host()
    For $repeats = 1 To 50
        WinActivate("This")
        _Slave1()
        _Slave2()
        Sleep(35000)
    Next
EndFunc   ;==>_Host


Func _Slave1()
    WinActivate("This")
    Send("S")
    Sleep(400)
EndFunc   ;==>_Slave1

Func _Slave2()
    WinActivate("This")
    Local $Pixel = 0x000111
    Sleep(100)
    Send("P")
    Do
        $Pixel = PixelGetColor(960, 249, 1)
    Until $Pixel = Dec(0x000000)
    Sleep(5000)
    Send("O")
EndFunc   ;==>_Slave2

 

This one works, but if I'm not mistaken it gets stuck after running Slave2 if the pixel is never found.

If its possible I would want the "For 1 to 50" loop to start the host again after a the Slave 1 has finished or some time has passed (since it wont ever find the pixel if I don't change the parameters of the search). This so that I could truly work on more automated procedure of finding that node and that pixel. Once fully rotated, zoomed and turned the file, I would like it to stop finding and moving and change the window to the next one and start over, this change I could incorporate in the host or some other function.

Thanks a lot, this is really helpful to me and I appreciate it :)

Link to comment
Share on other sites

I'd love to help you find a solution to solve your problem! 

But
This is a help forum, which means that it is not the place to ask/request people to write that code for you.

So start researching and you can post the problems that you have encountered but can not resolve.
Someone will help you fix it or give suggestions for you to fix it!

Regards,
 

Link to comment
Share on other sites

  • 2 weeks later...

Hi.

You could think about a timeout in Func _Slave2() with TimerInit() and TimerDiff() to leave this loop if it is not finding the pixel.

Func _Slave2()
    WinActivate("This")
    Local $Pixel = 0x000111
    Sleep(100)
    Send("P")
    Local $iTimer = TimerInit() ; start timeout
    Do
        $Pixel = PixelGetColor(960, 249, 1)
    Until $Pixel = Dec(0x000000) Or TimerDiff($iTimer) > 10000 ; until pixel found or timeout 10 seconds
    Sleep(5000)
    Send("O")
EndFunc   ;==>_Slave2

Regards, Conrad 

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...