Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Karl-Heinz" Newsgroups: comp.lang.clipper.visual-objects Subject: Re: Sample for SendInput() ? Date: Tue, 31 Jul 2018 16:11:11 +0200 Lines: 108 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=original Content-Transfer-Encoding: 8bit X-Trace: individual.net 5cJvhXIjSXhWupvFPk25BQI7I0SN8R2ImP/l57+75fl5Glukg= Cancel-Lock: sha1:ES3fNHAD1J3fIFqpcQqqjeB8GVM= In-Reply-To: X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3564.1216 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3564.1216 Xref: csiph.com comp.lang.clipper.visual-objects:11790 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 + . 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