Jump to content

Get chr from virtual key (wparam and Lparam)


Recommended Posts

in some api call we got a wparm (wparm is a virtual key according to MS SDK) as a returned result

Most Win32 api functions involve <b>Wparam</b> and <b> Lparam</b> to send and receive information.

There are api functions to map VK_KEYS to keyboard layout.

If it has to do with autoIt though you'll have to be more specific so those guys can point you in the right direction.

Link to comment
Share on other sites

mmm... try this

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 
Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

...i didnt write this, im not gonna take credit for. i dont knwo who did

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

Here a short description about what I mean:

It is a API function that return a Wparam and Lparam : here is a prototype:

LRESULT CALLBACK KeyboardProc(

int code,

WPARAM wParam,

LPARAM lParam

);

wParam

[in] Specifies the virtual-key code of the key that generated the keystroke message.

lParam

[in] Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. For more information about the lParam parameter, see Keystroke Message Flags. This parameter can be one or more of the following values.

0-15

Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key.

16-23

Specifies the scan code. The value depends on the OEM.

24

Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0.

25-28

Reserved.

29

Specifies the context code. The value is 1 if the ALT key is down; otherwise, it is 0.

30

Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up.

31

Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released.

So my question is How to convert returned Data (ie Wparam and L param) to a char ?

Hope it is clear know and thinks a lot for any help

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...