冥界3大法王 发表于 2019-11-30 13:22

delphi向x32dbg窗口发送Ctrl+F就成功,换Ctrl+Enter就不行呢?

delphi向x32dbg窗口发送Ctrl+F就成功,换ctrl+Enter就不行呢?


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)
    Edit1: TEdit;
    Edit2: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure hotykey(var msg: TMessage); message WM_HOTKEY;
private
    { Private declarations }
public
    { Public declarations }
end;
var
Form1: TForm1;
id1: Integer;         //id1 ctrl+shift+r
implementation
{$R *.dfm}
uses
TLHelp32, PsAPI;
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.hotykey(var msg: TMessage);   //定义下面这种热键,要先写长的判断,不然没有反应!这就是原因!
var
h: HWND;
pid: Cardinal;
pHandle: THandle;
buf: array of Char;
lpCaption: array of Char;                                    //字符缓冲变量
p: TPoint;
begin
if (GetAsyncKeyState(VK_CONTROL) < 0) and (GetAsyncKeyState(VK_SHIFT) < 0) and (GetAsyncKeyState(Ord('R')) < 0) then      //Ctrl+Shift+R
begin
    h := GetForegroundWindow;                                    //获取当前激活的窗体句柄
    GetWindowThreadProcessId(h, @pid);                           //通过句柄获取其进程ID
    pHandle := OpenProcess(PROCESS_ALL_ACCESS, False, pid);      //通过进程ID获取进程句柄
    GetModuleFileNameEx(pHandle, 0, buf, Length(buf));             //通过进程句柄获取其模块路径
    CloseHandle(pHandle);
    Edit1.Text := buf;
//keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), 0, 0);               //按下Ctrl键
//keybd_event(ord('F'), MapVirtualKey(ord('F'), 0), 0, 0);                     //按下F键
//keybd_event(ord('F'), MapVirtualKey(ord('F'), 0), KEYEVENTF_KEYUP, 0);       //放开F键
//keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0);
//keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), KEYEVENTF_KEYUP, 0);    //放开Ctrl键
    SendMessage(h, WM_keyDown, VK_CONTROL + 13, 0);
   //PostMessage(h, WM_KEYDOWN, VK_SPACE, 0);
    GetCursorPos(p);                                       //取当前鼠标指针位置
    h := WindowFromPoint(p);                               //取当前鼠标指针位置句柄
    IntToStr(GetWindowText(h, lpCaption, 255));            //获取当前鼠标指针位置文本
    Edit2.Text := lpCaption;
end;
end;
end.

成功的话,光标焦点会落在x32dbg的命令行插件就算达标了。换了上面这些都不行呢?
页: [1]
查看完整版本: delphi向x32dbg窗口发送Ctrl+F就成功,换Ctrl+Enter就不行呢?