MadDogDean Posted February 7, 2011 Share Posted February 7, 2011 Hi all, I'm relatively new, but wondering is there a way to step through a called script in the Console? I can do this with the main script I'm working on, but this script calls another AutoIt script, sending through certain parameters. I am having trouble with the second script and wondering how can I watch "console style" what actions are breaking in the second "called" script? Hope this makes sense. Thanks, Dean Link to comment Share on other sites More sharing options...
bo8ster Posted February 8, 2011 Share Posted February 8, 2011 You can use ConsoleWrite to print vars to the console You can also use #AutoIt3Wrapper_run_debug_mode=Y to see the lines that are executed. If you need something else, just ask. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
MadDogDean Posted February 8, 2011 Author Share Posted February 8, 2011 (edited) Hey, Wow, that #AutoIt3Wrapper_run_debug_mode=Y is brilliant, thanks! Now it gets tricky... This code is what I posted in another thread, but it helps to explain my question. expandcollapse popupif $Cmdline[0] <>2 Then Exit(10) else $path=$Cmdline[1] $title=$Cmdline[2] EndIf Run($path & "\program.exe",$path,@SW_MAXIMIZE) if @error Then Exit EndIf WinWait($title) $nRunPid=WinGetProcess($title) $nRunHandle = WinGetHandle($title, "") $sRunHandle = String($nRunHandle) $bIsLive=False MaxWin() func MaxWin() $state=WinGetState(HWnd($sRunHandle)) while not BitAND($state, 32) sleep(100) WEnd if BitAND($state, 32) = true Then $bIsLive=True EndIf EndFunc if $bIsLive = True Then $Args='"'&$path&'"' &' ' &'"'&$nRunPid&'"' ;the mess with the $Args above is because the path may contain spaces ConsoleWrite($nRunPid & @CRLF) Run("D:\\2.exe " & $Args, @ScriptDir, @SW_HIDE) EndIf Exit The Script for "2.exe" looks like this: if $Cmdline[0] <>2 Then Exit(10) else $path=$Cmdline[1] $nRunPid=$Cmdline[2] EndIf ProcessWaitClose($nRunPid) FileDelete($path&"\*.*") Exit I've been messing with it, and if I change the passed-through parameters and try to run it using WinWaitClose($title) instead of ProcessWaitClose($nRunPid) it works as expected, but in my instance I can't use the Windows title as there may be duplicates (in the end, I will get the PID from the first "Run(..program.exe.." - this was changed temporarily to find the problem). This long-winded explanation is to find out how I see what happens in 2.exe when it is called (if I run it in the console and manually pass the arguments it works fine, just not when it is Automated). #AutoIt3Wrapper_run_debug_mode=Y works great for the first script, but I am blind to what happens in the second (2.exe). I tried adding "#AutoIt3Wrapper_run_debug_mode=Y" into 2.exe but it doesn't do anything (probably because it is compiled?) Thanks for your efforts. Cheers, Dean Edited February 8, 2011 by MadDogDean Link to comment Share on other sites More sharing options...
bo8ster Posted February 8, 2011 Share Posted February 8, 2011 Try this. This will enable you to see if the args are received correctly. Script one expandcollapse popup#AutoIt3Wrapper_Change2CUI=Y Opt("MustDeclareVars", 1) Local $nRunHandle, $nRunPid, $bIsLive = 0 Local $title, $path, $sRunHandle, $Args = "" If $CmdLine[0] <> 2 Then Exit (10) Else $path = $CmdLine[1] $title = $CmdLine[2] EndIf Run($path & "\program.exe", $path, @SW_MAXIMIZE) If @error Then Exit EndIf Local $title, $nRunHandle, $nRunPid, $bIsLive = 0 WinWait($title) $nRunPid = WinGetProcess($title) $nRunHandle = WinGetHandle($title, "") $sRunHandle = String($nRunHandle) $bIsLive = False MaxWin() Func MaxWin() Local $state = WinGetState(HWnd($sRunHandle)) While Not BitAND($state, 32) Sleep(100) WEnd If BitAND($state, 32) = True Then $bIsLive = True EndIf EndFunc ;==>MaxWin If $bIsLive = True Then $Args = '"' & $path & '"' & ' ' & '"' & $nRunPid & '"' ;the mess with the $Args above is because the path may contain spaces ConsoleWrite($nRunPid & @CRLF) ConsoleWrite("Command is: " & "D:\\2.exe " & $Args & @CRLF) Run("D:\\2.exe " & $Args, @ScriptDir, @SW_HIDE) EndIf Exit (0) Script two #AutoIt3Wrapper_Change2CUI=Y Opt("MustDeclareVars", 1) Local $nRunPid, $path If $Cmdline[0] <> 2 Then Exit (10) Else $path = $Cmdline[1] $nRunPid = $Cmdline[2] EndIf ConsoleWrite("Args recieved are : " & $Cmdline[1] & " and " & $Cmdline[2] & @CRLF) ProcessWaitClose($nRunPid) FileDelete($path & "\*.*") Exit (0) Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
rover Posted February 8, 2011 Share Posted February 8, 2011 You can write to the SciTE console from a child script process. Sending the SCI_APPENDTEXT message to the SciTE console works, but the sent console writes are not synchronized with main script console writes. A script rapidly writing to the SciTE console immediately after an external process rapidly writes to the SciTE console will not appear right after the external console write, but sometimes after several more writes from the external process, this is fine if you are not monitoring synchronized event order between processes. Another easier way of monitoring a child process script, compiled or not Add dbg($msg) lines to your script Run DebugView Whenever a child script process is run, its output can be monitored in DebugView ;DebugView ;http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx Func dbg($msg) DllCall("kernel32.dll", "none", "OutputDebugStringW", "wstr", $msg) ;DllCall("kernel32.dll", "none", "OutputDebugStringA", "str", $msg) EndFunc I see fascists... Link to comment Share on other sites More sharing options...
MadDogDean Posted February 9, 2011 Author Share Posted February 9, 2011 @bo8ster @rover Thanks to you both for the suggestions. the "#AutoIt3Wrapper_Change2CUI=Y" worked great so far as I don't need to watch for synchronised writes, I just want to see what fails. I'll add using "dbg($msg)" to my little bag of goodies. Cheers, Dean 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