Ups Danke,
hatte es gat nicht getestet.
mfg Ubuntu
Ups Danke,
hatte es gat nicht getestet.
mfg Ubuntu
Update.
Schriftart geändert.
Danke an H2112
mfg Ubuntu
Du bist damit jetzt mindestens der dritte, der eine eigene Konsole gebastelt hat
https://autoit.de/index.php?page…4372#post104372
https://autoit.de/index.php?page…3886#post153886
Wir haben keine eigene Konsole erstellt, sondern die Standart-Konsole genommen und mit DLL-Aufrufen darauf zugegriffen.
Ich hab mich mal ein bisschen damit gespielt und dein Script stark umgeschrieben.
Jetzt hat die Console ein paar Funktionen mit Beschreibungen.
Sei mir nicht böse, aber ich hatte gerade Langeweile.
Kannst den ganzen Code übernehmen wenn du willst.
#include <Misc.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $Console, $CurCommand, $Read, $Commands[5], $CommandsDis[5], $Right, $CurCommandParameters, $CurCommandString
Global $dll = DllOpen("user32.dll")
Global $title = "Console"
$Commands[0] = "HELP"
$Commands[1] = "EXIT"
$Commands[2] = "MSGBOX"
$Commands[3] = "CLEAR"
$Commands[4] = "COLOUR"
$CommandsDis[0] = "Shows a List of all commands/E/tParameter 1 = Command (optional)"
$CommandsDis[1] = "Exit the console"
$CommandsDis[2] = "Shows a massage/E/tParameter 1 = Flag/E/tParameter 2 = Title (string)/E/tParameter 3 = Text (string)"
$CommandsDis[3] = "Clears the Console"
$CommandsDis[4] = "Changes the font and background colour/E/tParameter 1 = font colour (HEX)/E/tParameter 2 = background colour (HEX) (optional)"
$Console = _ConsoleCreate($title)
_ConsoleWrite($Console, "Welcome/EThis is a Console example from http://www.AutoIt.de/E")
While 1
If _IsPressed("0D", $dll) And WinActive($title) Then
$array = StringSplit(GUICtrlRead($Console[1]), @CRLF)
$CurCommand = $array[Ubound($array) - 1]
$CurCommandParameters = StringSplit($CurCommand, " ")
$CurCommandString = StringSplit($CurCommand, '"')
For $i = 1 To $array[0] - 1 Step 2
$Read &= $array[$i] & @CRLF
Next
GUICtrlSetData($Console[1], $Read & "> " & $CurCommand & @CRLF)
For $i = 0 To UBound($Commands) - 1
If $CurCommandParameters[1] = $Commands[$i] Then
Call("_ConsoleCommand_" & $Commands[$i])
$Right = True
ExitLoop
Else
$Right = False
EndIf
Next
If Not $Right Then
_ConsoleWrite($Console, "unknown Command/EType HELP to list all commands")
EndIf
While _IsPressed("0D", $dll) And WinActive($title)
Sleep(100)
WEnd
$Read = ""
EndIf
Sleep(30)
WEnd
Func _ConsoleCommand_COLOUR()
If UBound($CurCommandParameters) = 3 Then
GUICtrlSetColor($Console[1], "0x" & $CurCommandParameters[2])
ElseIf UBound($CurCommandParameters) = 4 Then
GUICtrlSetColor($Console[1], "0x" & $CurCommandParameters[2])
GUICtrlSetBkColor($Console[1], "0x" & $CurCommandParameters[3])
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _ConsoleCommand_CLEAR()
GUICtrlSetData($Console[1], "")
EndFunc
Func _ConsoleCommand_MSGBOX()
If Not UBound($CurCommandParameters) < 5 And UBound($CurCommandString) = 6 Then
MsgBox(Number($CurCommandParameters[2]), $CurCommandString[2], $CurCommandString[4])
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _ConsoleCommand_Exit()
_WinSetSize($Console[0], 660, 0, 10, 5)
Exit
EndFunc
Func _ConsoleCommand_HELP()
If UBound($CurCommandParameters) = 2 Then
For $i = 0 To UBound($Commands) - 1
_ConsoleWrite($Console, $Commands[$i])
Next
ElseIf UBound($CurCommandParameters) = 3 Then
For $i = 0 To UBound($Commands) - 1
If $CurCommandParameters[2] = $Commands[$i] Then
_ConsoleWrite($Console, $Commands[$i] & "/t" & $CommandsDis[$i])
ExitLoop
EndIf
Next
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _SM_SetVisualStyle($b_Enable)
Return DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $b_Enable)
EndFunc
Func _ConsoleCreate($Title)
Local $Console[2]
_SM_SetVisualStyle(False)
$Console[0] = GUICreate($Title, 654, 0, -1, @DesktopHeight/2 - 164, Default, $WS_EX_Composited)
GUISetOnEvent(-3, "_ConsoleCommand_Exit")
GUISetBkColor(0x000000)
$Console[1] = GUICtrlCreateEdit("", 0, 0, 657, 297, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetBkColor($Console[1], 0x000000)
GUICtrlSetColor($Console[1], 0xC0C0C0)
GUICtrlSetFont($Console[1], 10, Default, Default, "Lucida Console")
GUISetState(@SW_SHOW)
_WinSetSize($Console[0], 660, 329, 10, 5)
Return $Console
Endfunc
Func _ConsoleWrite($Console, $String)
Local $timer, $split
$String = StringReplace($String, "/E", @CRLF)
$String = StringReplace($String, "/t", @TAB)
$split = StringSplit($String, "")
$timer = TimerInit()
For $i = 1 To $split[0]
Sleep(20)
GUICtrlSetData($Console[1], GUICtrlRead($Console[1]) & $split[$i])
Next
GUICtrlSetData($Console[1], GUICtrlRead($Console[1]) & @CRLF)
EndFunc
Func _WinSetSize($hWnd, $iWidth, $iHeigth, $iSleep = -1,$iStep = 4);by Gta Spider
If $iSleep < 0 Then Return WinMove($hWnd,"",Default,Default,$iWidth,$iHeigth)
Local $i, $iStepW = $iStep, $iStepH = $iStep,$iSin,$i2,$iLastI
Local $aWinPos = WinGetPos($hWnd)
If $iWidth < $aWinPos[2] Then $iStepW *= -1
If $iHeigth < $aWinPos[3] Then $iStepH *= -1
Local $iDegToRad = 3.14159265358979/180
Local $iSinMulW = ($iWidth - $aWinPos[2]) / 2.5
Local $iSinMulH = ($iHeigth - $aWinPos[3]) / 2.5
If $iSinMulW < 0 Then $iSinMulW *= -1
If $iSinMulH < 0 Then $iSinMulH *= -1
If $iWidth <> $aWinPos[2] Then
For $i = $aWinPos[2] To $iWidth Step $iStepW
$iLastI = $i
$iSin = $i - $aWinPos[2]
$iSin = Sin($iDegToRad * (180*$iSin/($iWidth - $aWinPos[2])))
WinMove($hWnd,"",Default,Default,$i + ($iSin * $iSinMulW),Default)
Sleep($iSleep)
Next
If Mod($iWidth - $aWinPos[2],$iStep) Then
If $iStepW < 0 Then
$iStepW = -1
Else
$iStepW = 1
EndIf
For $i = $iLastI -1 To $iWidth Step $iStepW
WinMove($hWnd,"",Default,Default,$i,Default)
Next
EndIf
EndIf
If $iHeigth <> $aWinPos[3] Then
For $i = $aWinPos[3] To $iHeigth Step $iStepH
$iLastI = $i
$iSin = $i - $aWinPos[3]
$iSin = Sin($iDegToRad*(180*$iSin/($iHeigth - $aWinPos[3])))
WinMove($hWnd,"",Default,Default,Default,$i + ($iSin * $iSinMulH))
Sleep($iSleep)
Next
If Mod($iHeigth - $aWinPos[3],$iStep) Then
If $iStepH < 0 Then
$iStepH = -1
Else
$iStepH = 1
EndIf
For $i = $iLastI -1 To $iHeigth Step $iStepH
WinMove($hWnd,"",Default,Default,Default,$i)
Next
EndIf
EndIf
EndFunc
gebt da mal lol ein xD^^
@H2112:
Ok da werd ich ja bald wieder arbeitslos sein.
Ich werd das ganze meinerseits noch ein bisschen anpassen.
Wofür steht denn $WS_EX_Composited
konnte es in der Hilfe nicht finden.
mfg Ubuntu
So jetzt angepasst und oben gepostet.
Ich werde das ganze natürlich noch weiter modifizieren.
@H2112:
xD du hast ja fast alles umgeschrieben obwolhl du mit dem verändern von ein paar Zeilen das gleiche erreicht hättest
mfg Ubuntu
Befehl "HIDE" hinzugefügt
mfg Ubuntu
Bug gefixt der bei der Funktion Help auftrat
mfg Ubuntu
Wie angekündigt jetzt "CREATE_FILE"
Mit detailierter Fehlerrückgabe
mfg Ubuntu
Jetzt noch "EXECUTE" (in AutoIt ShellExecute) um die Dateien auch zu öffnen
mfg Ubuntu
die konsole is schon ganz witzig
du könntest ja auch zum fun was mit gdi+ machen
vll das man dan aum desktop herumzeichnet xD
Ich würd die Befehle wie CREATE_FILE eher nur mit dem Befehl FILE machen und den ersten Parameter für CREATE oder MOVE verwenden.
Außerdem ist beim FileCreate keine richtige Error Abfrage.
Aber ansonsten zwei nette Funktionen.
Edit:
$WS_EX_Composited sorgt dafür, dass die GUI nicht flackert.
Edit2:
So hab die Konsole nochmal überarbeitet und eine neue Funktion CD hinzugefügt.
#include <Misc.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <File.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $Console, $CurCommand, $Read, $Commands[8], $CommandsDis[8], $Right, $CurCommandParameters, $CurCommandString, $CurPath = @ScriptDir
Global $dll = DllOpen("user32.dll")
Global $title = "Console"
$Commands[0] = "HELP"
$Commands[1] = "EXIT"
$Commands[2] = "MSGBOX"
$Commands[3] = "CLEAR"
$Commands[4] = "COLOUR"
$Commands[5] = "HIDE"
$Commands[6] = "FILE"
$Commands[7] = "CD"
$CommandsDis[0] = "Shows a List of all commands/E/tParameter 1 = Command (optional)"
$CommandsDis[1] = "Exit the console"
$CommandsDis[2] = "Shows a massage/E/tParameter 1 = Flag/E/tParameter 2 = Title (string)/E/tParameter 3 = Text (string)"
$CommandsDis[3] = "Clears the Console"
$CommandsDis[4] = "Changes the font and background colour/E/tParameter 1 = font colour (HEX)/E/tParameter 2 = background colour (HEX) (optional)"
$CommandsDis[5] = "Hides the Console until its activated again/E/tParameter 1 = Sleeptime in ms"
$CommandsDis[6] = "CREATE/tCreates a file or overwrites a existing File/E/t/tParameter 1 = Filepath (string)/E/tMOVE/tMoves a File/E/t/tParameter 1 = Filepath (string)/E/t/tParameter 2 = Movepath (string)"
$CommandsDis[7] = "Changes the directory/E/tParameter 1 = New directory"
$Console = _ConsoleCreate($title)
_ConsoleWrite($Console, "Welcome/EThis is a Console example from http://www.AutoIt.de/E")
While 1
If _IsPressed("0D", $dll) And WinActive($title) Then
$array = StringSplit(GUICtrlRead($Console[1]), @CRLF)
$CurCommand = $array[Ubound($array) - 1]
$CurCommandParameters = StringSplit($CurCommand, " ")
$CurCommandString = StringSplit($CurCommand, '"')
For $i = 1 To $array[0] - 1 Step 2
$Read &= $array[$i] & @CRLF
Next
GUICtrlSetData($Console[1], $Read & $CurPath & "> " & $CurCommand & @CRLF)
For $i = 0 To UBound($Commands) - 1
If $CurCommandParameters[1] = $Commands[$i] Then
Call("_ConsoleCommand_" & $Commands[$i])
$Right = True
ExitLoop
Else
$Right = False
EndIf
Next
If Not $Right Then
_ConsoleWrite($Console, "unknown Command/EType HELP to list all commands")
EndIf
While _IsPressed("0D", $dll) And WinActive($title)
Sleep(100)
WEnd
$Read = ""
EndIf
Sleep(30)
WEnd
Func _ConsoleCommand_CD()
If UBound($CurCommandString) > 3 Then
$CurPath = $CurCommandString[2]
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _ConsoleCommand_FILE()
If UBound($CurCommandParameters) < 2 Then _ConsoleWrite($Console, "Parameter Error")
If $CurCommandParameters[2] = "CREATE" Then
If UBound($CurCommandString) > 3 Then
If Not _FileCreate($CurPath & "\" & $CurCommandString[2]) Then _ConsoleWrite($Console, "Error")
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
ElseIf $CurCommandParameters[2] = "MOVE" Then
If UBound($CurCommandString) > 5 Then
FileMove($CurPath & "\" & $CurCommandString[2], $CurPath & "\" & $CurCommandString[4],
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _ConsoleCommand_HIDE()
Local $timer
_WinSetSize($Console[0],660, 0, 10, 4)
GUISetState(@SW_MINIMIZE)
If UBound($CurCommandParameters) > 3 Then
$timer = TimerInit()
While 1
If TimerDiff($timer) > Number($CurCommandParameters[2]) Or WinActive($Title) Then ExitLoop
Sleep(20)
WEnd
ElseIf UBound($CurCommandParameters) = 2 Then
While 1
If WinActive($Title) Then ExitLoop
Sleep(20)
WEnd
EndIf
GUISetState(@SW_RESTORE)
_WinSetSize($Console[0], 660, 329, 10, 5)
EndFunc
Func _ConsoleCommand_COLOUR()
If UBound($CurCommandParameters) = 3 Then
GUICtrlSetColor($Console[1], "0x" & $CurCommandParameters[2])
ElseIf UBound($CurCommandParameters) = 4 Then
GUICtrlSetColor($Console[1], "0x" & $CurCommandParameters[2])
GUICtrlSetBkColor($Console[1], "0x" & $CurCommandParameters[3])
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _ConsoleCommand_CLEAR()
GUICtrlSetData($Console[1], "")
EndFunc
Func _ConsoleCommand_MSGBOX()
If Not UBound($CurCommandParameters) < 5 And UBound($CurCommandString) = 6 Then
MsgBox(Number($CurCommandParameters[2]), $CurCommandString[2], $CurCommandString[4])
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _ConsoleCommand_EXIT()
_WinSetSize($Console[0], 660, 0, 10, 5)
Sleep(100)
Exit
EndFunc
Func _ConsoleCommand_HELP()
If UBound($CurCommandParameters) = 2 Then
For $i = 0 To UBound($Commands) - 1
_ConsoleWrite($Console, $Commands[$i])
Next
_ConsoleWrite($Console, 'Type "help command" for more inforamtion')
ElseIf UBound($CurCommandParameters) = 3 Then
For $i = 0 To UBound($Commands) - 1
If $CurCommandParameters[2] = $Commands[$i] Then
_ConsoleWrite($Console, $Commands[$i] & "/t" & $CommandsDis[$i])
ExitLoop
EndIf
Next
Else
_ConsoleWrite($Console, "Parameter Error")
EndIf
EndFunc
Func _SM_SetVisualStyle($b_Enable)
Return DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $b_Enable)
EndFunc
Func _ConsoleCreate($Title)
Local $Console[2]
_SM_SetVisualStyle(False)
$Console[0] = GUICreate($Title, 654, 0, -1, @DesktopHeight/2 - 164, Default, $WS_EX_Composited)
GUISetOnEvent(-3, "_ConsoleCommand_EXIT")
GUISetBkColor(0x000000)
$Console[1] = GUICtrlCreateEdit("", 0, 0, 657, 297, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetBkColor($Console[1], 0x000000)
GUICtrlSetColor($Console[1], 0xC0C0C0)
GUICtrlSetFont($Console[1], 10, Default, Default, "Lucida Console")
GUISetState(@SW_SHOW)
_WinSetSize($Console[0], 660, 329, 10, 5)
Return $Console
Endfunc
Func _ConsoleWrite($Console, $String)
Local $timer, $split
$String = StringReplace($String, "/E", @CRLF)
$String = StringReplace($String, "/t", @TAB)
$split = StringSplit($String, "")
$timer = TimerInit()
For $i = 1 To $split[0]
Sleep(20)
GUICtrlSetData($Console[1], GUICtrlRead($Console[1]) & $split[$i])
Next
GUICtrlSetData($Console[1], GUICtrlRead($Console[1]) & @CRLF)
EndFunc
Func _WinSetSize($hWnd, $iWidth, $iHeigth, $iSleep = -1,$iStep = 4);by Gta Spider
If $iSleep < 0 Then Return WinMove($hWnd,"",Default,Default,$iWidth,$iHeigth)
Local $i, $iStepW = $iStep, $iStepH = $iStep,$iSin,$i2,$iLastI
Local $aWinPos = WinGetPos($hWnd)
If $iWidth < $aWinPos[2] Then $iStepW *= -1
If $iHeigth < $aWinPos[3] Then $iStepH *= -1
Local $iDegToRad = 3.14159265358979/180
Local $iSinMulW = ($iWidth - $aWinPos[2]) / 2.5
Local $iSinMulH = ($iHeigth - $aWinPos[3]) / 2.5
If $iSinMulW < 0 Then $iSinMulW *= -1
If $iSinMulH < 0 Then $iSinMulH *= -1
If $iWidth <> $aWinPos[2] Then
For $i = $aWinPos[2] To $iWidth Step $iStepW
$iLastI = $i
$iSin = $i - $aWinPos[2]
$iSin = Sin($iDegToRad * (180*$iSin/($iWidth - $aWinPos[2])))
WinMove($hWnd,"",Default,Default,$i + ($iSin * $iSinMulW),Default)
Sleep($iSleep)
Next
If Mod($iWidth - $aWinPos[2],$iStep) Then
If $iStepW < 0 Then
$iStepW = -1
Else
$iStepW = 1
EndIf
For $i = $iLastI -1 To $iWidth Step $iStepW
WinMove($hWnd,"",Default,Default,$i,Default)
Next
EndIf
EndIf
If $iHeigth <> $aWinPos[3] Then
For $i = $aWinPos[3] To $iHeigth Step $iStepH
$iLastI = $i
$iSin = $i - $aWinPos[3]
$iSin = Sin($iDegToRad*(180*$iSin/($iHeigth - $aWinPos[3])))
WinMove($hWnd,"",Default,Default,Default,$i + ($iSin * $iSinMulH))
Sleep($iSleep)
Next
If Mod($iHeigth - $aWinPos[3],$iStep) Then
If $iStepH < 0 Then
$iStepH = -1
Else
$iStepH = 1
EndIf
For $i = $iLastI -1 To $iHeigth Step $iStepH
WinMove($hWnd,"",Default,Default,Default,$i)
Next
EndIf
EndIf
EndFunc
Und ja, das Teil macht mich süchtig.
Ist aufjedenfall schon ne coole idee, und gut umgesetzt.
Die Idee entwickelt sich. Sehr gut. Dass kann noch was sehr interessantes werden.
Finde es auch sehr interesant und Ausbaufähig.
Mal gespannt was daraus noch wird
Was mir aufgefallen ist.
Wenn ich viel in die Console schreibe, so das man scrollen muss um den text komplett zu sehen dann springt die console immerwieder nach oben wenn ich einen befehl eingebe.
Und während du etwas in die Console schreibst würde ich Blockinput auf 1 setzen da der user sonst noch buchstaben in deinem Text einfügen kann, und das sieht nich gut aus
Gut umgesetz, der Typewriter-effekt ist einfach cool
@All:
Danke für die Kritik
Ich werde mein bestes geben um daraus was ordneliches zu machen
Ansonsten kann ja jeder Funktionen hinzufügen der möchte.
( yxyx: besonders auf deine Gdi+ Funktion werde ich gespannt sein )
Was meinerseits geplant ist
monkey
1. Ist bekannt
2. Gute Idee
Ich werde gleich mal weiter machen.
mfg Ubuntu
Zitat( yxyx: besonders auf deine Gdi+ Funktion werde ich gespannt sein )
ok ich baus dir ein xD