Sign in to follow this  
Followers 0
Casablanca0s

Multi-Loop, Cycle

5 posts in this topic

Hi guys!

Help me pls to join these codes into one

While 1
If  Not ProcessExists("FirstProgram.exe") Then
Run("FirstProgram.exe")
EndIf
WEnd
While 1
If @MIN = 28 Then
RunWait ("File28.exe")
EndIf
WEnd
While 1
If ProcessExists("EMAIL.exe") Then
Sleep(20000)
Else
Run("TIME.exe")
EndIf
WEnd

As you can see I need for with 1 script to monitoring 3 programs and run at different times

how can i realize that?

Thank you

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

 

$iSleep = TimerInit()

While Sleep(100)
    If Not ProcessExists("FirstProgram.exe") Then
        Run("FirstProgram.exe")
    EndIf
    If @MIN = 28 Then
        RunWait ("File28.exe")
    EndIf
    If Not ProcessExists("EMAIL.exe") And TimerDiff($t) > 20000 Then
        Run("TIME.exe")
        $iSleep = TimerInit()
    EndIf
WEnd

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I tried to do a more elegant solution (elegant if you look at it from the outside. Inside is a different story)

'?do=embed' frameborder='0' data-embedContent>>

It works but note that it has some limitations.

Here's an example for your case:

#include 'RegisterLoop_v2.au3'


; Press Exit to exit the script
HotKeySet('{ESC}','Exit1')
Func Exit1()
    Exit
EndFunc


RegisterLoop('loop1')

RegisterLoop('loop2')

RegisterLoop('loop3')

Func loop1()
    If  Not ProcessExists("FirstProgram.exe") Then
        Run("FirstProgram.exe")
    EndIf
EndFunc



Func loop2()
    If @MIN = 28 Then
        RunWait ("File28.exe")
    EndIf
EndFunc


Func Loop3()
    If ProcessExists("EMAIL.exe") Then
         WaitWhile('Loop3',20000)
    Else
        Run("TIME.exe")
    EndIf
EndFunc




; Main loop just to keep the script running
While 1
    Sleep(10000)
WEnd

I do not recommend you use this solution because I do not use it myself

Edited by gil900

Share this post


Link to post
Share on other sites

I tried to do a more elegant solution (elegant if you look at it from the outside. Inside is a different story)

'?do=embed' frameborder='0' data-embedContent>>

 

It works but note that it has some limitations.

Here's an example for your case:

#include 'RegisterLoop_v2.au3'


; Press Exit to exit the script
HotKeySet('{ESC}','Exit1')
Func Exit1()
    Exit
EndFunc


RegisterLoop('loop1')

RegisterLoop('loop2')

RegisterLoop('loop3')

Func loop1()
    If  Not ProcessExists("FirstProgram.exe") Then
        Run("FirstProgram.exe")
    EndIf
EndFunc



Func loop2()
    If @MIN = 28 Then
        RunWait ("File28.exe")
    EndIf
EndFunc


Func Loop3()
    If ProcessExists("EMAIL.exe") Then
         WaitWhile('Loop3',20000)
    Else
        Run("TIME.exe")
    EndIf
EndFunc




; Main loop just to keep the script running
While 1
    Sleep(10000)
WEnd
I do not recommend you use this solution because I do not use it myself

I'm not sure about this one. Looks to me your processor time may be real high with it.

Share this post


Link to post
Share on other sites

 

Try this:

 

$iSleep = TimerInit()

While Sleep(100)

    If Not ProcessExists("FirstProgram.exe") Then

        Run("FirstProgram.exe")

    EndIf

    If @MIN = 28 Then

        RunWait ("File28.exe")

    EndIf

    If Not ProcessExists("EMAIL.exe") And TimerDiff($t) > 20000 Then

        Run("TIME.exe")

        $iSleep = TimerInit()

    EndIf

WEnd

 

thanks, your code working nice, but with some corrections for me  :thumbsup:

$iSleep = TimerInit()

While Sleep(100)
    If Not ProcessExists("FirstProgram.exe") Then
        Run("FIrstProgram.exe")
    EndIf
    If @MIN = 47 Then
        RunWait ("2ndProgram.exe")
        Sleep(20000)
    EndIf
    If Not ProcessExists("Program3.exe") And TimerDiff($iSleep) > 20000 Then
        Run("Program3.exe")
        $iSleep = TimerInit()
    EndIf
WEnd

Share this post


Link to post
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
Sign in to follow this  
Followers 0