| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1436 人关注过本帖
标题:请教向桌面发送按键或者字符
只看楼主 加入收藏
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
快速回复:请教向桌面发送按键或者字符
数据加载中...
 
   



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

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