Hi Gerhard,
> for a phone dial by our app, we have to do a keyboard simulation.
> Therefor I found the WIN32 function SendInput(). Has somebody a sample
> with VO to do this?
it seems that it´s neccesarry to create a UNION. Here´s what i did so far:
UNION _UnionSendInput
MEMBER mi IS _WINMOUSEINPUT
MEMBER ki IS _winKEYBDINPUT
MEMBER hi IS _winHARDWAREINPUT
STRUCTURE _winINPUT
MEMBER type AS DWORD
MEMBER Input IS _UnionSendInput // <-------
/*
MEMBER mi IS _WINMOUSEINPUT
MEMBER ki IS _winKEYBDINPUT
MEMBER hi IS _winHARDWAREINPUT
*/
STRUCTURE _winHARDWAREINPUT
MEMBER uMsg AS DWORD
MEMBER wParamL AS WORD
MEMBER wParamH AS WORD
STRUCTURE _winKEYBDINPUT
MEMBER wVk AS WORD
MEMBER wScan AS WORD
MEMBER dwFlags AS DWORD
MEMBER time AS DWORD
MEMBER dwExtraInfo AS _WINULARGE_INTEGER // ULONG_PTR ???
STRUCTURE _WINMOUSEINPUT
MEMBER dx AS LONG
MEMBER dy AS LONG
MEMBER mouseData AS DWORD
MEMBER dwFlags AS DWORD
MEMBER time AS DWORD
MEMBER dwExtraInfo AS _WINULARGE_INTEGER // ULONG_PTR ????
DEFINE INPUT_MOUSE := 0 // The event IS a mouse event. Use the mi STRUCTURE
OF the UNION.
DEFINE INPUT_KEYBOARD := 1 // The event IS a keyboard event. Use the ki
STRUCTURE OF the UNION.
DEFINE INPUT_HARDWARE := 2 // The event is a hardware event. Use the hi
structure of the union.
_DLL FUNCTION SendInput ( nInputs AS DWORD , pInputs AS _winINPUT , cbSize
AS INT ) AS DWORD PASCAL:User32.SendInput
-----------------------------------
about the dwExtraInfo member i´m not sure if it´s correct, but at least this
sample works for me. It opens here a Submenu via
<Alt> + L. Without using the UNION SendInPut() fails with the errorcode
87 -> ERROR_INVALID_PARAMETER
----------------------
FUNCTION TestKeyboardSendInPut() AS VOID
LOCAL ip IS _winINPUT
LOCAL dwError AS DWORD
ip.type := INPUT_KEYBOARD
ip.Input.ki.wScan := 0
ip.Input.ki.time := 0
ip.Input.ki.dwExtraInfo := 0
// -----------------------
// Press "Alt" key
ip.Input.ki.wVk := VK_MENU
ip.Input.ki.dwFlags := 0 // 0 for key press
SendInput(1, @ip, _SIZEOF( _winINPUT))
// Press "L" key
ip.Input.ki.wVk := WORD ( Asc ( "L" ))
ip.Input.ki.dwFlags := 0 // 0 for key press
SendInput(1, @ip, _SIZEOF( _winINPUT))
// Release the "L" key
ip.Input.ki.wVk := WORD ( Asc ( "L" ) )
ip.Input.ki.dwFlags := KEYEVENTF_KEYUP
SendInput(1, @ip, _SIZEOF( _winINPUT))
// Release the "Alt" key
ip.Input.ki.wVk := VK_MENU
ip.Input.ki.dwFlags := KEYEVENTF_KEYUP
IF SendInput(1, @ip, _SIZEOF( _winINPUT)) == 0
dwError := GetLastError()
MsgInfo ( NTrim ( dwError ) + crlf + ErrString ( dwError ) )
ENDIF
//
RETURN
regards
Karl-Heinz