I just wrote (a very simple) AutoIt v3 script that "communicates" with one of my XYplorer scripts via the clipboard.
What's the reason to do this?
I haven't found a reasonable way to execute a 'run <application>' script command that waits until it's finished before it continues with the next instruction WITHOUT blocking the XYplorer's GUI (although it should run in the background).
Here is a link for a compiled version (.exe) of the script so that you don't need to install AutoIt yourself (or you can use the portable version including SciTE to do it manually: http://www.autoitscript.com/forum/topic ... __portable).
http://db.tt/sah2EybV
What are the scripts doing:
The XYplorer's script starts the CheckProcess.exe file (the compiled .au3 script), executes the "run <application" command and then copies the text (e.g.) "WinRAR.exe=started" to the clipboard. After that it will poll the clipboard every 250 ms to see if it holds the string "WinRAR.exe=finished". If that's the case it continues with the next instruction.
The AutoIt script get's the process name as it's first argument, checks the clipboard for "WinRAR.exe=started" (250 ms interval) and when found it waits for the process's end to write "WinRAR.exe=finished" back to the clipboard.
I didn't like the way to use a temp file for this kind of task because of the constant disk activity but if you use a clipboard manager and don't like the entries that are created you should modify both scripts to use a file instead.
I haven't found an issue so far but if you'd like to suggest a different or better method, don't hesitate to do so
In my WinRAR script I'll use it like this:
Code: Select all
global $ProcessName;
$CheckProcess = "<xypath>\.Tools\CheckProcess\CheckProcess.exe";
// Start the process watcher (external tool)
$ProcessName = "WinRAR.exe";
run """$CheckProcess"" ""$ProcessName""";
// Actually extract all archive files (-kb = keep broken files | -o+ = overwrite existing files)
run """$WinRARCmd"" x -kb -o+ ""$SourceFileWildcardName"" ""$FilePath\$ShortedFileName\""", , 0;
// Inform the process watcher tool
copytext "$ProcessName=started";
// Wait until WinRAR has finished it's task(s)
sub "_CheckProcess";
// Wait until a process has finished
"_CheckProcess"
global $ProcessName;
$WaitForProcess = "-1";
while($WaitForProcess == -1){
$WaitForProcess = strpos("<clipboard>", "$ProcessName=finished");
wait 250;
}
Code: Select all
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Res_Icon_Add=D:\Tools\.AutoIt\App\Icons\au3.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#comments-start
The script expects a process name (with or without quotation marks) as it's only parameter.
#comments-end
Opt("ExpandVarStrings", 1) ; Expand variables in strings
If $CmdLine[0] = 0 Then
$ProcessName = ""
Exit
Else
$ProcessName = $CmdLine[1]
EndIf
$WaitForProcess = 0;
While $WaitForProcess = 0
Sleep(250)
$ClipBoard = ClipGet()
$WaitForProcess = StringInStr("$ClipBoard$", "$ProcessName$=started", 2)
WEnd
ProcessWaitClose("$ProcessName$")
ClipPut("$ProcessName$=finished")