|
本帖最后由 tt911 于 2019-11-28 14:58 编辑
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
ListBox1: TListBox;
Edit1: TEdit;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure hotykey(var msg: TMessage); message WM_HOTKEY;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
id1: Integer; //id1 ctrl+shift+r
implementation
{$R *.dfm}
uses
TLHelp32, PsAPI, Clipbrd, RegularExpressions;
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
match: TMatch;
begin
ListBox1.Clear;
for I := 0 to Memo1.Lines.Count - 1 do
begin
//ShowMessage(Memo1.Lines[I]);
match := TRegEx.match(Memo1.Lines[I], '(?<=模块=).*(?=\..*)');
if match.Success then
begin
//ShowMessage(match.Value);
ListBox1.Items.Add(match.Value + #13#10);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
match: TMatch;
begin
match := TRegEx.match(Edit1.Text, '(?<=模块=).*(?=\..*)');
if match.Success then
begin
ShowMessage(match.Value);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
id1 := GlobalAddAtom('hotkey1');
RegisterHotKey(handle, id1, MOD_CONTROL + MOD_SHIFT, 82); //ctrl+shift+r
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle, id1);
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
ShowMessage(ListBox1.Items[ListBox1.ItemIndex] + #13#10 + '已复制到剪贴板');
Clipboard.AsText := ListBox1.Items[ListBox1.ItemIndex];
end;
procedure TForm1.hotykey(var msg: TMessage);
var
h: HWND;
pid: Cardinal;
pHandle: THandle;
buf: array[0..MAX_PATH] of Char;
SelectedIndex: Integer;
begin
if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(Ord('R')) < 0) then //Ctrl+Shift+R
begin
ListBox1.Selected[ListBox1.ItemIndex + 1] := True;
//ShowMessage(ListBox1.Items[ListBox1.ItemIndex + 1] + #13#10 + '已复制到剪贴板');
Clipboard.AsText := ListBox1.Items[ListBox1.ItemIndex];
end;
end;
end.
|
评分
-
查看全部评分
|