Sign in to follow this  
Followers 0
gamingmouse

Console Window Closing

8 posts in this topic

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)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Okay, makes sense.

What I really want to do is use my autoit app from the command line. That is, I want my ConsoleWrite to be visible if I run my autoit application from the CL. Right now, they are not. They only show up if I run the program inside autoit editor.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Hmm... Putting that line at the top of my script did not fix it.

Also, if I go to Tools -> Compile, nothing pops up where I could add any options. It just compiles immediately.

I'm using Version 1.77. Any ideas?

Thanks,

J

Share this post


Link to post
Share on other sites

Are you using the full version of Scite?

http://www.autoitscript.com/autoit3/scite/downloads.shtml

Share this post


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
Sign in to follow this  
Followers 0