现在我已经实现了webBrowser在FLASH里点击鼠标,但就是不能实现按住左键不放然后拖动到另一个坐标释放左键,请教一下大家该如何实现?下面的代码是鼠标的点击事件。
int x, y;
            x = Convert.ToInt32(X1.Text);
            y = Convert.ToInt32(Y1.Text); 
           
            IntPtr handle = webBrowser1.Handle;
            StringBuilder className = new StringBuilder(100);
            while (className.ToString() != "Internet Explorer_Server")
            {
                handle = GetWindow(handle, 5);
                GetClassName(handle, className, className.Capacity);
            }
            IntPtr lParam = (IntPtr)((y << 16) | x); //坐标
            IntPtr wParam = IntPtr.Zero; // 额外的参数点击(例如。Ctrl)
            //const uint mousemovecode = 0x200; // 移动
            const uint downCode = 0x201; // 左键按下代码
            const uint upCode = 0x202; //左键抬起代码
            SendMessage(handle, downCode, wParam, lParam); // 鼠标按钮下
            SendMessage(handle, upCode, wParam, lParam); // 鼠标抬起

解决方案 »

  1.   

    这个你要把html 的脚本搞好。
      

  2.   

    用了相同的代码,我的无法在Flash上点击的,变通的连接标签就可以!怪怪
      

  3.   


    用mouse_event试试using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        [DllImport("user32.dll")]
            static extern bool ReleaseCapture();
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);        [DllImport("user32.dll")]
            static extern int SetCursorPos(int x, int y);        [DllImport("user32.dll")]
            static extern int mouse_event(UInt32 dwFlags, Int32 dx, Int32 dy, Int32 cButtons, Int32 dwExtraInfo);        private readonly UInt32 WM_SYSCOMMAND = 0x112;
            private readonly UInt32 SC_MOVE = 0xF010;
            private readonly UInt32 HTCAPTION = 2;        /// <summary>
            /// 鼠标控制参数
            /// </summary>        
            private readonly UInt32 MOUSEEVENTF_LEFTDOWN = 0x2;
            private readonly UInt32 MOUSEEVENTF_LEFTUP = 0x4;        private void Form1_Load(object sender, EventArgs e)
            {
                button1.MouseDown += MyMouseMove;
            }        private void MyMouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    ReleaseCapture();
                    SendMessage(this.button1.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
                }
            }        private void button2_Click(object sender, EventArgs e)
            {
                System.Drawing.Point p = PointToScreen(button1.Location);
                SetCursorPos(p.X + button1.Width / 2, p.Y + button1.Height / 2);
                mouse_event(MOUSEEVENTF_LEFTDOWN, p.X + button1.Width / 2, p.Y + button1.Height / 2, 0, 0);
                SetCursorPos(p.X, p.Y);
                mouse_event(MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0);
            }
        }
    }