模拟点击Webbrowser

来源:互联网 发布:吉文斯旋转的算法 编辑:程序博客网 时间:2024/04/26 00:08

滚动到相应位置:

           mshtml.HTMLDocument doc1 = (mshtml.HTMLDocument)this.webBrowser1.Document.DomDocument;
            doc1.parentWindow.scrollBy(0, 1500);

模拟点击         

       int x = 505; // X 点

                int y = 22; // Y 点

                IntPtr handle = webBrowser1.Handle;
                StringBuilder className = new StringBuilder(100);
                while (className.ToString() != "Internet Explorer_Server")
                {

                    handle = GetWindow(handle, 5); // Get a handle to the child window
                    GetClassName(handle, className, className.Capacity);
                }
                IntPtr lParam = (IntPtr)((y << 16) | x);
                IntPtr wParam = IntPtr.Zero;
                const uint downCode = 0x201; //
                const uint upCode = 0x202; //
                SendMessage(handle, downCode, wParam, lParam);
                SendMessage(handle, upCode, wParam, lParam); // Mouse

原创粉丝点击