rover Posted March 28, 2009 Share Posted March 28, 2009 (edited) _WinAPI_ClearConsoleClear console screen buffer, six options to set cursor and clear or overwrite text_WinAPI_CursorShowConsoleShow or hide cursor and set cursor sizeNOTE: for scripts compiled as console apps with wrapper directive: #AutoIt3Wrapper_Change2CUI=ysome console related links:Overwriting StdOut in CUI compiled apphttp://www.autoitscript.com/forum/index.php?showtopic=66486set text colour attributeshttp://www.autoitscript.com/forum/index.ph...st&p=493255CMD.au3http://www.autoit.de/index.php?page=Thread...44881#post44881How To Performing [sic] Clear Screen (CLS) in a Console Applicationhttp://support.microsoft.com/kb/99261 Clearing the Screen (Windows)http://msdn.microsoft.com/en-us/library/ms682022.aspxScreen_Scrape.au3http://www.autoitscript.com/forum/index.ph...st&p=527810Edit 1 second example added - DOS character set frame around multiple data displays and mid line progress barEdit 2 corrected error in parameter range check on X Y coordinates - Thanks AuthenticityExample 1: Console line editing and data display updating on a row[autoit]#Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_Change2CUI=y#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****If Not @Compiled Then Exit MsgBox(262144 + 16, "_WinAPI_ClearConsole() Test", "Script must be compiled as a console app to run")Opt('MustDeclareVars', 1);clear screen - clears prompt if run from command lineLocal $hStdOut = _WinAPI_ClearConsole();save previous cursor, hide cursorLocal $iPrevSize = _WinAPI_CursorShowConsole($hStdOut, False)#Region - Console line editing example;//////////////////////////////////////////////////////////////////////////////////////;Example demonstrating console line editing;//////////////////////////////////////////////////////////////////////////////////////Local $aArray = StringSplit("4D7900204B61726D61002072756E00206F76657200206D790020446F676D61", "00", 1)Local $iCnt; sequentially append text to end of row 0 ($iCnt is character column position on row)For $i = 1 To $aArray[0] ConsoleWrite(BinaryToString("0x" & $aArray[$i])) Sleep(750) $iCnt += (StringLen($aArray[$i]) / 2) _WinAPI_ClearConsole(-1, $iCnt, 0)NextConsoleWrite(@CRLF);add a block of rowsFor $i = 1 To 6 ConsoleWrite("Jackdaws love my big sphinx of quartz" & @CRLF)NextSleep(1000); set cursor size to a block_WinAPI_CursorShowConsole($hStdOut, True, 100); clear then write single rows with new textFor $i = 1 To 3 _WinAPI_ClearConsole(-1, Default, $i) Sleep(1000) ConsoleWrite("New row " & $i)NextSleep(2000)_WinAPI_ClearConsole(-1, -2, -1) ; clear a block of 2 rows starting on row 1ConsoleWrite("correcting 'Typo' in row 0")Sleep(2000)_WinAPI_ClearConsole(-1, -10, 0) ; change letter in first row of textConsoleWrite("a")Sleep(2000)_WinAPI_ClearConsole(-1, Default, 1) ; clear row 1ConsoleWrite("Done")Sleep(1000)_WinAPI_ClearConsole(-1, 0, 0) ; set cursor on character column 0 and row 0Sleep(1000)_WinAPI_ClearConsole(-1, 0, Default) ; set cursor on character column 0 and bottom rowSleep(1000)_WinAPI_ClearConsole(-1, Default, -1) ; clear all rows starting at second rowSleep(1000)_WinAPI_ClearConsole() ; clear screen (set cursor on character column 0 and row 0);//////////////////////////////////////////////////////////////////////////////////////#EndRegion - Console line editing example#Region - Console label and data updating on a row;//////////////////////////////////////////////////////////////////////////////////////;Example demonstrating label and data updating on a row;//////////////////////////////////////////////////////////////////////////////////////;Overwriting StdOut in CUI compiled app, for use with progress indicator;http://www.autoitscript.com/forum/index.php?showtopic=66486;hide cursor_WinAPI_CursorShowConsole($hStdOut, False)Local $progress, $buffer, $ClearProgressConsoleWrite("Milliseconds: " & @CRLF)ConsoleWrite("Seconds : " & @CRLF)ConsoleWrite("Progress" & @CRLF)For $i = 0 To 500 Sleep(10) _WinAPI_ClearConsole(-1, 14, 0) ConsoleWrite(@MSEC) _WinAPI_ClearConsole(-1, 14, 1) ConsoleWrite(@SEC) If @SEC <> $buffer Then _WinAPI_ClearConsole(-1, 8, 2) $buffer = @SEC $progress &= "." ConsoleWrite($progress) $ClearProgress += 1 If $ClearProgress = 25 Then $ClearProgress = 0 $progress = "" EndIf EndIfNext;//////////////////////////////////////////////////////////////////////////////////////#EndRegion - Console label and data updating on a row;restore and show cursor, clear console_WinAPI_CursorShowConsole($hStdOut, True, $iPrevSize)_WinAPI_ClearConsole()Sleep(1000)Exit; #FUNCTION# =======================================================; Name...........: _WinAPI_ClearConsole; Description ...: Clears console screen buffer /w six options to clear rows & characters & set cursor position; Syntax.........: _WinAPI_ClearConsole($hConsole = -1, $iX = Default, $iY = Default); Parameters ....: $hConsole - (Optional) Handle to standard output device; $iX - (Optional) zero based character column position of cursor; Default or 0 to screen buffer max width (negative values for some modes); $iY - (Optional) zero based row position of cursor; Default or 0 to screen buffer max height (negative values for some modes);;No params ; clear screen (-1, Default, Default);(-1, Default, 0) ; clear single row: $iY = row number (0 is row 1);(-1, -2, -3) ; clear block of rows: -$iX = number of rows, -$iY = starting row (minimum $iX = -1, $iY = -1);(-1, Default, -1) ; clear all rows from start row: -$iY = starting row (minimum $iY = -1);(-1, 20, 2) ; clear characters to end of row: $iX = start character column, $iY = row number;(-1, -20, 2) ; set cursor at coordinates: -$iX = start character column, $iY = row number (minimum $iX = -1);(-1, 0, Default) ; set cursor on bottom row of console window: $iX = start character column; Return values .: Success - return handle to standard output device (does not have to be closed); Failure - return 0, set error and extended; Author ........: rover; Modified.......:; Remarks .......:; Related .......:;; Link ..........; @@MsdnLink@@ FillConsoleOutputCharacter; Example .......; Yes; ==================================================================Func _WinAPI_ClearConsole($hConsole = -1, $iX = Default, $iY = Default) Local $dwCoord, $fFlag = False Local $bChar = 0x20, $iErr ; fill character: 0x20 (Space) Local Const $STD_OUTPUT_HANDLE = -11 Local Const $INVALID_HANDLE_VALUE = -1 Local Const $tagCONSOLE_SCREEN_BUFFER_INFO = "short dwSizeX; short dwSizeY;short dwCursorPositionX;" & _ "short dwCursorPositionY; short wAttributes;short Left; short Top; short Right; short Bottom;" & _ "short dwMaximumWindowSizeX; short dwMaximumWindowSizeY" ;// get handle to standard output device (handle does not have to be closed on return) Local $hDLLK32 = DllOpen("Kernel32.dll"), $aRet If $hConsole = -1 Then $aRet = DllCall($hDLLK32, "hwnd", "GetStdHandle", "dword", $STD_OUTPUT_HANDLE) $iErr = @error If @error Or UBound($aRet) <> 2 Or $aRet[0] = $INVALID_HANDLE_VALUE Then Return SetError($iErr, 1, $INVALID_HANDLE_VALUE) EndIf $hConsole = $aRet[0] EndIf ;// create console screen buffer struct, get buffer Local $tCONSOLE_SCREEN_BUFFER_INFO = DllStructCreate($tagCONSOLE_SCREEN_BUFFER_INFO) If @error Then Return SetError(@error, 2, 0) Local $pConsoleScreenBufferInfo = DllStructGetPtr($tCONSOLE_SCREEN_BUFFER_INFO) If @error Then Return SetError(@error, 3, 0) $aRet = DllCall($hDLLK32, "int", "GetConsoleScreenBufferInfo", "hwnd", _ $hConsole, "ptr", $pConsoleScreenBufferInfo) $iErr = @error If @error Or UBound($aRet) <> 3 Or Not $aRet[0] Then Return SetError($iErr, 4, 0) ;// Get the screen buffer max width (character columns) and height (rows) Local $dwSizeX = DllStructGetData($tCONSOLE_SCREEN_BUFFER_INFO, "dwSizeX") Local $dwSizeY = DllStructGetData($tCONSOLE_SCREEN_BUFFER_INFO, "dwSizeY") Local $dwConSize ;// input coordinates range check If IsNumber($iX) And (Abs($iX) > ($dwSizeX -1)) Then $iX = $dwSizeX -1 If IsNumber($iY) And (Abs($iY) > ($dwSizeY -1)) Then $iY = $dwSizeY -1 Select ;// clear screen (Default) - max screen buffer width multiplied by height Case IsNumber($iX) = 0 And IsNumber($iY) = 0 ; handles Default keyword and strings in params $dwConSize = ($dwSizeX * $dwSizeY) $iX = 0 $iY = 0 ;// overwrite or clear any single row - cursor now set to start of that row Case IsKeyword($iX) = 1 And IsKeyword($iY) = 0 And $iY >= 0 $dwConSize = $dwSizeX $iX = 0 ;// overwrite or clear a number of rows from starting row ;(-$iX parameter is number of rows to overwrite, second row minimum) Case $iX < 0 And $iY < 0 $iY = Abs($iY) $dwConSize = ($dwSizeX * Abs($iX)) $iX = 0 ;// overwrite or clear all rows from starting row to last row, second row minimum) Case IsKeyword($iX) = 1 And $iY < 0 $iY = Abs($iY) $dwConSize = ($dwSizeX * $dwSizeY) - ($dwSizeX * $iY) $iX = 0 ;// overwrite or clear text from character position on row to end of row Case $iX >= 0 And IsKeyword($iY) = 0 And $iY >= 0 $dwConSize = ($dwSizeX - $iX) If $iX = 0 And $iY = 0 Then $fFlag = True ContinueCase EndIf ;// place cursor at last row of console window Case $iX >= 0 And IsKeyword($iY) = 1 If Not $fFlag Then $iY = DllStructGetData($tCONSOLE_SCREEN_BUFFER_INFO, "Bottom") ContinueCase ;// places cursor at coordinates for overwriting Case $iX < 0 And $iY >= 0 $dwCoord = BitOR($iY * 0x10000, BitAND(Abs($iX), 0xFFFF)) $aRet = DllCall($hDLLK32, "int", "SetConsoleCursorPosition", "hwnd", _ $hConsole, "dword", $dwCoord) $iErr = @error If @error Or UBound($aRet) <> 3 Or Not $aRet[0] Then Return SetError($iErr, 5, 0) DllClose($hDLLK32) Return SetError(0, 0, $hConsole) Case Else Return SetError(@error, 6, 0) EndSelect ;// Cursor position: make DWord of X,Y coordinates) $dwCoord = BitOR($iY * 0x10000, BitAND($iX, 0xFFFF)) ;// Fill selected rows with blanks $aRet = DllCall($hDLLK32, "int", "FillConsoleOutputCharacterW", "hwnd", $hConsole, _ "byte", $bChar, "dword", $dwConSize, "dword", $dwCoord, "int*", 0) $iErr = @error If @error Or UBound($aRet) <> 6 Or $aRet[5] <> $dwConSize Then Return SetError($iErr, 7, 0) ;// Get the current text attributes $aRet = DllCall($hDLLK32, "int", "GetConsoleScreenBufferInfo", "hwnd", _ $hConsole, "dword", $pConsoleScreenBufferInfo) $iErr = @error If @error Or UBound($aRet) <> 3 Or Not $aRet[0] Then Return SetError($iErr, 8, 0) Local $wAttribute = DllStructGetData($tCONSOLE_SCREEN_BUFFER_INFO, "wAttributes") ;// Set the buffer's attributes $aRet = DllCall($hDLLK32, "int", "FillConsoleOutputAttribute", "hwnd", $hConsole, _ "short", $wAttribute, "dword", $dwConSize, "dword", $dwCoord, "int*", 0) $iErr = @error If @error Or UBound($aRet) <> 6 Or $aRet[5] <> $dwConSize Then Return SetError($iErr, 9, 0) ;// Put the cursor at 0,0 or supplied coordinates $aRet = DllCall($hDLLK32, "int", "SetConsoleCursorPosition", "hwnd", _ $hConsole, "dword", $dwCoord) $iErr = @error If @error Or UBound($aRet) <> 3 Or Not $aRet[0] Then Return SetError($iErr, 10, 0) DllClose($hDLLK32) Return SetError(@error, 0, $hConsole)EndFunc ;==>_WinAPI_ClearConsole; #FUNCTION# =======================================================; Name...........: _WinAPI_CursorShowConsole; Description ...: Show or Hide console cursor, set cursor size; Syntax.........: _WinAPI_CursorShowConsole($hConsole, $fShow = True, $iSize = Default); Parameters ....: $hConsole - Handle to standard output device; $fShow - Boolean: True - show cursor, False - hide cursor; $iSize - (Optional) set cursor size 1-100;; Return values .: Success - return previous cursor size; Failure - return 0, set error and extended; Author ........: rover; Modified.......:; Remarks .......:;; Related .......:; Link ..........; @@MsdnLink@@ SetConsoleCursorInfo / GetConsoleCursorInfo; Example .......; Yes; ==================================================================Func _WinAPI_CursorShowConsole($hConsole = -1, $fShow = True, $iSize = Default) If $hConsole = -1 Then Return SetError(1, 1, 0) ;// create console cursor info struct Local $aRet, $iErr Local Const $tagCONSOLE_CURSOR_INFO = "dword dwSize;int bVisible" Local $tCONSOLE_CURSOR_INFO = DllStructCreate($tagCONSOLE_CURSOR_INFO) If @error Then Return SetError(@error, 2, 0) Local $pCONSOLE_CURSOR_INFO = DllStructGetPtr($tCONSOLE_CURSOR_INFO) If @error Then Return SetError(@error, 3, 0) $aRet = DllCall("Kernel32.dll", "int", "GetConsoleCursorInfo", _ "hwnd", $hConsole, "ptr", $pCONSOLE_CURSOR_INFO) $iErr = @error If @error Or UBound($aRet) <> 3 Or Not $aRet[0] Then Return SetError($iErr, 4, 0) Local $iPrevSize = DllStructGetData($tCONSOLE_CURSOR_INFO, "dwSize") If @error Then Return SetError(@error, 5, 0) DllStructSetData($tCONSOLE_CURSOR_INFO, "bVisible", $fShow) If @error Then Return SetError(@error, 6, 0) If Not IsKeyword($iSize) And IsNumber($iSize) Then DllStructSetData($tCONSOLE_CURSOR_INFO, "dwSize", $iSize) If @error Then Return SetError(@error, 7, 0) EndIf DllCall("Kernel32.dll", "int", "SetConsoleCursorInfo", _ "hwnd", $hConsole, "ptr", $pCONSOLE_CURSOR_INFO) $iErr = @error If @error Or UBound($aRet) <> 3 Or Not $aRet[0] Then Return SetError($iErr, 8, 0) Return SetError(@error, 0, $iPrevSize)EndFunc ;==>_WinAPI_CursorShowConsole Edited March 29, 2009 by rover mLipok 1 I see fascists... Link to comment Share on other sites More sharing options...
KaFu Posted March 28, 2009 Share Posted March 28, 2009 Perfect, with good examples... updated my signature ... Best Regards OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
ResNullius Posted March 29, 2009 Share Posted March 29, 2009 Beautiful! Thanks rover. Link to comment Share on other sites More sharing options...
rover Posted March 29, 2009 Author Share Posted March 29, 2009 Greetings KaFu and ResNullius Thanks! The cursor positioning options added to the console clear function I posted in the help forum worked out nicely. I wasn't satisfied with the basic three row display in the first example script, so I've now added an example that demonstrates multiple updated mid line labels and a mid line progress bar in a console DOS character frame with hidden cursor. be seeing you I see fascists... Link to comment Share on other sites More sharing options...
Mobius Posted March 29, 2009 Share Posted March 29, 2009 Brilliant work rover, Very helpful indeed Link to comment Share on other sites More sharing options...
trancexx Posted March 29, 2009 Share Posted March 29, 2009 rover kicks ass with this ...and that ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Authenticity Posted March 29, 2009 Share Posted March 29, 2009 ;// input coordinates range check If IsNumber($iX) And IsNumber($iY) Then If $iX > $dwSizeX Then $iX = $dwSizeX If $iY > $dwSizeY Then $dwSizeY = $dwSizeY EndIf $dwSizeY = $dwSizeY ;] Link to comment Share on other sites More sharing options...
rover Posted March 29, 2009 Author Share Posted March 29, 2009 ;// input coordinates range check If IsNumber($iX) And IsNumber($iY) Then If $iX > $dwSizeX Then $iX = $dwSizeX If $iY > $dwSizeY Then $dwSizeY = $dwSizeY EndIf $dwSizeY = $dwSizeY ;]Authenticity Thanks for pointing that out yep, looks like one of my unfinished cut 'n' paste mistakes vaguely remember needing to finish that this is what it should be: ;// input coordinates range check If IsNumber($iX) And (Abs($iX) > ($dwSizeX -1)) Then $iX = $dwSizeX -1 If IsNumber($iY) And (Abs($iY) > ($dwSizeY -1)) Then $iY = $dwSizeY -1 Thanks @Mobius @trancexx glad you can make use of this this is what I was going to respond with anyway, now its more pointed rover kicks ass with this ...and thatsometimes rover gets kicked or falls on his ass live long enough and you'll know I see fascists... Link to comment Share on other sites More sharing options...
trancexx Posted March 29, 2009 Share Posted March 29, 2009 I'm gonna be a little offtopic now, but only because I need help with something. Hope rover won't mind (if you do I will post somewhere else). Thing is this thread is likely read by people who might help me because the problem all about console and I need assistance of console people (rover is console people ).... I'm writing console addition to ResourcesViewerAndCompiler.au3. I have the whole concept of command line options and switches and additionally I wanted to be able to write and read from console without need to do #AutoIt3Wrapper_Change2CUI=y.So basically, compile as GUI but with capabilities of CUI.Since AutoI't is using funcions CreateFile and related to do file reading and writing stuff I've manage to use that to do most of the job (link to explanation on how to use CreateFile for this). What I don't have solution for is how to write to console without allocating a new console.I tried AttachConsole function but the result is not exactly what I expected. If you could help me with that rover or anyone else I would be more than grateful. This is what I got (strings are to be worked on):expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=Test.exe #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon Global $sParent = _GetParent() If @Compiled Then Switch $sParent Case "explorer.exe" Run("Test.exe") ;$iDroppedOnFirstRun = $CmdLineRaw = True ;_Main(StringReplace($CmdLineRaw, '"', '')) Case Else _ExecuteCommandLine($CmdLineRaw) EndSwitch Else Switch $sParent Case "cmd.exe" _ExecuteCommandLine($CmdLineRaw) Case Else Run("Test.exe") ;_Main() EndSwitch EndIf Func _GetParent() Local $sParent ; will be used in case of error Local $aCall = DllCall("kernel32.dll", "int", "GetCurrentProcess") If @error Or Not $aCall[0] Then $sParent = _ProcessGetParent(@AutoItPID) Return SetError(@error, 0, $sParent) EndIf Local $hProcess = $aCall[0] Local $tPROCESS_BASIC_INFORMATION = DllStructCreate("dword ExitStatus;" & _ "ptr PebBaseAddress;" & _ "dword AffinityMask;" & _ "dword BasePriority;" & _ "dword UniqueProcessId;" & _ "dword InheritedFromUniqueProcessId") Local $aCall = DllCall("ntdll", "int", "NtQueryInformationProcess", _ "hwnd", $hProcess, _ "dword", 0, _ "ptr", DllStructGetPtr($tPROCESS_BASIC_INFORMATION), _ "dword", DllStructGetSize($tPROCESS_BASIC_INFORMATION), _ "dword*", 0) If @error Then $sParent = _ProcessGetParent(@AutoItPID) Return SetError(@error, 0, $sParent) EndIf Local $aProcesses = ProcessList() If @error Then Return SetError(11, 0, "") EndIf For $i = 1 To $aProcesses[0][0] If $aProcesses[$i][1] = DllStructGetData($tPROCESS_BASIC_INFORMATION, "InheritedFromUniqueProcessId") Then Return SetError(0, 0, $aProcesses[$i][0]) EndIf Next $sParent = _ProcessGetParent(@AutoItPID) Return SetError(@error, 0, $sParent) EndFunc ;==>_GetParent Func _ProcessGetParent($iPID) ; SmOke_N's originally Local $aCall = DllCall("kernel32.dll", "hwnd", "CreateToolhelp32Snapshot", _ "dword", 2, _ ; CS_SNAPPROCESS "dword", 0) If @error Or $aCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hSnapshot = $aCall[0] Local $tPROCESSENTRY32 = DllStructCreate("dword Size;" & _ "dword Usage;" & _ "dword ProcessID;" & _ "int DefaultHeapID;" & _ "dword ModuleID;" & _ "dword Threads;" & _ "dword ParentProcessID;" & _ "int PriClassBase;" & _ "dword Flags;" & _ "wchar ExeFile[260]") DllStructSetData($tPROCESSENTRY32, "Size", DllStructGetSize($tPROCESSENTRY32)) $aCall = DllCall("kernel32.dll", "int", "Process32FirstW", _ "hwnd", $hSnapshot, _ "ptr", DllStructGetPtr($tPROCESSENTRY32)) If @error Or Not $aCall[0] Then Return SetError(2, 0, "") EndIf If DllStructGetData($tPROCESSENTRY32, "ProcessID") = $iPID Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hSnapshot) Local $aProcesses = ProcessList() If @error Then Return SetError(11, 0, "") EndIf For $i = 1 To $aProcesses[0][0] If $aProcesses[$i][1] = DllStructGetData($tPROCESSENTRY32, "ParentProcessID") Then Return SetError(0, 0, $aProcesses[$i][0]) EndIf Next Return SetError(3, 0, "") EndIf While 1 $aCall = DllCall("kernel32.dll", "int", "Process32NextW", "hwnd", $hSnapshot, "ptr", DllStructGetPtr($tPROCESSENTRY32)) If @error Or Not $aCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hSnapshot) Return SetError(4, 0, "") EndIf If DllStructGetData($tPROCESSENTRY32, "ProcessID") = $iPID Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hSnapshot) Local $aProcesses = ProcessList() If @error Then Return SetError(11, 0, "") EndIf For $i = 1 To $aProcesses[0][0] If $aProcesses[$i][1] = DllStructGetData($tPROCESSENTRY32, "ParentProcessID") Then Return SetError(0, 0, $aProcesses[$i][0]) EndIf Next Return SetError(3, 0, "") EndIf WEnd EndFunc ;==>_ProcessGetParent Func _ExecuteCommandLine($sCommandLine) ; Code missing regarding checking run switches Local $aCall = DllCall("kernel32.dll", "int", "AllocConsole") If @error Or Not $aCall[0] Then Return SetError(1, 0, "") EndIf Local $hConIn = FileOpen("CONIN$", 4) ; reading handle Local $hConOut = FileOpen("CONOUT$", 1) ; writing handle FileWrite($hConOut, "Resources Viewer And Compiler >") FileClose($hConOut) Local $sPrintString While 1 Sleep(100) Switch BinaryToString(FileRead($hConIn, 512)) Case "help" & @CRLF, "?" & @CRLF $sPrintString = @CRLF $sPrintString &= "Description:" & @CRLF & " Command line section of ResourcesViewerAndCompiler.exe" & @CRLF & _ " To be used for: - deleting/altering/adding resources to PE files " & _ " - compiling resource DLLs " & @CRLF $sPrintString &= "Usage: " & @CRLF & " [-gen][Module path][Resource path][-add|-remove][-restype Type][-resname Name]" & _ " [-reslang Language] " & @CRLF $sPrintString &= "Options:" & @CRLF & " -gen ...optional parameter. Required only when compiling initial DLL" & _ " file. Can be omitted and is ignored otherwise. " & _ " Module path ...fully qualified path to the module. In combination with " & _ " previous parameter means the path/name of the compiled " & _ " initial module. " & _ " Resource path ...fully qualified path to the resource file. Should be omitted" & _ " if -remove switch is used " & _ " -add ...add resource " & _ " -remove ...remove/delete resource " & _ " -restype ...type of resource. If -add switch is used can be omitted. In " & _ " that case type is derived out of res file's characteristics." & _ " -resname ...name of resource. Required. " & _ " -reslang ...resource language. Can be omitted - default is 0 (neutral)." $sPrintString &= @CRLF & @CRLF & "Resources Viewer And Compiler >" $hConOut = FileOpen("CONOUT$", 1) FileWrite($hConOut, $sPrintString) FileClose($hConOut) Case "gui mode" & @CRLF $sPrintString = "Switching to GUI mode..." & @CRLF $hConOut = FileOpen("CONOUT$", 1) FileWrite($hConOut, $sPrintString) FileClose($hConOut) Sleep(300) DllCall("kernel32.dll", "int", "FreeConsole") ;_Main() Case "exit" & @CRLF, "quit" & @CRLF Exit Case Else $sPrintString = @CRLF & "Invalid input. Type ? for help." & @CRLF & @CRLF & _ "Resources Viewer And Compiler >" $hConOut = FileOpen("CONOUT$", 1) FileWrite($hConOut, $sPrintString) FileClose($hConOut) EndSwitch WEnd FileClose($hConIn) Return EndFunc ;==>_ExecuteCommandLineDon't change AutoIt3Wrapper_GUI directives and just compile it and run exe or that script afterward. Or don't compile, but run script from command prompt.To summarize, how can I attach to console and not lose it with every ENTER? Hope I was clear enough ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
rover Posted March 29, 2009 Author Share Posted March 29, 2009 trancexx, carry ona forum search for: DaveF consoleturns up some informative linksI've only tried these examples and not applied themUsing autoit to make console applikationshttp://www.autoitscript.com/forum/index.ph...st&p=120325Using autoit to make console applikationshttp://www.autoitscript.com/forum/index.ph...st&p=120671 I see fascists... Link to comment Share on other sites More sharing options...
trancexx Posted March 31, 2009 Share Posted March 31, 2009 trancexx, carry ona forum search for: DaveF consoleturns up some informative linksI've only tried these examples and not applied themUsing autoit to make console applikationshttp://www.autoitscript.com/forum/index.ph...st&p=120325Using autoit to make console applikationshttp://www.autoitscript.com/forum/index.ph...st&p=120671I didn't find much there. Maybe there's something that I missed, but the outcome is still nothing.Will try on general help and support.Thanks. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now