#2
eddybccn2020-03-28 20:19
|
这两段代码都不行,求助一下
程序代码:
IntPtr hWndParent = (IntPtr)FindWindowEx(0, 0, "WorkerW", null);
IntPtr hWndItem;
IntPtr hWnd;
while (true)
{
hWndItem = (IntPtr)FindWindowEx((int)hWndParent, 0, "SHELLDLL_DefView", null);
if (hWndItem != IntPtr.Zero)
{
hWnd = (IntPtr)FindWindowEx((int)hWndItem, 0, "SysListView32", "FolderView");
break;
}
hWndParent = (IntPtr)FindWindowEx(0, (int)hWndParent, "WorkerW", null);
}
// 激活
// SetActiveWindow(GetDesktopWindow());
// SetActiveWindow(tempHwnd);
// SetForegroundWindow(parent);
// SetFocus(hWndItem);
SendKeys.Send("as");
SendKeys.SendWait("df");
IntPtr hWndItem;
IntPtr hWnd;
while (true)
{
hWndItem = (IntPtr)FindWindowEx((int)hWndParent, 0, "SHELLDLL_DefView", null);
if (hWndItem != IntPtr.Zero)
{
hWnd = (IntPtr)FindWindowEx((int)hWndItem, 0, "SysListView32", "FolderView");
break;
}
hWndParent = (IntPtr)FindWindowEx(0, (int)hWndParent, "WorkerW", null);
}
// 激活
// SetActiveWindow(GetDesktopWindow());
// SetActiveWindow(tempHwnd);
// SetForegroundWindow(parent);
// SetFocus(hWndItem);
SendKeys.Send("as");
SendKeys.SendWait("df");
程序代码:
IntPtr pWnd = FindWindow("Progman", null);
pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SHELLDLL_DefVIew", null);
pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", null);
// pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", "FolderView");
// IntPtr tWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
SetParent(this.Handle, pWnd);
SendKeys.Send("as");
SendKeys.SendWait("df");
pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SHELLDLL_DefVIew", null);
pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", null);
// pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", "FolderView");
// IntPtr tWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
SetParent(this.Handle, pWnd);
SendKeys.Send("as");
SendKeys.SendWait("df");