🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15193

Re: Keybd_event problems

#15193
From: JD
Date: Fri, 18 Jul 2003 10:02
31 lines
1857 bytes
"Henry" <eangelo@libero.it> wrote:
> I am trying to programmatically generate keyboard strokes
> [...] My problem is: if I try to generate characters other
> then "A-Z" and "0-9", the "keyboard_event" does not work
> correctly. The following code:
>
>       keybd_event('+', 0, 0, 0);
>       keybd_event('+', 0, KEYEVENTF_KEYUP, 0);
>
>does not work.

I just used an OnKeyDown event to catch the '+' keypress.
Turns out that when your code executes, the Key value is 43
but if you manually press the plus symbol the Key value is 107.

If you replace '+' with 107, your code performs as expected.
You should note that according to the win32 docs, the first
parameter is a virtual key value and that:

       43 = 0010 1011
      107 = 0110 1011

So ....

    keybd_event( '+' | 0x40, 0, 0, 0);
    keybd_event( '+' | 0x40, 0, KEYEVENTF_KEYUP, 0);

also produces the desired results.

~ JD
Technical Details
Message-ID: <3f17c5c8$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-08!supernews.com!newsfeed.news2me.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f17a276@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,f99436c531b1645c
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-18 03:12:03 PST
From: "JD" <nospam@nospam.com>
Sender: "JD" <nospam@nospam.com>
Reply-To: "JD" <nospam@nospam.com>
Subject: Re: Keybd_event problems
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 172.203.129.169 172.203.129.169    
References:  <3f17a276@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3f17c5c8$1@newsgroups.borland.com>
Date: 18 Jul 2003 03:02:48 -0700
X-Trace: newsgroups.borland.com 1058522568 207.105.83.65 (18 Jul 2003 03:02:48 -0700)
Lines: 32
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-08!supernews.com!newsfeed.news2me.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail