当前位置:编程学习 > C#/ASP.NET >>

关于googleearth的二次打开 模拟鼠标事件自动拖动,疑问?

 [DllImport("User32")]
        public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo);
        public enum MouseEventFlags
        {
            Move = 0x0001,
            LeftDown = 0x0002,
            LeftUp = 0x0004,
            RightDown = 0x0008,
            RightUp = 0x0010,
            MiddleDown = 0x0020,
            MiddleUp = 0x0040,
            Wheel = 0x0800,
            Absolute = 0x8000
        } 
        private void button3_Click(object sender, EventArgs e)
        {
            Form1 fm = new Form1();
            this.WindowState = FormWindowState.Minimized;
            fm.Focus();
            fm.panel1.Focus();
            for(int i=0;i<=10;i++)
            {
                mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.Move), 300 * 65536 / 1280, 200 * 65536 / 800, 0,( IntPtr)appGE.GetRenderHwnd());
                Thread.Sleep(300);
                mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown), 300 * 65536 / 1280, 200 * 65536 / 800, 0, (IntPtr)appGE.GetRenderHwnd());
                Thread.Sleep(300);
                mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.Move), 300 * 65536 / 1280, 500 * 65536 / 800, 0, (IntPtr)appGE.GetRenderHwnd());
                Thread.Sleep(300);
                mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftUp), 300 * 65536 / 1280, 500 * 65536 / 800, 0, (IntPtr)appGE.GetRenderHwnd());
              
            }
            fm.Dispose();
        } 
用mouse_event函数实现自动拖动,google earth的地球放在panel控件中,为什么这段代码有时候能运行起来,有时不行 请高人指点 --------------------编程问答-------------------- --------------------编程问答--------------------
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,