Senden an Java-Application

  • Hallo.

    Wie sende ich Tasten an eine Java-Anwendung?
    Also hab geschafft, dort in ein Editfeld einen Text einzufügen, jedoch klappt es nicht per ControlSend, ein {ENTER} zu simulieren.

    Handle stimmt alles, Text mit ControlSetText funktioniert, nur die Enter nicht :(


    Danke,
    Schrubber

  • Poste mal dein Code.
    Bin mir nicht sicher, ob da alle Funktionen auch mit Java Programme funktionsfähig sind.

  • probier mal das:

    [autoit]


    $hWnd = Controlgethandle("Fenster","","ControlID")
    ssend($hWnd,"Ich bin ein Text!")
    ssend($hWnd,"0D",1) ; Enter

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

    ; #FUNCTION# ======================================================================================
    ; Name ..........: ssend()
    ; Description ...: Sends a string to a specified Control
    ; Syntax ........: ssend($hWnd, $sString[, $iHex = 0[, $bSendMsg = True]])
    ; Parameters ....: $hWnd - Control Handle to send to.
    ; $sString - String to send
    ; $iHex - [optional] Determines wether you want to send pure hex, or not. (default:0)
    ; |This can be handy, if you want to send special keystrokes like ENTER (0D)
    ; |0 - Convert String to Hex first
    ; |1 - Do not convert string to Hex
    ; $bSendMsg - [optional] Determines weither you want to send WM_SETFOCUS and WM_ACTIVATE messages beforehand. (default:False)
    ; Return values .: On Success - Returns 1
    ; On Failure - Returns 0 and sets @error to
    ; |-1 $hWnd is not a Hwnd-Type var.
    ; |>1 error(s) occured when trying to send string
    ; Author ........: hamburger, modified by SEuBo
    ; =================================================================================================
    Func ssend($hWnd, $sString, $iHex = 0, $bSendMsg = False)
    If Not IsHWnd($hWnd) Then Return SetError(-1, 0, 0)
    Local $aPar, $aText, $iErr

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

    ; 1. Get Parent Window. 2. Send WM_ACTIVATE to Parent. 3. Send WM_SETFOCUS to Control.
    If $bSendMsg Then
    $aPar = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hWnd)
    If @error Then Dim $aPar[1] = [WinGetHandle("Program Manager")]
    _SendMessage($aPar[0], 0x0006, $sString, 0, 0, "int", "long")
    _SendMessage($hWnd, 0x7)
    EndIf

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

    ; Send WM_CHAR messages to Control.
    If $iHex Then _SendMessage($hWnd, 0x102, $sString, 0, 0, "int", "long")
    If @error Then $iErr +=1
    If Not $iHex Then
    $aText = StringSplit($sString, "", 3)
    For $i = 0 To UBound($aText) - 1
    _SendMessage($hWnd, 0x102, "0x" & Hex(StringToBinary($aText[$i])), 0, 0, "int", "long")
    If @error Then $iErr +=1
    Next
    EndIf

    If $iErr Then Return SetError($iErr,0,0)
    Return SetError(0,0,1)
    ;~ _SendMessage($hwnd, 0x8)
    EndFunc ;==>ssend

    [/autoit]