Sign in to follow this  
Followers 0
nbala75

Pause a script and un-pause it after running another script

10 posts in this topic

I have couple of scripts running say A and B

Now i want to run a new script named C. While running script C, i want to pause A and B. While after completing script C, scripts A and B shud resume.

How do i do it?

I cannot use ShellexecuteWAIT since Script C is not run from Script A or B. Script C is run independently.

I Cannot use processwait etc from Script C, bcos, Script A and B are not .exe files, they are just script files with .au3

Plz guide me ASAP

Share this post


Link to post
Share on other sites



Create a lookup function which checks every x seconds whether the relevant process exists.

If it exists then, loop (sleep) otherwise it goes on.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I think it would be smarter to just turn them into .exe's? Or are you still working on them?

Share this post


Link to post
Share on other sites

I think it would be smarter to just turn them into .exe's? Or are you still working on them?

yup....still working on them...may do so in near term as well

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Create a lookup function which checks every x seconds whether the relevant process exists.

If it exists then, loop (sleep) otherwise it goes on.

which process to check and where to write this loop?

btw...all are .au3 scripts and how do u propose to check those whether running or not?

And also...i tried this which never worked :idiot:

I have hotkeyset("^P") in Script A to Pause the script

If i want to run Script C, while pausing Script A, then at the beginning of Script C's code, i used Send keys ("^P"), thinking that this wud indeed pause Script A....it never worked...

Any other ideas?? :);)

Edited by nbala75

Share this post


Link to post
Share on other sites

I have couple of scripts running say A and B

Now i want to run a new script named C. While running script C, i want to pause A and B. While after completing script C, scripts A and B shud resume.

How do i do it?

Try and put all 3 into one script?

Share this post


Link to post
Share on other sites

Global $pid = 0, $pid1 = 0, $scriptPath = "loopTest.au3", $scriptPath1 = "loopTest1.au3"

$pid = _runAU3($scriptPath)
$pid1 = _runAU3($scriptPath1)
ConsoleWrite('! The PID of ' & $scriptPath & ' is : ' & $pid & @CRLF)
ConsoleWrite('! The PID of ' & $scriptPath1 & ' is : ' & $pid1 & @CRLF)

ConsoleWrite(_checkAU3Run($pid) & "=== 0 = not running, 1 = running" & @CRLF)
ConsoleWrite(_checkAU3Run($pid1) & "=== 0 = not running, 1 = running" & @CRLF)

Func _checkAU3Run($pid)
    If ProcessExists($pid) Then Return 1
    Return 0
EndFunc   ;==>_checkAU3Run

Func _runAU3($pathToAu3)
    Local $pid = Run('"' & @AutoItExe & '" ' & '/AutoIt3ExecuteScript "' & $pathToAu3 & '"', '', @SW_SHOW)
    Return $pid
EndFunc   ;==>_runAU3


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create a function/s from the second script and in the first script just call that function.

You can even #Include them .

Share this post


Link to post
Share on other sites

Global $pid = 0, $pid1 = 0, $scriptPath = "loopTest.au3", $scriptPath1 = "loopTest1.au3"

$pid = _runAU3($scriptPath)
$pid1 = _runAU3($scriptPath1)
ConsoleWrite('! The PID of ' & $scriptPath & ' is : ' & $pid & @CRLF)
ConsoleWrite('! The PID of ' & $scriptPath1 & ' is : ' & $pid1 & @CRLF)

ConsoleWrite(_checkAU3Run($pid) & "=== 0 = not running, 1 = running" & @CRLF)
ConsoleWrite(_checkAU3Run($pid1) & "=== 0 = not running, 1 = running" & @CRLF)

Func _checkAU3Run($pid)
    If ProcessExists($pid) Then Return 1
    Return 0
EndFunc   ;==>_checkAU3Run

Func _runAU3($pathToAu3)
    Local $pid = Run('"' & @AutoItExe & '" ' & '/AutoIt3ExecuteScript "' & $pathToAu3 & '"', '', @SW_SHOW)
    Return $pid
EndFunc   ;==>_runAU3

Does this run both simultaneously?? :)

Share this post


Link to post
Share on other sites

Yes, I think so! Just change the loopTest.au3 to any of your scripts.

Or create the to scripts loopTest.au3 and loopTest1.au3 with this content.

While 1
    Sleep(1000)
WEnd

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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