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(hWnd);
SendKeys.Send("as");
SendKeys.SendWait("df");
试了都没有效果
向桌面发送按键或都字符,目的是在桌面按键配合Listary用
SendKeys.Send("as");
SendKeys.SendWait("df");
新手学习,上面代码是网上找的
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
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");
SetForegroundWindow(hWnd);
break;
}
hWndParent = (IntPtr)FindWindowEx(0, (int)hWndParent, "WorkerW", null);
}
SendKeys.Send("as");
SendKeys.SendWait("df");
调试完成~~
调试”概念很简单,但是有的人没有调试概念而靠“蒙”着编程。比如说你的 hWnd、hWndItem、hWndParent 等等每一步论坛发帖机的值是什么?你 用别的工具——特别是windows SDK 自带的标准调试工具——验证过每一个值对应什么 windows 系统内部对象了吗?