Jonniy Posted November 30, 2013 Posted November 30, 2013 (edited) Here's the script: expandcollapse popup#include <ButtonConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <GuiEdit.au3> #include <ScrollBarsConstants.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) HotKeySet("{UP}", "_GetCommandUp") HotKeySet("{DOWN}", "_GetCommandDown") Global $sCurrentCommand, $iTimeStartMin = @MIN, $iTimeStartH = @HOUR If FileRead(@AutoItExe & ":commandlist") <> '' And FileExists(@AutoItExe & "\CMD-Commands.log") = 0 Then Global $hCommandFile = FileOpen(@ScriptDir & "\CMD-Commands.log", 9) FileWrite($hCommandFile, FileRead(@AutoItExe & ":commandlist")) DllCall("kernel32.dll", "int", "DeleteFileW", "wstr", @AutoItExe & ":commandlist") FileFlush($hCommandFile) Global $aCommandArray = FileReadToArray(@ScriptDir & "\CMD-Commands.log") Global $iCommandCount = UBound($aCommandArray) - 2 Global $iCurrentCommand = $iCommandCount Else Global $hCommandFile = FileOpen(@ScriptDir & "\CMD-Commands.log", 9) Global $aCommandArray = FileReadToArray(@ScriptDir & "\CMD-Commands.log") Global $iCommandCount = UBound($aCommandArray) - 2 Global $iCurrentCommand = $iCommandCount DllCall("kernel32.dll", "int", "DeleteFileW", "wstr", @AutoItExe & ":commandlist") EndIf Global $hGUI = GUICreate("Cmd", 489, 277, Default, Default, $WS_CAPTION + $WS_SYSMENU) GUISetBkColor(0x000000, $hGUI) GUICtrlSetDefBkColor(0x000000, $hGUI) GUICtrlSetDefColor(0x00FF00, $hGUI) Global $hEdit1 = GUICtrlCreateEdit("", 8, 8, 473, 217, $ES_READONLY + $ES_AUTOVSCROLL) Global $hButton1 = GUICtrlCreateButton("Execute", 16, 240, 75, 25, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON)) Global $hInput1 = GUICtrlCreateInput("", 96, 243, 385, 20) GUICtrlSetOnEvent($hButton1, "_RunCommand") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) Func _RunCommand() $iCommandCount + 1 Local $sInputCommand = GUICtrlRead($hInput1) _ArrayAdd($aCommandArray, $sInputCommand) FileWrite($hCommandFile, $sInputCommand & @CRLF) FileWrite(@AutoItExe & ":commandlist", $sInputCommand & @CRLF) FileFlush($hCommandFile) Local $hDOS = Run(@ComSpec & " /c " & $sInputCommand, "", @SW_HIDE, $STDERR_MERGED) GUICtrlSetData($hEdit1, GUICtrlRead($hEdit1) & @CRLF & 'Command: "' & $sInputCommand & '"' & @CRLF & "{") _GUICtrlEdit_Scroll($hEdit1, $SB_SCROLLCARET) Do Local $sStdOut = StdoutRead($hDOS) If $sStdOut <> '' Then GUICtrlSetData($hEdit1, GUICtrlRead($hEdit1) & @CRLF & Oem2Ansi($sStdOut)) _GUICtrlEdit_Scroll($hEdit1, $SB_SCROLLCARET) EndIf Until ProcessExists($hDOS) = 0 GUICtrlSetData($hEdit1, GUICtrlRead($hEdit1) & @CRLF & "}" & ' ;==> "' & $sInputCommand & '"' & @CRLF) _GUICtrlEdit_Scroll($hEdit1, $SB_SCROLLCARET) EndFunc ;==>_RunCommand Func Oem2Ansi($text) Local $aText = DllCall("user32.dll", "Int", "OemToChar", "str", $text, "str", "") Return $aText[2] EndFunc ;==>Oem2Ansi Func _GetCommandUp() If $iCurrentCommand - 1 <= 0 Then GUICtrlSetData($hInput1, "") Else $iCurrentCommand - 1 GUICtrlSetData($hInput1, $aCommandArray[$iCurrentCommand]) EndIf EndFunc ;==>_GetCommandUp Func _GetCommandDown() If $iCurrentCommand + 1 > $iCommandCount Then GUICtrlSetData($hInput1, "") Else $iCurrentCommand + 1 GUICtrlSetData($hInput1, $aCommandArray[$iCurrentCommand]) EndIf EndFunc ;==>_GetCommandDown Func _Exit() Local $hLogFile = FileOpen(@ScriptDir & "\CMD-Klon.log", 9) FileWrite($hLogFile, "Execution log (Session: " & @MDAY & "/" & @MON & "/" & @YEAR & ")(At: " & $iTimeStartH & "/" & $iTimeStartMin & "|'Till: " & @HOUR & "/" & @MIN & "):" & @CRLF & GUICtrlRead($hEdit1) & @CRLF) FileClose($hCommandFile) FileClose($hLogFile) Exit EndFunc ;==>_Exit While 1 Sleep(200) WEnd Now, this doesn't display "öüä" in the output of the cmd. What I mean by that is:http://www.imagebanana.com/view/gbigbyx9/CMDOutput.JPG At the marked spot should be 2 "Umlauts". ---Is this really the correct translation?? http://www.dict.cc/?s=umlaut EDIT: The "öüä" problem has been solved. Just run the output through this: Func Oem2Ansi($text) Local $aText = DllCall("user32.dll", "Int", "OemToChar", "str", $text, "str", "") Return $aText[2] EndFunc ;==>Oem2Ansi The second problem is that if I press up/down, it'll just display "" instead of the previous command. EDIT2: When I did FileReadToArray.. I put the wrong path in it. I corrected it here as well. But it still doesn't work correctly... PS: Maybe I can't reply untill monday evening... Sincerely, -Jonniy- Edited November 30, 2013 by Jonniy Thanks for your help & have a good day. Yours sincerely, -Jonniy-
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