Jump to content

Console Window Closing


 Share

Recommended Posts

As is, the script below will open a console window for a split-second, and then close it.

If I change which line is commented out, the console window opens and stays open, as I want.

But I need to be able to write to StdIn, so I need to use the line with the 7 option. Why is it closing when I use that option?

Thanks,

Jonah

#include <StaticConstants.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

$pid = Run(@ComSpec & ' /k', @WorkingDir,@SW_MAXIMIZE,7)
;$pid = Run(@ComSpec & ' /k', @WorkingDir,@SW_MAXIMIZE)
Link to comment
Share on other sites

The Window opens and stays open either way on my machine

A flag of 7 means that Stdin and Stdout are going to be redirected to the script, so there's no sense even having the window visible. Observe this script. Output from the command prompt will be displayed in the message box. In the input box, enter the desired commands: "ipconfig", "dir *.exe", etc.

$pid = Run(@ComSpec& ' /k', @WorkingDir, @SW_MAXIMIZE, 7)
;$pid = Run(@ComSpec & ' /k', @WorkingDir,@SW_MAXIMIZE)
Dim $data
While 1
    Sleep(2000)
    
    $data = StdoutRead($pid)
        
    MsgBox(0, "", $data)
    $input = InputBox("Command", "Command")
    StdinWrite($pid, $input & @CRLF)
WEnd
Link to comment
Share on other sites

This is how far I got the last time I tried that:

http://www.autoitscript.com/forum/index.php?showtopic=72563

Basically you can't make it an interactive console application

Though Stdin and Stdout can be hooked up directly to other scripts.

EDIT:

I see you're talking about ConsoleWrite. That should work if your compile options are set to console.

Edited by TurionAltec
Link to comment
Share on other sites

Yes, the compiler options worked!

Now how can I make the default compiler shortcut from within the editor use that option? (I did it using the converter tool)

Thanks!

Put this line at the top of your script:

#AutoIt3Wrapper_Change2CUI=y

I accessed that by going Tools->compile

Checking the "Create CUI"

Then Save only, and it added that directive to the script.

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