myspacee Posted December 26, 2008 Share Posted December 26, 2008 hello to all, in these days i'm working on comparing images, all fine at this point, but now i've possibility to exapand my results. Lot of DOS programs return a value after finish its work RunWait(@ComSpec & " /c " & "date /T") return today date without prompting user anything else. is possibile to capture date in code post above ? thank you for info, m. Link to comment Share on other sites More sharing options...
Bert Posted December 26, 2008 Share Posted December 26, 2008 look at consolewrite The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 26, 2008 Share Posted December 26, 2008 look at consolewrite I don't think so.... StdoutRead() is what he wants ; Demonstrates StdoutRead() #include <Constants.au3> Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = StdoutRead($foo) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) Wend While 1 $line = StderrRead($foo) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) Wend MsgBox(0, "Debug", "Exiting...") 8) Link to comment Share on other sites More sharing options...
Valuater Posted December 26, 2008 Share Posted December 26, 2008 But, I would use the "Date" functions for the date or time 8) Link to comment Share on other sites More sharing options...
myspacee Posted December 26, 2008 Author Share Posted December 26, 2008 (edited) Perfect ! thank you, m. EDIT: speak too soon. for Imagemagick command i must run command from runwait() and so it doesn't works: (result ok but not console 'capture') $IM_compare_A_vs_B = runwait(@ComSpec & " /c " & @ScriptDir & "compare -fuzz 95% -metric PSNR A.tif B.tif diff.png") m. Edited December 26, 2008 by myspacee Link to comment Share on other sites More sharing options...
Baraoic Posted December 26, 2008 Share Posted December 26, 2008 (edited) looks like your missing the exe file name and a \ for example $IM_compare_A_vs_B = runwait(@ComSpec & " /c " & @ScriptDir & "\Imagemagick compare -fuzz 95% -metric PSNR A.tif B.tif diff.png") thats assuming the Imagemagick program is called Imagemagick and that it is in the same dir as the script. also not sure if it works with runwait i normally use something like $IM_compare_A_vs_B = run(@ComSpec & " /c " & @ScriptDir & "\Imagemagick compare -fuzz 95% -metric PSNR A.tif B.tif diff.png") While ProcessExists($IM_compare_A_vs_ Sleep(100) $Read = StdoutRead($IM_compare_A_vs_B, True) WEnd msgbox(0,'',$read) Edited December 26, 2008 by Onichan Link to comment Share on other sites More sharing options...
myspacee Posted December 26, 2008 Author Share Posted December 26, 2008 (edited) sorry oni, 'compare' is one imagemagick executables. Result of command is ok, can't capture STDOUT. runwait() is problem for me can't use $STDERR_CHILD + $STDOUT_CHILD as parameters... (i believe) m. Edited December 26, 2008 by myspacee Link to comment Share on other sites More sharing options...
Andreik Posted December 26, 2008 Share Posted December 26, 2008 Try this: #include <Process.au3> ;~ Example MsgBox(0,"",DOSResult("VER")) MsgBox(0,"",DOSResult("dir c:")) Func DOSResult($LINE) _RunDOS($LINE & " >" & @TempDir & "\DosResult.txt") $FILE = FileOpen(@TempDir & "\DosResult.txt",0) $RESULT = FileRead($FILE) FileClose($FILE) Return $RESULT EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
myspacee Posted December 26, 2008 Author Share Posted December 26, 2008 triky one, not tried yet, but sure works m. Link to comment Share on other sites More sharing options...
slideawayz Posted February 20, 2009 Share Posted February 20, 2009 (edited) Try this: #include <Process.au3> ;~ Example MsgBox(0,"",DOSResult("VER")) MsgBox(0,"",DOSResult("dir c:")) Func DOSResult($LINE) _RunDOS($LINE & " >" & @TempDir & "\DosResult.txt") $FILE = FileOpen(@TempDir & "\DosResult.txt",0) $RESULT = FileRead($FILE) FileClose($FILE) Return $RESULT EndFunc it doesn't work. here is my script #include <Process.au3> ;~ Example MsgBox(0,"",DOSResult("compare -metric PSNR c:/0.jpg c:/1.jpg c:/difference.png")) Func DOSResult($LINE) _RunDOS($LINE & " >" & @TempDir & "\DosResult.txt") $FILE = FileOpen(@TempDir & "\DosResult.txt",0) $RESULT = FileRead($FILE) FileClose($FILE) Return $RESULT EndFunc it popup nothing on msgbox. (and in the DosResult.txt too.) can someone help? thank you Edited February 20, 2009 by slideawayz Link to comment Share on other sites More sharing options...
myspacee Posted February 20, 2009 Author Share Posted February 20, 2009 forgot to post also solution: dos command 2> yourfile.txt ' 2> ' do the trick. m. Link to comment Share on other sites More sharing options...
slideawayz Posted February 21, 2009 Share Posted February 21, 2009 thank you myspaceebut I still no luck with this. when I run script, I gotand this command work fine in cmdhere is my script#include <Process.au3> ;~ Example MsgBox(0,"",DOSResult("compare -metric PSNR c:/0.jpg c:/1.jpg c:/difference.png")) Func DOSResult($LINE) _RunDOS($LINE & " 2>" & @TempDir & "\DosResult.txt") $FILE = FileOpen(@TempDir & "\DosResult.txt",0) $RESULT = FileRead($FILE) FileClose($FILE) Return $RESULT EndFuncany help will be greatly appreciated Link to comment Share on other sites More sharing options...
Authenticity Posted February 21, 2009 Share Posted February 21, 2009 #include <Process.au3> ;~ Example MsgBox(0,"",DOSResult("compare -metric PSNR c:/0.jpg c:/1.jpg c:/difference.png")) Func DOSResult($LINE) _RunDOS($LINE & " > " & @TempDir & "\DosResult.txt") ;==> Did you take into consideration the working path? $FILE = FileOpen(@TempDir & "\DosResult.txt",0) $RESULT = FileRead($FILE) FileClose($FILE) Return $RESULT EndFunc If compare should be in the working directory then $LINE probably is correct otherwise it should contain "Path with blanks\compare.exe" for example. Don't forget the double quotes to enclose the path in a valid form. Link to comment Share on other sites More sharing options...
slideawayz Posted February 21, 2009 Share Posted February 21, 2009 #include <Process.au3> ;~ Example MsgBox(0,"",DOSResult("compare -metric PSNR c:/0.jpg c:/1.jpg c:/difference.png")) Func DOSResult($LINE) _RunDOS($LINE & " > " & @TempDir & "\DosResult.txt") ;==> Did you take into consideration the working path? $FILE = FileOpen(@TempDir & "\DosResult.txt",0) $RESULT = FileRead($FILE) FileClose($FILE) Return $RESULT EndFunc If compare should be in the working directory then $LINE probably is correct otherwise it should contain "Path with blanks\compare.exe" for example. Don't forget the double quotes to enclose the path in a valid form. Thank You Authenticity now it working. thank you very much Link to comment Share on other sites More sharing options...
slideawayz Posted February 22, 2009 Share Posted February 22, 2009 ok I got this to work but when my script directory have space in the path name, script will not wotk.my script#include <Process.au3>;~ ExampleMsgBox(0,"",DOSResult(@ScriptDir & "\comparer\compare.exe -fuzz 5% c:/0.jpg c:/1.jpg c:/difference.png"))Func DOSResult($LINE)_RunDOS($LINE & " 2> " & @TempDir & "\DosResult.txt") ;==> Did you take into consideration the working path?$FILE = FileOpen(@TempDir & "\DosResult.txt",0)$RESULT = FileRead($FILE)FileClose($FILE)Return $RESULTEndFunc Link to comment Share on other sites More sharing options...
Authenticity Posted February 22, 2009 Share Posted February 22, 2009 Then always prepend and append a double quote to the path like: Dim $Path = '"' & @ScriptDir & '\Something\some.thing"' Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now