Jump to content

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


nbala75
 Share

Recommended Posts

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

Link to comment
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

Link to comment
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.

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
Link to comment
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

Link to comment
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?? :)

Link to comment
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

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