Solved

for msac_m

Posted on 1998-11-19
3
136 Views
Last Modified: 2010-04-04
Do you know the right parameter for keybd_event function
because i don't understand how to simulate pressing
two keys(for example ctrl and C) simultaneously.
Virtual codes include only one key.
                                            Thanks
0
Comment
Question by:jpenev3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
ahalya earned 10 total points
ID: 1347330
you use a keyboard buffer (just like an array) and then check for keys that are down.
the following code should get you going, i'd guess.


var buf : TKeyboardState;

begin
GetKeyboardState(Buf);

SpeedButton1.Down := (Buf[vk_Shift]   And 128) <> 0;
SpeedButton2.Down := (Buf[vk_Control] And 128) <> 0;
SpeedButton3.Down := (Buf[vk_Menu]    And 128) <> 0;

SpeedButton4.Down := (Buf[vk_NUMLOCK]    And 128) <> 0;
update;

0
 

Expert Comment

by:msac_m
ID: 1347331
Hi jpenev3,

 I saw your question today ,
I will write some code and send to you.


Regards

   
0
 

Expert Comment

by:msac_m
ID: 1347332
Hi  jpenev3,
This is My Unit,


// Unit Begins Here

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
Var
      dwFlags: DWORD;
begin
//     if(isUpDownSt=1) then //KEYUP
//        dwFlags:= dwFlags or KEYEVENTF_KEYUP;
     Memo1.SetFocus;
     dwFlags:= 0;
     keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), dwFlags, 0);
     keybd_event(ord('C'), MapVirtualKey(ord('C'), 0), dwFlags, 0);
     dwFlags:= KEYEVENTF_KEYUP;
     keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), dwFlags, 0);
     keybd_event(ord('C'), MapVirtualKey(ord('C'), 0), dwFlags, 0);
     Application.ProcessMessages;
end;


procedure TForm1.Button2Click(Sender: TObject);
Var
      dwFlags: DWORD;
begin

     Memo1.SetFocus;
     Memo1.Lines.Add('NewLine');
     dwFlags:= 0;
     keybd_event(VK_CONTROL,      MapVirtualKey(VK_CONTROL, 0), dwFlags, 0);
     keybd_event(ord('V'), MapVirtualKey(ord('V'), 0), dwFlags, 0);
     dwFlags:= KEYEVENTF_KEYUP;
     keybd_event(VK_CONTROL,      MapVirtualKey(VK_CONTROL, 0), dwFlags, 0);
     keybd_event(ord('V'), MapVirtualKey(ord('V'), 0), dwFlags, 0);
     Application.ProcessMessages;
end;

end.
// END OF THE UNIT.


1- Open a new application put two buttons,
2- Drag a Memo on the form.
3- Assign the button click events.
4-Run The Application
5- Write Something into the memo and select your writings.
6- press button1 to copy the selected,
7-Press button2 to paste them into the memo.


I hope, it is what you want.

Regards.







0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 112
Intraweb download file link ? 1 184
PHP preg_replace code convert to Delphi 14 98
Way to create an iPhone app for my customers 8 91
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question