;Script: Console ;Function: To allow people to easily make console based programs. ;Requirements: AutoIt V3 Unstable Gui version ;Author: Guido Arbia ;This is exactly the same as Console only it does no longer require the notepad. It now operates in its own window. ;Commands: ;LoadConsole("Console Title") ;CloseConsole() ;$Answer = Input("Question") ;ActivateConsole() ;ConsoleOutputLine("Line") ;ConsoleOutput("Line") ;v4 bug fixes ;Caps problem fixed. ;Other simple gunk. ;DO NOT EDIT THIS FILE. IT IS MYNE MYNE MYNE MYNE MYNE. Global $Console_Title Global $Console_Answer Global $Console_Answered Global $Console_Question Global $Console_DisableAfterEnter Global $Console_WinActive Global $Console_PromptLine $Console_WinActive = 1 GuiCreate("Console",640,480) GuiCtrlCreateEdit("",0,0,640,480) Func ActivateConsole() WinActivate("Console - "& $Console_Title) EndFunc Func EnableEnter() HotKeySet("{Enter}") EndFunc Func DisableEnter() HotKeySet("{Enter}","ConsoleNothing") EndFunc Func IsConsoleActive() Return WinActive("Console - "&$Console_Title) EndFunc Func LoadConsole($ConsoleTitle) GuiSetState() WinSetTitle("","","Console - " & $ConsoleTitle) $Console_Title = $ConsoleTitle EndFunc Func SetConsoleTitle($Console_Title) WinSetTitle("","","Console - " & $ConsoleTitle) $Console_Title = $ConsoleTitle EndFunc Func GetConsoleTitle() return $Console_Title EndFunc Func CloseConsole() ActivateConsole() WinKill("") EndFunc Func Input($Question) ActivateConsole() $Console_Question = $Question ConsoleOutput($Question) $CLine = ControlCommand("Console - "&$Console_Title,"","Edit1","GetCurrentLine","") $Console_PromptLine = $CLine Call("WaitAnswer") return $Console_Answer EndFunc Func Answer() HotKeySet("{ENTER}") GetAnswer() Send("{ENTER}") $Console_Answered = 1 EndFunc ;Here is the multiline support: Func GetAnswer() $CLine = ControlCommand("Console - "&$Console_Title,"","Edit1","GetCurrentLine","") $Console_Answer = ControlCommand("Console - "&$Console_Title,"","Edit1","GetLine",$Console_PromptLine) $Console_Answer = StringRight($Console_Answer, StringLen($Console_Answer) - StringLen($Console_Question)) If $CLine > $Console_PromptLine Then For $ILine = $Console_PromptLine +1 to $CLine $Console_Answer = $Console_Answer & ControlCommand("Console - "&$Console_Title,"","Edit1","GetLine",$ILine) Next EndIf EndFunc Func ConsoleNothing() EndFunc Func ConsoleOutput($Text) ClipPut($Text) Send("{CTRLDOWN}V{CTRLUP}") EndFunc Func ConsoleOutputLine($Text) ClipPut($Text) Send("{CTRLDOWN}V{CTRLUP}{ENTER}") EndFunc Func WaitAnswer() $CLine = ControlCommand("Console - "&$Console_Title,"","Edit1","GetCurrentLine","") Console_UserKeysOff() While $Console_Answered = 0 If WinExists("Notepad","Do you want to") Then Send("N") EndIf If Not WinActive("Console - "& $Console_Title) Then If $Console_WinActive = 1 Then $Console_WinActive = 0 Console_UserKeysOn() EndIf Else If $Console_WinActive = 0 Then $Console_WinActive = 1 Send("{CTRLDOWN}{END}{CTRLUP}") Console_UserKeysOff() EndIf EndIf If Not WinExists("Console - "& $Console_Title) Then Console_UserKeysOn() MsgBox(0,"Console", "The console window was closed right in the middle of a console operation. The program using the console was terminated to prevent errors from occuring.") Exit EndIf If StringLen(ControlCommand("Console - "&$Console_Title,"","Edit1","GetLine",$CLine)) = StringLen($Console_Question) Then HotKeySet("{BS}","ConsoleNothing") HotKeySet("{CTRLDOWN}", "ConsoleNothing") Else HotKeySet("{BS}") HotKeySet("{CTRLDOWN}") EndIf If $Console_WinActive = 1 Then EndIf Wend Console_UserKeysOn() $Console_Answered = 0 EndFunc Func ClearConsole() Send("{CTRLDOWN}{SHIFTDOWN}{HOME}{CTRLUP}{SHIFTUP}{DELETE}") ;Clear the notepad. EndFunc Func Console_UserKeysOn() HotKeySet("{DOWN}") HotKeySet("{UP}") HotKeySet("{LEFT}") HotKeySet("{HOME}") HotKeySet("{CTRLDOWN}") HotKeySet("{ENTER}") EndFunc Func Console_UserKeysOff() HotKeySet("{DOWN}", "ConsoleNothing") HotKeySet("{UP}", "ConsoleNothing") HotKeySet("{LEFT}", "ConsoleNothing") HotKeySet("{HOME}", "ConsoleNothing") HotKeySet("{CTRLDOWN}", "ConsoleNothing") HotKeySet("{ENTER}","Answer") HotKeySet("{ALT}","ConsoleMsg1") EndFunc Func ConsoleMsg1() msgbox(0,,"Console","What are you pressing the alt key for? This is a console not a regular document.") EndFunc