🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages Started by Emmanuel Wed, 24 Oct 2007 06:12
How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1119
Author: Emmanuel
Date: Wed, 24 Oct 2007 06:12
33 lines
1985 bytes
Dear All,
I meet a problem again
I want to make a effect to control the keyboard input
press SHIFT, and press Right Arrow
for example to select a text
by the code
 step 1: keybd_event(VK_SHIFT, 0, 0,0);
 step 2: keybd_event(39, 0, 0,0);
 step 3: keybd_event(39, 0, KEYEVENTF_KEYUP,0);
 step 4: keybd_event(39, 0, 0,0);
 step 5: keybd_event(39, 0, KEYEVENTF_KEYUP,0);
 step 6: keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP,0);

but I find that when process step 2,
the application auto recieve a keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP,0); 
signal,
such that the step 1 is useless,

 step 1: keybd_event(VK_SHIFT, 0, 0,0);
         keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP,0);
 step 2: keybd_event(39, 0, 0,0);
 step 3: keybd_event(39, 0, KEYEVENTF_KEYUP,0);
 step 4: keybd_event(39, 0, 0,0);
 step 5: keybd_event(39, 0, KEYEVENTF_KEYUP,0);
 step 6: keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP,0);

How can I send a message to the keyboard
 keybd_event(VK_SHIFT, 0, 0,0);
 keybd_event(39, 0, 0,0);
 such that the keyboard know that the key "Shift + Right Arrow" are pressed 
as the same time?

Thank
Re: How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1022
Author: Emmanuel
Date: Mon, 05 Nov 2007 04:17
1 lines
1025 bytes
No any idea? 
Re: How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1021
Author: Ed Mulroy [TeamB]
Date: Mon, 05 Nov 2007 04:25
8 lines
1238 bytes
Look at the function GetKeyboardState

.  Ed

> Emmanuel wrote in message
> news:472e9911@newsgroups.borland.com...
>
> No any idea?
Re: How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1027
Author: Emmanuel
Date: Mon, 05 Nov 2007 12:36
14 lines
1460 bytes
I have already tested that, it is useless for GetKeyboardState or 
SetKeyboardState

"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> д����Ϣ����:472e9b4b$1@newsgroups.borland.com...
> Look at the function GetKeyboardState
>
> .  Ed
>
>> Emmanuel wrote in message
>> news:472e9911@newsgroups.borland.com...
>>
>> No any idea?
>
> 
Re: How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1028
Author: Ed Mulroy [TeamB]
Date: Mon, 05 Nov 2007 14:38
9 lines
1260 bytes
Ok, then use GetAsyncKeyState.

.  Ed

> Emmanuel wrote in message
> news:472f0ded$1@newsgroups.borland.com...
>
>I have already tested that, it is useless for GetKeyboardState or 
>SetKeyboardState
Re: How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1029
Author: Asger Jørgensen
Date: Mon, 05 Nov 2007 18:02
33 lines
1969 bytes
Hi Emmanuel 

In article <472e9911@newsgroups.borland.com> 
emmanuel@erphk.com 
 Emmanuel says:
> No any idea? 

I don't know how to fix it, but Your theori about
what is going on is wrong.

   keybd_event(VK_SHIFT, 0, 0,0);
   keybd_event(VK_RIGHT, 0, 0,0);
   keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP,0);
   Application->ProcessMessages();
   Sleep(500);
   keybd_event(VK_RIGHT, 0, 0,0);
   keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP,0);
   Application->ProcessMessages();
   Sleep(500);
   if (GetAsyncKeyState(VK_SHIFT)&0x8000)
      Beep(400,100);
   //keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP,0);

if You run this code You will hear a beep and You will
see that the text will be selected if You press the right 
arrow on the keyboard, so the shiftkey is down.
Why it doen't select the text when You aoutgenerate the
the right arrow keypress i don't know.

Kind regards
Asger
 
Re: How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1030
Author: Emmanuel
Date: Tue, 06 Nov 2007 01:51
41 lines
2223 bytes
: (
I can hear a beep;
but It still cannot select text by the code, I can only select text by 
typing arrow

I am using Windows XP Simple Chinese , C++builder 6

"Asger J?rgensen" <junk@Asger-P.dk> д����Ϣ����:MPG.2199791d4a8fd91698988e@newsgroups.borland.com...
>
> Hi Emmanuel
>
> In article <472e9911@newsgroups.borland.com>
> emmanuel@erphk.com
> Emmanuel says:
>> No any idea?
>
> I don't know how to fix it, but Your theori about
> what is going on is wrong.
>
>   keybd_event(VK_SHIFT, 0, 0,0);
>   keybd_event(VK_RIGHT, 0, 0,0);
>   keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP,0);
>   Application->ProcessMessages();
>   Sleep(500);
>   keybd_event(VK_RIGHT, 0, 0,0);
>   keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP,0);
>   Application->ProcessMessages();
>   Sleep(500);
>   if (GetAsyncKeyState(VK_SHIFT)&0x8000)
>      Beep(400,100);
>   //keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP,0);
>
> if You run this code You will hear a beep and You will
> see that the text will be selected if You press the right
> arrow on the keyboard, so the shiftkey is down.
> Why it doen't select the text when You aoutgenerate the
> the right arrow keypress i don't know.
>
> Kind regards
> Asger
> 
Re: How can keyboard know that the key "Shift + Right Arrow"are pressed as the same time?
#1031
Author: Asger Jørgensen
Date: Tue, 06 Nov 2007 10:35
25 lines
1704 bytes
Hi Emmanuel 

In article <472fc864$1@newsgroups.borland.com> 
emmanuel@erphk.com 
 Emmanuel says:
> : (
> I can hear a beep;
> but It still cannot select text by the code, I can only select text by 
> typing arrow
> 
> I am using Windows XP Simple Chinese , C++builder 6

Mine is XP Danish BCB5

So I dont think it has anything to do with this.

But couldn't You find another solution for selecting 
text, have a look at SelStart and SelLength or the
EM_SETSEL message.

What is it You are trying to do ??

Kind regards
Asger
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads