Article View: borland.public.cppbuilder.nativeapi
Article #12300Sending keyboard messages
From: Daniel Delande
Date: Mon, 15 Dec 2003 22:31
Date: Mon, 15 Dec 2003 22:31
26 lines
2190 bytes
2190 bytes
My application has to simulate keystrokes to another application. If the destination window is the foreground window, I can send the messages using keybd_event(). Then I have no problem, even when I have to simulate a Shift key depressed : for instance, to simulate Shift+G, I call keybd_event() 4 times : Shift down, G down, G up and Shift up. That's fine. If the destination window is NOT the foreground window, I have to use something else. I tried SendMessage() (I have a handle to the destination window), and found that the destination application ignores the Shifts. I had the opportunity to hook WindowProc in the destination application, so as to monitor the keyboard messages WM_KEYDOWN, WM_KEYUP and WM_CHAR. I noted the sequence I got hooked when I actually typed the Shift+G sequence (WM_KEYDOWN Shift, WM_KEYDOWN G, WM_CHAR G, WM_KEYUP G and WM_KEYUP Shift) and repeated it in my program (verbatim, including scan codes, etc.). I found exactly the same sequence in the hook procedure, but unfortunatly, the destination application still ignored the Shifts. So, I must miss something, another message ? Several questions regarding keyboard and mouse simulations are posted here, but I could not find the answer, up to now. Daniel Delande
Technical Details
Message-ID:
<3FDE365E.2030501@fnac.net>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,ff1c03795d4b3af5,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-15 14:40:55 PST Message-ID: <3FDE365E.2030501@fnac.net> Date: Mon, 15 Dec 2003 23:31:58 +0100 From: Daniel Delande <d.delande@fnac.net> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: fr-fr, fr, en-us MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Sending keyboard messages Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.167.47.229 X-Trace: newsgroups.borland.com 1071527345 81.167.47.229 (15 Dec 2003 14:29:05 -0700) Lines: 27 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail