标题:请教向桌面发送按键或者字符
只看楼主
eddybccn
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2020-1-28
结帖率:100%
 问题点数:0 回复次数:1 
请教向桌面发送按键或者字符

这两段代码都不行,求助一下
 
程序代码:
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 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");
搜索更多相关主题的帖子: 桌面 null IntPtr 发送 int 
2020-03-27 22:00
eddybccn
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2020-1-28
得分:0 
自问自答了
程序代码:
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");

2020-03-28 20:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-500665-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034329 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved