大佬教程收集整理的这篇文章主要介绍了如何获取当前正在运行的实际窗口的标题?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
到目前为止,我已经到了这里
function EnumWindowProc(hHwnd: HWND; lParam : Integer): Boolean; stdcall; var pPid : DWORD; title,ClassName : String; begin if (hHwnd=NULL) then begin result := false; end else begin GetWindowThreadProcessId(hHwnd,pPid); SetLength(ClassName,255); SetLength(ClassName,GetClassName(hHwnd,PChar(className),Length(className))); SetLength(title,255); SetLength(title,GetWindowText(hHwnd,PChar(titlE),Length(titlE))); OptionsForm.ListBox1.Items.Add(titlE); OptionsForm.Memo1.Lines.Add ('Class Name = ' + className + '; title = ' + title + '; HWND = ' + IntToStr(hHwnd) + '; Pid = ' + IntToStr(pPid)); Result := true; end; end;
但是,它返回各种各样的“窗口”,不同的形式焦点等.我怎样才能得到“主要”的?
以下是结果示例:
Class Name = SHell_TrayWnd; title = ; HWND = 65898; Pid = 3776 Class Name = CiceroUIWndFrame; title = CiceroUIWndFrame; HWND = 65976; Pid = 3776 Class Name = THelpInsightWindowImpl; title = HelpInsightWindow; HWND = 1577734; Pid = 4852 Class Name = THelpInsightWindowImpl; title = HelpInsightWindow; HWND = 591660; Pid = 4852 Class Name = TTokenWindow; title = CodeParamWindow; HWND = 985436; Pid = 4852 Class Name = TaskSwitcherWnd; title = Přepínání úloh; HWND = 66824; Pid = 3776 Class Name = tooltips_class32; title = ; HWND = 198982; Pid = 1768 Class Name = tooltips_class32; title = ; HWND = 66046; Pid = 3776 Class Name = _SearchEditBoxFakeWindow; title = ; HWND = 66024; Pid = 3776 Class Name = tooltips_class32; title = ; HWND = 66008; Pid = 3776 Class Name = tooltips_class32; title = ; HWND = 131538; Pid = 3776 Class Name = Desktop User Picture; title = Magicmaster; HWND = 65982; Pid = 3776 Class Name = DV2ControlHost; title = Nabídka Start; HWND = 65978; Pid = 3776 Class Name = tooltips_class32; title = ; HWND = 327840; Pid = 1768 Class Name = tooltips_class32; title = ; HWND = 460808; Pid = 1768 Class Name = CTSCTooltip; title = ; HWND = 266710; Pid = 2792 Class Name = Auto-Suggest Dropdown; title = ; HWND = 69884; Pid = 4732 Class Name = Auto-Suggest Dropdown; title = ; HWND = 69802; Pid = 4732 Class Name = TaskbarNotifierClass; title = DAP message Center; HWND = 68924; Pid = 4732 Class Name = tooltips_class32; title = ; HWND = 134356; Pid = 1992 Class Name = ATKOSD; title = ATKOSD; HWND = 65884; Pid = 3636
先感谢您!
该程序向您展示了它是如何完成的:
program EnumTaskbarWindows; {$APPTYPE CONSOLE} uses SysUtils,Windows; function EnumWindowsProc(hwnd: HWND; lParam: LPARAM): BOOL; stdcall; var s: String; IsVisible,Isowned,IsAppWindow: Boolean; begin Result := True;//carry on enumerating IsVisible := IsWindowVisible(hwnd); if not IsVisible then exit; Isowned := GetWindow(hwnd,GW_owneR)<>0; if Isowned then exit; IsAppWindow := GetWindowLongPtr(hwnd,GWL_STYLE) and WS_EX_APPWINDOW<>0; if not IsAppWindow then exit; SetLength(s,GetWindowTextLength(hwnd)); GetWindowText(hwnd,PChar(s),Length(s)+1); Writeln(s); end; begin EnumWindows(@EnumWindowsProc,0); end.
以上是大佬教程为你收集整理的如何获取当前正在运行的实际窗口的标题?全部内容,希望文章能够帮你解决如何获取当前正在运行的实际窗口的标题?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。