Text an ein Fenster senden

  • Hi

    Mein Handicap ist das ich Querschnitt gelähmt bin und ich kann nur mit der Softwaretastatur schreiben/chaten usw...
    Wenn ich im Gamechat etwas schreiben will wird oft die Softwaretastatur nicht erkannt und der klick auf die Tastatur wird als klick ins Game gesendet
    also hab ich keine chace zu chaten, und das in einem Onlinegame. hmmmm
    Das ist nicht so der Hammer.

    Ich bräuchte also ein Programm mit

    Einer Textbox und Ein Button.

    Genauer gesagt

    Ich schreibe etwas in die Textbox
    Mit dem Button wird nun der Text in den Gamechat eingefügt und abgeschickt.

    und zwar an dieses Fenster

    >>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
    Entropia Universe Client
    ahk_class CryENGINE

    zum öffnen des chat und zum absenden braucht es jeweils ein enter.

    Thx im voraus.
    Ps.: Toll währe wenn ich auch ein paar Texte speicher könnte. zb. thx 4 heal oder so

    3 Mal editiert, zuletzt von Tester75 (11. Juli 2010 um 15:25)

  • Also ich kenne zwar nicht das Spiel, aber du könntest es mal so versuchen:

    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 463, 123, 192, 124)
    $Edit1 = GUICtrlCreateEdit("", 8, 8, 257, 105)
    GUICtrlSetData(-1, "Text")
    $Button1 = GUICtrlCreateButton("Senden", 272, 8, 97, 25, $WS_GROUP)
    $Group1 = GUICtrlCreateGroup("Fenstertitel", 272, 32, 185, 57)
    $Input1 = GUICtrlCreateInput("Entropia Universe Client", 280, 56, 169, 21)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Checkbox1 = GUICtrlCreateCheckbox("Immer im Vordergrund", 272, 96, 185, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Button1
    $titel=GUICtrlRead($Input1)
    sleep(4000)
    If WinExists($titel) Then
    ControlSend($titel,"","",GUICtrlRead($Edit1))
    ControlSend($titel,"","","{ENTER}")
    Else
    MsgBox(16,"Fehler","Das Fenster existiert nicht")
    Endif
    Case $Checkbox1
    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
    WinSetOnTop ( $Form1, "", 1 )
    Else
    WinSetOnTop ( $Form1, "", 0 )
    Endif
    EndSwitch
    WEnd

    [/autoit]

    Eventuell noch die Tasten die vor / nach dem Klick gedrückt werden ändern^^

  • ja thx

    es funkt zum teil. Also den chat muss ich selber öffnen aber das is nicht schlimm.

    Der Text wird eingefügt aber er macht kein enter.

    Könnte man vieleicht noch ein Button für Enter und einen für Backspace einfügen.

    Wenn ich auf der Tastatur Enter drücke schliesst sich der chat nur.

    Könntest du noch ein paar Kommentare dazu schreiben dass ein Noob wie ich es auch kapiere was die Befehle bewirken.

    THX Vielmals

  • Spoiler anzeigen
    [autoit]


    ; send single keyboard event to non active window
    ; event = pressed, down, up
    ; kdown = key down delay
    ; note: supports only lower case keys + NUMx, Fx, some special keys and @
    Func KeySend($hwnd, $inkey, $evt ="pressed", $kdown = 50)
    $user32 = DllOpen("user32.dll")
    if $user32 = -1 Then
    ConsoleWrite("KeySend: cannot open user32.dll")
    Exit
    EndIf

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

    ; handling for special keys
    Switch StringUpper($inkey)
    Case "@"
    $skey = 0x40
    $lparam = 0x00100001
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", 0x71, "long", $lparam)
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_CHAR, "int", $skey, "long", $lparam)
    Sleep(20)
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", 0x71, "long", BitOR($lparam, 0xC0000000))
    Case "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"
    $skey = 0x6f + Int(StringMid($inkey, 2))
    ContinueCase
    Case "NUM0", "NUM1", "NUM2", "NUM3", "NUM4", "NUM5", "NUM6", "NUM7", "NUM8" , "NUM9"
    if StringUpper(StringLeft($inkey, 3)) = "NUM" Then
    $skey = 0x60 + Int(StringMid($inkey, 4))
    EndIf
    ContinueCase
    Case "RETURN", "SPACE", "TAB", "BACK", "END", "HOME", "SNAPSHOT", "INSERT", "DELETE", "LEFT", "RIGHT", "UP", "DOWN"
    Switch StringUpper($inkey)
    Case "RETURN"
    $skey = 0x0D
    Case "SPACE"
    $skey = 0x20
    Case "TAB"
    $skey = 0x09
    Case "BACK"
    $skey = 0x08
    Case "END"
    $skey = 0x23
    Case "HOME"
    $skey = 0x24
    Case "SNAPSHOT"
    $skey = 0x2c
    Case "INSERT"
    $skey = 0x2d
    Case "DELETE"
    $skey = 0x2e
    Case "LEFT"
    $skey = 0x25
    Case "RIGHT"
    $skey = 0x27
    Case "UP"
    $skey = 0x26
    Case "DOWN"
    $skey = 0x28
    EndSwitch
    $ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
    $lparam = BitShift($ret[0], -16)
    $lparam = BitOr($lparam, 1)
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
    Sleep($kdown)
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
    Case Else ; default lower case key handling
    $key = DllCall($user32, "int", "VkKeyScan", "int", Asc(StringLower($inkey)))
    $skey = $key[0]
    $ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
    $lparam = BitShift($ret[0], -16)
    $lparam = BitOr($lparam, 1)
    Select
    Case $evt = "pressed"
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
    Sleep($kdown)
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
    Case $evt = "down"
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
    Case $evt = "up"
    DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
    EndSelect
    EndSwitch

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

    DllClose($user32)
    EndFunc

    [/autoit]

    Alternative zu ControlSend und sollte überall laufen

  • Ich hab bei zeile 11 noch ein Button hinzugefügt

    [autoit]


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 463, 123, 192, 124)
    $Edit1 = GUICtrlCreateEdit("", 8, 8, 257, 105)
    GUICtrlSetData(-1, "Text")
    $Button1 = GUICtrlCreateButton("Senden", 272, 8, 97, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Enter", 372, 8, 97, 25, $WS_GROUP) ; << (neu) hoffe das stimmt.
    ;Wie kann ich dem Button die enter Funktion zuweisen?
    $Group1 = GUICtrlCreateGroup("Fenstertitel", 272, 32, 185, 57)
    $Input1 = GUICtrlCreateInput("Entropia Universe Client", 280, 56, 169, 21)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Checkbox1 = GUICtrlCreateCheckbox("Immer im Vordergrund", 272, 96, 185, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Button1
    $titel=GUICtrlRead($Input1)
    sleep(4000)
    If WinExists($titel) Then
    ControlSend($titel,"","",GUICtrlRead($Edit1))
    ControlSend($titel,"","","{ENTER}")
    Else
    MsgBox(16,"Fehler","Das Fenster existiert nicht")
    Endif
    Case $Checkbox1
    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
    WinSetOnTop ( $Form1, "", 1 )
    Else
    WinSetOnTop ( $Form1, "", 0 )
    Endif
    EndSwitch
    WEnd

    [/autoit]
  • Ja das einfügen funktioniert einwandfrei aber vor dem einfügen müsste erst Enter gedrückt werden (um das chatfenster zu öffnen), dann erst einfügen und nochmals enter zum absenden.

    Die Enterfunkion will aber nicht recht

  • mit sleep gehts auch nicht und wen ich

    [autoit]


    If WinExists($titel) Then
    ControlSend($titel,"","",GUICtrlRead($Edit1))
    Sleep(10)
    Send("{ENTER}")

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


    mach,dann schreibt er den Text als Schlaufe in den Chat macht aber kein Enter.