Jump to content

enable hotkeys on keyboard scan-codes


jennico
 Share

Recommended Posts

hi there,

for my script (see below) i want to add the option to redefine the keystrokes to unicode characters. the aim is to create a program that can emulate any character you want on any key.

as this should work identically for any OSlang (qwerty-qwertz-aserty, cirillic, arabic keyboards) and the vk_oem keys it would only be possible by hotkeying the scan codes of the keyboard, not the chars, before the kb driver does it.

hotkeyset and _ispressed are not suitable for this purpose. though hotkeyset would be okay if i could rather hotkey the scan code and not the char.

i do not want to remap the keyboard permanantly by adding a registry key. the change should just be temporarily as long as my script runs.

in the forum i read several posts that refer to dlls that are designed to enable this, but all links are broken. imo you just need the user32.dll, but i don't know how.

so anyone advanced who knows about catching scan codes ?

thx

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

found at msdn:

http://msdn2.microsoft.com/en-us/library/ms646307.aspx

MapVirtualKeyEx Function

The MapVirtualKeyEx function translates (maps) a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code. The function translates the codes using the input language and an input locale identifier.

Syntax

UINT MapVirtualKeyEx( UINT uCode,

UINT uMapType,

HKL dwhkl

);

Parameters

uCode

[in] Specifies the virtual-key code or scan code for a key. How this value is interpreted depends on the value of the uMapType parameter.

uMapType

[in] Specifies the translation to perform. The value of this parameter depends on the value of the uCode parameter.

MAPVK_VK_TO_VSC

The uCode parameter is a virtual-key code and is translated into a scan code. If it is a virtual-key code that does not distinguish between left- and right-hand keys, the left-hand scan code is returned. If there is no translation, the function returns 0.

MAPVK_VSC_TO_VK

The uCode parameter is a scan code and is translated into a virtual-key code that does not distinguish between left- and right-hand keys. If there is no translation, the function returns 0.

Windows Vista and later: The high byte of the uCode value can contain either 0xe0 or 0xe1 to specify the extended scan code.

MAPVK_VK_TO_CHAR

The uCode parameter is a virtual-key code and is translated into an unshifted character value in the low order word of the return value. Dead keys (diacritics) are indicated by setting the top bit of the return value. If there is no translation, the function returns 0.

MAPVK_VSC_TO_VK_EX

Windows NT/2000/XP and later: uCode is a scan code and is translated into a virtual-key code that distinguishes between left- and right-hand keys. If there is no translation, the function returns 0.

Windows Vista and later: The high byte of the uCode value can contain either 0xe0 or 0xe1 to specify the extended scan code.

MAPVK_VK_TO_VSC_EX

Windows Vista and later: The uCode parameter is a virtual-key code and is translated into a scan code. If it is a virtual-key code that does not distinguish between left- and right-hand keys, the left-hand scan code is returned. If the scan code is an extended scan code, the high byte of the uCode value can contain either 0xe0 or 0xe1 to specify the extended scan code. If there is no translation, the function returns 0.

dwhkl

[in] Input locale identifier to use for translating the specified code. This parameter can be any input locale identifier previously returned by the LoadKeyboardLayout function.

Return Value

The return value is either a scan code, a virtual-key code, or a character value, depending on the value of uCode and uMapType. If there is no translation, the return value is zero.

Remarks

The input locale identifier is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input.

An application can use MapVirtualKeyEx to translate scan codes to the virtual-key code constants VK_SHIFT, VK_CONTROL, and VK_MENU, and vice versa. These translations do not distinguish between the left and right instances of the SHIFT, CTRL, or ALT keys.

Windows NT/2000/XP: An application can get the scan code corresponding to the left or right instance of one of these keys by calling MapVirtualKeyEx with uCode set to one of the following virtual-key code constants.

VK_LSHIFT

VK_RSHIFT

VK_LCONTROL

VK_RCONTROL

VK_LMENU

VK_RMENU

These left- and right-distinguishing constants are available to an application only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, MapVirtualKey, and MapVirtualKeyEx functions. For list complete table of virtual key codes, see Virtual-Key Codes.

Windows 95/98/Me: MapVirtualKeyExW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems .

Function Information

Minimum DLL Version user32.dll

Header Declared in Winuser.h, include Windows.h

Import library User32.lib

Minimum operating systems Windows 95, Windows NT 4.0

Unicode Implemented as ANSI and Unicode versions.

so there is a way to do it, no ?

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

okay,

the MapVirtualKeyEx Function is a "translator" between virtual key (vk) and scan code (vsc) and implements the local settings and language used. this seems very easy to use with the user32.dll and is exactly what i need.

so please can someone help me making an autoit function out of that ?

thx again

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

okay, i nearly made it on my own. since there is no one talking to me, i will keep my secret. i just want to mention that nearly all of the scan code tables in internet are wrong. this is very weird, but it's true.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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