예제 #1
0
        private static void LeftMouseClick(MouseHookHelper.POINT pointInfo)
        {
            //先移动鼠标到指定位置
            MouseHookHelper.SetCursorPos(pointInfo.X, pointInfo.Y);

            //按下鼠标左键
            MouseHookHelper.mouse_event(MouseHookHelper.MOUSEEVENTF_LEFTDOWN,
                                        pointInfo.X,
                                        pointInfo.Y, 0, 0);

            //松开鼠标左键
            MouseHookHelper.mouse_event(MouseHookHelper.MOUSEEVENTF_LEFTUP,
                                        pointInfo.X,
                                        pointInfo.Y, 0, 0);
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            IntPtr awin = MouseHookHelper.FindWindow("UnityWndClass",
                                                     "Shadowverse");

            if (awin == IntPtr.Zero)
            {
                MessageBox.Show("没有找到窗体");


                return;
            }
            else
            {
                canStart = true;
                MessageBox.Show("已寻找到窗体,请进行后续操作");
            }
        }
예제 #3
0
        //实时打印鼠标的相对(x,y)位置
        private static void PrintMousePoint(int x, int y)
        {
            int x1 = x;
            int y1 = y;

            while (true)
            {
                Point p = new Point(1, 1);//定义存放获取坐标的point变量
                MouseHookHelper.GetCursorPos(ref p);

                if (x1 != p.X && y1 != p.Y)
                {
                    System.Console.WriteLine("相对于父类窗口 dx:");
                    System.Console.WriteLine(p.X - x);
                    System.Console.WriteLine("相对于父类窗口 dy:");
                    System.Console.WriteLine(p.Y - y);
                    x1 = p.X;
                    y1 = p.Y;
                }
            }
        }
예제 #4
0
        void sv_work1_DoWork(object sender, DoWorkEventArgs e)
        {
            while (sv_NeedRun == true && Cishu < Convert.ToInt32(textBox1.Text)) // 后台开始
            {
                IntPtr awin = MouseHookHelper.FindWindow("UnityWndClass",
                                                         "Shadowverse");

                MouseHookHelper.RECT rc = new MouseHookHelper.RECT();

                MouseHookHelper.GetWindowRect(awin, ref rc);

                int width  = rc.Right - rc.Left; //窗口的宽度
                int height = rc.Bottom - rc.Top; //窗口的高度
                int x      = rc.Left;
                int y      = rc.Top;



                MouseHookHelper.SetForegroundWindow(awin);                           // 设置当前窗口置前
                MouseHookHelper.ShowWindow(awin, MouseHookHelper.SW_SHOWNOACTIVATE); //4、5

                System.Threading.Thread.Sleep(2000);
                if (sv_NeedRun == false)
                {
                    break;                                 //真不会了,只能这样判断是否暂停(下面的if都是判断)
                }
                LeftMouseClick(new MouseHookHelper.POINT() //点击换牌决定
                {
                    X = x + 1227,
                    Y = y + 415,
                });

                System.Threading.Thread.Sleep(8000);
                if (sv_NeedRun == false)
                {
                    break;
                }
                LeftMouseClick(new MouseHookHelper.POINT()  //如为先攻点击回合结束
                {
                    X = x + 1227,
                    Y = y + 415,
                });
                if (sv_NeedRun == false)
                {
                    break;
                }
                Cishu = Cishu + 1;   //次数+1后判断是不是继续循环
                System.Threading.Thread.Sleep(68000);
                if (sv_NeedRun == false || Cishu >= Convert.ToInt32(textBox1.Text))
                {
                    break;
                }
                LeftMouseClick(new MouseHookHelper.POINT()  //点击再次挑战
                {
                    X = x + 700,
                    Y = y + 725,
                });

                System.Threading.Thread.Sleep(5000);
                if (sv_NeedRun == false)
                {
                    break;
                }
                LeftMouseClick(new MouseHookHelper.POINT()  //默认第一卡组
                {
                    X = x + 347,
                    Y = y + 260,
                });

                System.Threading.Thread.Sleep(1000);
                if (sv_NeedRun == false)
                {
                    break;
                }
                LeftMouseClick(new MouseHookHelper.POINT()  //OK
                {
                    X = x + 816,
                    Y = y + 584,
                });
                if (sv_NeedRun == false)
                {
                    break;
                }
                System.Threading.Thread.Sleep(21500);
                if (sv_NeedRun == false)
                {
                    break;
                }
            }
        }