Function Reference


_WinAPI_GetKeyNameText

Retrieves a string that represents the name of a key

#include <WinAPISys.au3>
_WinAPI_GetKeyNameText ( $lParam )

Parameters

$lParam Specifies the second parameter of the keyboard message (such as WM_KEYDOWN) to be processed.

Return Value

Success: String containing the name of the key.
Failure: Empty string, call _WinAPI_GetLastError() to get extended error information.

Remarks

The format of the key-name string depends on the current keyboard layout. The keyboard driver maintains a list
of names in the form of character strings for keys with names longer than a single character. The key name
is translated according to the layout of the currently installed keyboard, thus the function may give different
results for different input locales. The name of a character key is the character itself. The names of dead
keys are spelled out in full.

See Also

Search GetKeyNameText in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
GUIRegisterMsg($WM_KEYDOWN, 'WM_KEYDOWN')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_KEYDOWN($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam

        ConsoleWrite(_WinAPI_GetKeyNameText($lParam) & @CRLF)
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_KEYDOWN