Solved

for msac_m

Posted on 1998-11-19
3
131 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
  • 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now