Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

for msac_m

Posted on 1998-11-19
3
Medium Priority
?
139 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 30 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

916 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