Jump to content

RunWait calling another script, but can't see ConsoleWrite in the subscript


Recommended Posts

Hello, 

I'm trying to call a Subscript using a Mainscript. 

This is my Mainscript: 

;#pragma("AutoItExecuteAllowed", True)

ConsoleWrite("Start Loop" & @CRLF)
For $i = 1 To 3
    ConsoleWrite("Looping..." & @CRLF)
    Sleep(1000)
    RunWait(@AutoItExe & " /AutoIt3ExecuteScript Subscript.au3")
Next
ConsoleWrite("Loop Finished" & @CRLF)

This is my Subscript: 

_write15()
;ConsoleWrite("Hello" & @CRLF)
MsgBox(0, "", "Hello")


Func _write15()
    ;ConsoleWrite("15" & @CRLF)
    MsgBox(0, "", "15")
EndFunc

 

If I run exactly like above, it's working correctly. I can see the message boxes every time; first "Hello" and then "15". No problem at all. This is my output: 

+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
Start Loop
Looping...
Looping...
Looping...
+>18:07:37 AutoIt3.exe ended.rc:0
+>18:07:37 AutoIt3Wrapper Finished.

 

BUT: If I comment MsgBox and open the ConsoleWrite in the Subscript, I cannot see "Hello" and "15" in the output window: 

_write15()
ConsoleWrite("Hello" & @CRLF)
;MsgBox(0, "", "Hello")


Func _write15()
    ConsoleWrite("15" & @CRLF)
    ;MsgBox(0, "", "15")
EndFunc

The output is the same as above: 

+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
Start Loop
Looping...
Looping...
Looping...
Loop Finished
+>18:10:45 AutoIt3.exe ended.rc:0
+>18:10:45 AutoIt3Wrapper Finished.

 

Is there a way that I can see "Hello" and "15" as ConsoleWrite in the output window? What I'm expecting is something like this: 

Start Loop
Looping...
15
Hello
Looping...
15
Hello
Looping...
15
Hello
Loop Finished

 

Side note-1: I don't want to use #include <Subscript.au3> because I want to change and edit the content of Subscript any time I want. If I include Subscript.au3, even if I change the content while the Mainscript is running, I cannot see the changes until I start Mainscript again. 

Side note-2: I found #pragma("AutoItExecuteAllowed", True) in some other topics, but I couldn't make use of it, so I commented it. 

 

Edited by taylansan

TY.

Link to post
Share on other sites
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Iraj
      Hi Team,
      Greetings!
       
      One silly doubt, I need to pass one parameter using RunWait to write an output to a file using Cmd Line, but the below isn't writing to the file specified. Kindly assist.
      $pass = $CmdLine[1] $CMD = "C:\Progra~1\bin\Encrypt.exe" &$pass& " > C:\temp\pwd.txt" #write the parameter $pass in C:\temp\pwd.txt RunWait(@ComSpec & " /c " & $CMD,"",@SW_HIDE) Thank you!!
    • By user4157124
      ConsoleWrite('>Message here.' & @CRLF) outputs colored text (per + > - ! characters).
      ConsoleWrite('warning' & @TAB & '38' & @TAB & 'more text ...' & @CRLF) enables jump to line 38 on doubleclick.

      Using "jump to line" format, only red and pink text coloring seems possible (simply prefixing color directives to output-text disables jump to line functionality). Is it possible to combine the two (define custom color while keeping "jump to line" functionality)?
    • By lonardd
      Hi
      I have to run an executable with a parameter preceded by a /, like this:
      c:\myfolder\Tools\AutomaticRun\myexe.EXE /filename=c:\myfolder\Tools\AutomaticRun\myTemplate.xml")
      I tried both this:
      $iReturn = RunWait ("c:\myfolder\Tools\AutomaticRun\myexe.EXE"," /filename=c:\myfolder\Tools\AutomaticRun\myTemplate.xml")
      and using COMSPEC as per some posted suggestions on this forum:
      Run(@comspec & ' /c "c:\myfolder\Tools\AutomaticRun\myexe.EXE" /filename=c:\myfolder\Tools\AutomaticRun\myTemplate.xml')
      They both seem to fail.
      Can you please tell me what I'm doing wrong?
      Thanks
      Dave
       
    • By vyperhand
      I'm struggling to launch a VBS file via autoit using RunWait.  Due to the nature of the deployment tool I am using for said script, I only know that the .vbs files will be in the same directory as my AutoIt-generated .exe, but not what that path will be.  The path will look something like this:
      c:\programdata\vendor\lots\of\folders\randomnumber
      This is generated during deployment and I have no way of predicting the path - therefore, I am not sure how to call back to "same directory" in order to successfully launch the .vbs.
      This line is as close as I have gotten - this fires off the cmd window, but it closes immediately with out information, and the .vbs is not launched.
      RunWait (@ComSpec & " /c" & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel') I thought /c might be the problem, but leaving out the /c element causes me not to even see the momentary CMD window flash by.  Any help will be greatly appreciated, and thanks in advance.
    • By lewisg
      Suddenly a RunWait command has stop working after 2 years of no errors, issues, or problems. The code uses RunWait to start Plink.exe, a command-line remote connection tool similar to UNIX ssh. I'm using it to ssh to a linux (Centos) machine, run a Perl script, and redirect the output to a file on a PC running the AutoIt script.  
       
      $FilePath = "C:\AutoIT\LED" $FilePathPlus = $FilePath & "\plink.exe" $Code1 = RunWait(@ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt ", @SW_SHOW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " = ' & @ComSpec & " /c " & $FilePathPlus & " -ssh -l root -pw ?????? 10.170.4.163 /usr/local/nagios/etc/led.pl > C:\AutoIT\LED\led.txt " & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console The ConsoleWrite output when cut-n-pasted into a DOS box produces the expected file so I know it works. I've also tried many variations of the function moving, adding, and changing the " and ' (quote) marks. Also tried it without the @ComSpec macro and other related functions...e.g.  ShellExecuteWait , etc.
      The PC is a Windows 10 64bit and AutoIT is version 3.3.14.2.
      Searching here and Google has not yielded any clues that helped. 
×
×
  • Create New...