Jump to content
Sign in to follow this  

AutoIt Console Application

Recommended Posts


Local $sAnswer = InputBox(" ", "Write your name:", "", "", 404, 136, Default, Default, 120)
MsgBox(0,"","Nice to meet you "&$sAnswer)

How convert this code into a console?
Print the question and wait for answers from the user in the console window that is not INPUT BOX?


ConsoleWrite("Write your name:" &@CRLF)
ConsoleWrite("Nice to meet you: " & $sAnswer &@CRLF)



Share this post

Link to post
Share on other sites

Freely adapted from the helpfile of ConsoleRead. Notice that it should be ran as a compiled exe, and be compiled as a console application (otherwise ConsoleWrite will not write to the dos screen).

Use the SciTE compile dialog (Ctrl+F7, check option Create CUI instead of GUI EXE ), or the /console switch to if you command the compiler from the commandline.

Run by piping the standard input of the shell session (descriptor CON) to the command, by literally doing this: type CON | myapplication.exe (of course changing the application name to your own).

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <MsgBoxConstants.au3>


Func Example()
    If Not @Compiled Then
        MsgBox($MB_SYSTEMMODAL, "", "This script must be compiled in order to run the example.")

    ConsoleWrite("Enter your name. Enter ^Z on a new line when you're done (equals EOF)." & @CRLF & "Name: ")

    Local $sOutput

    While True
        $sOutput &= ConsoleRead()
        If @error Then ExitLoop

    ; DOS only recognizes the EOF command when it's at the start of a line, meaning the last character is always a newline
    While StringRegExp(StringRight($sOutput, 1), "[\r\n]")
        $sOutput = StringTrimRight($sOutput, 1)

    ConsoleWrite("Name received: '" & $sOutput & "'")
EndFunc   ;==>Example


  • Like 1

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post

Link to post
Share on other sites

I was looking around for color output in cmd and then i saw an example that fit your need in color xD
the first example on that topic

  • Like 1

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