Konsole

  • Hi @all ich habe dieses jahr mit VC++ ein wenig begonnen und dort gibt es ja die Windows-Konsolen-Andwendung das habe ich haber in auotit nicht gefunden und jetzt habe ich mal ein kleines Script dazu geschreiben mit 9 Funktionen um etwas ähnliches zu schreiben

    Ich hoffe es gefällt euch

    Funktionen
    [autoit]

    ;=================================================================================================
    ; Function: _Konsol_Create
    ; Varibles: $title = Titel der Konsole
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_Create($title,$Hanle)
    Local $hWnd[4]
    $hWnd[0] = GUICreate($title,500,300)
    GUISEtBkColor(0x000000)
    $hWnd[1] = GUICTrlCreateLabel("",10,10,480,200)
    GUICTrlSetColor(-1,0xffffff)
    GUICtrlSetFont($hWnd[1],12)
    $hWnd[2] = GUICtrlCreateInput("",10,200,480,20)
    GUICtrlSETBKColor(-1,0x000000)
    GUICTrlSETColor(-1,0xFFFFFF)
    GUICtrlSEtState($hWnd[2],$GUI_HIDE)
    $hWnd[3] = GUICtrlCreateButton("",10,240,150,30)
    GUICtrlSetState($hWnd[3],$GUI_HIDE)
    GUISwitch ($Hanle)
    Return $hWnd
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_SetText
    ; Varibles: $hWnd = Handel der Konsole von _Konsol_Create
    ; $text = Text der Beschriftung der Konsole
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_SetText($hWnd,$text)
    GUICtrlSetData($hWnd[1],$text)
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_SetInputText
    ; Varibles: $hWnd = handel der _Konsol
    ; $text = Text der in die Input geschrieben werden soll
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_SetInputText($hWnd,$text)
    GUICTrlSEtDATA($hWnd[2],$text)
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_SetState
    ; Varibles: $hWnd = handel der _Konsol_Create
    ; $state = State des Fensters zb. @SW_HIDE und @SW_SHOW
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_SetState ($hWnd,$State)
    GUISetState($State,$hWnd[0])
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_CreateInput
    ; Varibles: $hWnd = Handel der _Konsol_Create
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_CreateInput($hWnd)
    GUICtrlSETState($hWnd[2],$GUI_SHOW)
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_DeleteInput
    ; Varibles: $hWnd = Handel der _Konsol_Create
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_DeleteInput($hWnd)
    GUICtrlSEtState($hWnd[2],$GUI_HIDE)
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_CreateButton
    ; Varibles: $hWnd = Handel der _Konsol_Create
    ; $text = Text mit dem der Button beschriftet werden soll
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_CreateButton($hWnd,$text = "Ok")
    GUICtrlSetState($hWnd[3],$GUI_SHOW)
    GUICtrlSetData($hWnd[3],$text)
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_DeleteButton
    ; Varibles: $hWnd = Handel der _Konsol_Create
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_DeleteButton($hWnd)
    GUICtrlSetState($hWnd[3],$GUI_HIDE)
    EndFunc
    ;=================================================================================================
    ; Function: _Konsol_Read
    ; Varibles: $hWnd = Handel der _Konsol_Create
    ; Author: SB
    ;=================================================================================================
    Func _Konsol_Read($hWnd)
    $readen = GUICtrlRead($hWnd[2])
    return $readen
    EndFunc
    ;ein danke an Jam00

    [/autoit]
    Beispiel
    [autoit]

    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $hWnd = GUICreate("GUI",300,300)
    $info = GUICtrlCreateButton("Info",10,10)
    GUISETSTATE()
    $Konsole = _Konsol_Create("Beispielconsole",$hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGETMSG(1)
    Switch $nMsg[1]
    Case $hWnd
    Switch $nMsg[0]
    Case -3
    Exit
    Case $info
    _Konsol_SetState($Konsole,@SW_SHOW)
    _Konsol_SetText($Konsole,"Hallo")
    _Konsol_SetInputText($Konsole,"Dies ist der Input Text")
    _Konsol_CreateInput($Konsole)
    _Konsol_CreateButton($Konsole,"Hallo ich bin der Button")
    EndSwitch
    Case $Konsole[0]
    Switch $nMsg[0]
    Case -3
    _Konsol_SetState($Konsole,@SW_HIDE)
    Case $Konsole[3]
    $read = _Konsol_Read($Konsole)
    MsgBox(0,""," In der Input steht:" & @CRLF & '"' & $read & '"')
    EndSwitch
    EndSwitch

    WEnd

    [/autoit]

    Ich hoffe es kann jemand gebrauchen

    Einmal editiert, zuletzt von simon (3. Mai 2009 um 11:35)

  • gute arbeit, aber es gibt doch

    [autoit]

    ConsoleWrite()

    [/autoit]


    und

    [autoit]

    Consoleread()

    [/autoit]


    bereits :)

  • Ja ber das hat damit nichts zu tun da consolwrite und consolread werte in einen texteditor schreibenabe eine windows-consolen-anwendung ist ein fenster in dem Texte stehen
    Konsolenanwendungen im VC++ ist ein schwarzes fenster ohne allem an Grafik nu weiser Text eingaben und Ausgaben

  • ich weiß was konsolenanwendungen sind^^
    aber da es in c++ so ähnlich heißt (ich glaub console.writeline) wie

    [autoit]

    Consolewrite()

    [/autoit]

    in autoit, dachte ich es wäre das selbe^^ (hab das garnich ausprobiert xD)

  • Oder einfach mir run eine Console aufrufen.

    Spoiler anzeigen

    To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE) ; don't forget " " before "/c"

    MfG
    Der_Doc

  • Damit kann man nur DOS-Kommandos ausführen, kein Kommandozeilenprogramm erstellen o.ä.
    Ich hab selbst mal so etwas ähnliches gemacht (ich wollt CMD nachbauen)
    Hier ist der Versuch (vielleicht will ihn iwer ausbauen? :D)
    autoit.de/wcf/attachment/4628/

    Padmak

  • Hups sry du hast recht :D
    Hier is die Funk die wichtig ist^^:

    Spoiler anzeigen
    [autoit]


    Func _IsAnyKeyPressed($vDLL = 'user32.dll')
    If __KeyPressCheck(1, 221, -1, $vDLL) Then Return 1
    Return 0
    EndFunc ;==>_IsAnyKeyPressed
    Func __KeyPressCheck($iStart, $iFinish, $iHexKey = -1, $vDLL = 'user32.dll')
    Local $ikey, $ia_R
    For $ikey = $iStart To $iFinish
    If $iHexKey == -1 Then $ia_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & Hex($ikey, 2))
    If $iHexKey <> -1 Then $ia_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $iHexKey)
    If Not @error And BitAND($ia_R[0], 0x8000) = 0x8000 Then Return 1
    Next
    Return 0
    EndFunc ;==>__KeyPressCheck

    [/autoit]


    (wollt jetzt net hochladen^^)

    Dein Versuch ist auch nicht schlecht aber du hast genauso wie ich schon lang nix mehr dran gemacht oder :D
    Allein von der Realität find ich meine passt besser^^
    Warum nimmst du das Home-Verzeichnis und nicht die Workingdir? Verwirrt doch bloß oO
    Aber ich find beide schön^^
    (aber dein grün ist hässlich :D:D:D)

    Padmak

    Edit: So ich hoff jetzt passts^^

    Einmal editiert, zuletzt von Padmak (3. Mai 2009 um 09:43)

  • Ok ich werde in der Nächsten Version befehle einbauen und es umprogrammieren das das _Konsol_SetInputText wegfält und das _Konsol_SetText

  • Ist interessant^^
    aber wenn du vielleicht kurz erklären könntest was man damit eigenlich machen kann?^^
    Ich find jetzt keinen Verwendungszweck sorry

    Padmak

  • @Padmak In den nächsten verisonen werden befehle integriert und somit wird was ausgeführt und es wird sich mehr an der Windows Konsole orientieren aber bis ich die version habe wird es wohl noch eine weile dauern

  • Ahso ok
    ich konnt nur jez nix damit anfangen^^
    Also so ähnlich wie von Jam und mir oder?

    Padmak

  • Ich weis nicht ich habe die von Jam00 noch nicht gesehen und anders als deine (Padmak) wird sie schon