如何模拟键盘输入下划线(96分)

  • 主题发起人 主题发起人 111111
  • 开始时间 开始时间
_unit Unit1;

interface

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

type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
keybd_event(VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY, 0);

keybd_event(189, 0, 0, 0);

keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);


end;

end.

 
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
keybd_event(VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY, 0);

keybd_event(189, 0, 0, 0);

keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);


end;

end.


object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
ActiveControl = Edit1
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 72
Top = 72
Width = 121
Height = 21
TabOrder = 0
Text = 'Edit1'
end
object Timer1: TTimer
Interval = 300
OnTimer = Timer1Timer
Left = 136
Top = 136
end
end


 
接受答案了.
 
后退
顶部