我正在研究Windows中的UI自动化。 我尝试获取单击的完整文件路径。
所以我用
SetWindowsHookEx(WH_MOUSE_LL, ~~)
并尝试挂钩回调。
首先,我使用此代码:
POINT pt;
IUIAutomationElement* pTargetElement = NULL;
GetCursorPos(&pt);
m_pUIAutomation->ElementFromPoint(pt, &pTargetElement);
UIA_HWND uHwnd;
pTargetElement->get_CurrentNativeWindowHandle(&uHwnd);
get_CurrentNativeWindowHandle()返回0,因为图标没有窗口。
其次,我得到了桌面的Syslistview32句柄。但它只能得到文件名。
HWND hShellWnd = GetShellWindow();
HWND hDefView = FindWindowEx(hShellWnd, NULL, _T("SHELLDLL_DefView"), NULL);
HWND folderView = FindWindowEx(hDefView, NULL, _T("SysListView32"), NULL);
如何在桌面或资源管理器...等等获取完整的文件路径? enter image description here