好友
阅读权限40
听众
最后登录1970-1-1
|
[mw_shl_code=delphi,true]
procedure TWinTitle.hotykey(var msg: TMessage);
var
// voice: OLEVariant; //TTS朗读用的
pid: Cardinal;
pHandle: THandle;
buf: array[0..MAX_PATH] of Char;
ps: array[0..254] of Char; // 这个是定义激活的窗口的控件名
path: string; // 激活窗口的路径
arr: array[0..254] of Char;
h: HWND;
pt: TPoint;
c: TColor;
begin
if (GetAsyncKeyState(VK_LWIN) and (GetAsyncKeyState(Ord('A'))) < 0) then // Win+A
begin
PostMessage.ComboBox3.Clear;
WinTitle.CKBT.Clear;=====================>就他娘的这里!
WinTitle.CKBT.Items.Clear;=====================>就他娘的这里!
ShowMessage('清空了吗?');
h := GetForegroundWindow; // 这个是句柄
GetWindowThreadProcessId(h, @pid);
pHandle := OpenProcess(PROCESS_ALL_ACCESS, false, pid);
GetModuleFileNameEx(pHandle, 0, buf, Length(buf));
CloseHandle(pHandle);
// ShowMessage('激活窗口的pid是:' + IntToHex(StrToInt(Format('%u', [pid])), 4)); //再转换成 16进制,因为x32dbg/x64dbg 附加进程用到的是 16进制数
GetWindowText(h, @arr, SizeOf(arr));
GetClassName(h, ps, 255);
// aWnd := WindowFromPoint(Mouse.CursorPos);
path := GetProcessExePath(h);
WinTitle.KJ_Edit1.Text := arr;
WinTitle.KJ_Edit2.Text := ps;
WinTitle.KJ_Edit4.Text := '0x' + PChar(IntToHex(StrToInt(IntToStr(h))));
WinTitle.KJ_Edit5.Text := PChar(path);
WinTitle.KJ_Edit6.Text := Format('%u', [pid]);
//ShowMessage('当前激活的窗口标题是:' + arr + #13#10 + '得到激活的窗口类名是:' + ps + #13#10 + '得到激活窗口的完整路径是:' + PChar(path) + #13#10 + '当前窗口的句柄是:' + PChar(IntToHex(StrToInt(IntToStr(h)))));
//ShowMessage(Format('%u', [pid])); //得到激活窗口的pid可行
WinTitle.KJ_Edit7.Text := TRegEx.Replace(WinTitle.KJ_Edit5.Text, '.*\\', '');
GetCursorPos(pt);
WinTitle.KJ_Edit8.Text := IntToStr(pt.X) + ',' + IntToStr(pt.Y);
GetCursorPos(pt);
c := GetPixel(GetDC(0), pt.X, pt.Y);
WinTitle.KJ_Edit3.Color := c;
WinTitle.KJ_Edit3.Text := Format('#%.6x', [c]);
WinTitle.kj_Memo1.Lines.Text := GetEditText;
WinTitle.CKBT.Items.Add('0. 【' + arr + '】');
WinTitle.CKBT.Items.Add('0. 【' + '部分标题】');
WinTitle.CKBT.Items.Add('1.激活的窗口 【A】');
WinTitle.CKBT.Items.Add('2.ahk_class 【ahk_class ' + WinTitle.KJ_Edit2.Text + '】');
WinTitle.CKBT.Items.Add('3.ahk_id 【ahk_id ' + WinTitle.KJ_Edit4.Text + '】');
WinTitle.CKBT.Items.Add('4.ahk_pid 【ahk_pid ' + WinTitle.KJ_Edit6.Text + '】');
WinTitle.CKBT.Items.Add('5.ahk_exe 【ahk_exe ' + WinTitle.KJ_Edit7.Text + '】');
WinTitle.CKBT.Items.Add('5.ahk_exe 【ahk_exe ' + WinTitle.KJ_Edit5.Text + '】');
WinTitle.CKBT.Items.Add('6.ahk_group 【窗口组】');
WinTitle.CKBT.Items.Add('7. 【多重条件】');
WinTitle.CKBT.Items.Add('8.都为空 【上次找到的窗口】');
PostMessage.ComboBox3.Items.Add('ahk_class ' + WinTitle.KJ_Edit2.Text);
PostMessage.ComboBox3.Items.Add('ahk_id ' + WinTitle.KJ_Edit4.Text);
PostMessage.ComboBox3.Items.Add('ahk_pid ' + WinTitle.KJ_Edit6.Text);
PostMessage.ComboBox3.Items.Add('ahk_exe ' + WinTitle.KJ_Edit7.Text);
WinTitle.kj_Memo1.SelectAll; //全选
WinTitle.kj_Memo1.CopyToClipboard; //并复制到剪贴板,这样主界面底部就能完成Win+A后复制到剪贴板了!
//voice := CreateOLEObject('SAPI.SpVoice');
//voice.Speak('数据已复制到剪贴板!', 0); //TTS朗读用的
end;
end;
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|