Jump to content

Send To Edit With Dllcall ?!


Recommended Posts

i found this code to send key to a window trought dllcall but how can i send the text or key to a "Edit1" Control in the window?

what do i have to change in the code?

i dont know anything about dllcall so anyone can help me with this?

Global Const $VK_OEM_PLUS = 0xBB
Global Const $VK_OEM_MINUS = 0xBD
Global Const $VK_OEM_3 = 0xC0
Global Const $VK_TAB = 0x9
Global Const $VK_ESC = 0x1B
Global Const $VK_F5 = 0x74
Global Const $VK_F12 = 0x7B

$window = WinGetTitle("")
Dim $hWnd = WingetHandle( $window )


_SendKeys($hWnd, "123123123"); using send keys





Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc 
Func _SendKeys($hWnd, $keys)
    If $hWnd <= 0 Or StringLen($keys) = 0 Then
        SetError(-1)
        Return False
    EndIf
    $keys = StringUpper($keys)
    $keys = StringReplace($keys, "`", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "~", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "-", Chr($VK_OEM_MINUS))
    $keys = StringReplace($keys, "=", Chr($VK_OEM_PLUS))
    $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
    $keys = StringReplace($keys, "{TAB}", Chr(0x9))
    $keys = StringReplace($keys, "{ESC}", Chr($VK_ESC))
    $keys = StringReplace($keys, "{F5}", Chr($VK_F5))
    $keys = StringReplace($keys, "{F12}", Chr($VK_F12))
    $keys = StringReplace($keys, "{SHIFT}", "+")
    Local $i, $ret
    Local $shiftdown = False
    For $i = 1 To StringLen($keys)
        If StringMid($keys, $i, 1) = "+" Then
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
            $shiftdown = True
            Sleep(1)
            ContinueLoop
        Else
            $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
            If IsArray($ret) Then
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
                Sleep(1)
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
            EndIf
        EndIf
        If $shiftdown Then
            Sleep(1)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
            $shiftdown = False
        EndIf
    Next
    Return True
EndFunc
Edited by ljkkda
Link to comment
Share on other sites

i.e.

Global Const $VK_OEM_PLUS = 0xBB
Global Const $VK_OEM_MINUS = 0xBD
Global Const $VK_OEM_3 = 0xC0
Global Const $VK_TAB = 0x9
Global Const $VK_ESC = 0x1B
Global Const $VK_F5 = 0x74
Global Const $VK_F12 = 0x7B

Run("notepad")
WinWaitActive("Untitled")
$window = WinGetTitle("Untitled")
Dim $hWnd = ControlGetHandle($window,"","Edit1")


_SendKeys($hWnd, "123123123"); using send keys





Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc 
Func _SendKeys($hWnd, $keys)
    If $hWnd <= 0 Or StringLen($keys) = 0 Then
        SetError(-1)
        Return False
    EndIf
    $keys = StringUpper($keys)
    $keys = StringReplace($keys, "`", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "~", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "-", Chr($VK_OEM_MINUS))
    $keys = StringReplace($keys, "=", Chr($VK_OEM_PLUS))
    $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
    $keys = StringReplace($keys, "{TAB}", Chr(0x9))
    $keys = StringReplace($keys, "{ESC}", Chr($VK_ESC))
    $keys = StringReplace($keys, "{F5}", Chr($VK_F5))
    $keys = StringReplace($keys, "{F12}", Chr($VK_F12))
    $keys = StringReplace($keys, "{SHIFT}", "+")
    Local $i, $ret
    Local $shiftdown = False
    For $i = 1 To StringLen($keys)
        If StringMid($keys, $i, 1) = "+" Then
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
            $shiftdown = True
            Sleep(1)
            ContinueLoop
        Else
            $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
            If IsArray($ret) Then
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
                Sleep(1)
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
            EndIf
        EndIf
        If $shiftdown Then
            Sleep(1)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
            $shiftdown = False
        EndIf
    Next
    Return True
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

guys is it impossible to send trought the user 32.dll to this 3 contrl´s ?!

http://www.knuddels.de/applet_old.html?c=-3

i test now 4 - 5 days and nothing will work

please can anybody help me with that

That happens with java scripts.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

that means its impossible with autoit?

^^^ Free Bump, but at least peeps will see the post being deleted and re posted over and over for the bump :) Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...