Example #1
0
 /// <summary>
 /// 鼠标左键单击事件
 /// </summary>
 public static void BtnLeftClick(IntPtr handle)
 {
     // 按下左键
     WinApiServer.SendMessage(handle, 0x0201, 0, 0);
     // 释放左键
     WinApiServer.SendMessage(handle, 0x0202, 0, 0);
 }
Example #2
0
        /// <summary>
        /// 系统提示音
        /// </summary>
        public static void SystemSound()
        {
            Random random = new Random();

            Task.Run(() =>
            {
                for (int i = 0; i < 100; i++)
                {
                    WinApiServer.Beep(random.Next(500), 500);
                    WinApiServer.MessageBeep(BeepType.SimpleBeep);
                }
            });
        }
Example #3
0
        /// <summary>
        /// 查找所有子控件-广度遍历
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static List <IntPtr> Findallchild(IntPtr parent)
        {
            List <IntPtr> allchild = new List <IntPtr>();

            allchild.Add(parent);   //第一个添加父句柄,最后再删除
            for (int i = 0; i < allchild.Count; i++)
            {
                IntPtr patenttemp = allchild[i];
                IntPtr hwnd       = WinApiServer.FindWindowEx(patenttemp, IntPtr.Zero, null, null);
                while (hwnd != IntPtr.Zero)
                {
                    allchild.Add(hwnd);
                    hwnd = WinApiServer.FindWindowEx(patenttemp, hwnd, null, null);
                }
            }
            allchild.RemoveAt(0);
            return(allchild);
        }
Example #4
0
        /// <summary>
        /// 通告父级查找指定控件句柄
        /// </summary>
        /// <param name="parent">父句柄</param>
        /// <param name="classname"></param>
        /// <param name="text">为Null时则为所有窗口全匹配</param>
        /// <returns></returns>
        public static IntPtr Findview(IntPtr parent, string classname, string text)
        {
            IntPtr hwndtemp = WinApiServer.FindWindowEx(parent, IntPtr.Zero, classname, text);

            return(hwndtemp);
        }
Example #5
0
        /// <summary>
        ///  查找句柄
        /// </summary>
        /// <param name="lpClassName">窗体类名</param>
        /// <param name="lpWindowName">窗体名称</param>
        /// <returns></returns>
        public static IntPtr FindWindow(string classname, string windowName)
        {
            IntPtr hwndtemp = WinApiServer.FindWindow(classname, windowName);

            return(hwndtemp);
        }