コード例 #1
0
    private void NuitrackManager_onHandsTrackerUpdate(nuitrack.HandTrackerData handTrackerData)
    {
        active = false;
        press  = false;

        if (handTrackerData != null)
        {
            nuitrack.UserHands userHands = handTrackerData.GetUserHandsByID(CurrentUserTracker.CurrentUser);

            if (userHands != null)
            {
                if (userHands.RightHand != null)
                {
                    Vector2 curpos = new Vector2(userHands.RightHand.Value.X * Screen.currentResolution.width, userHands.RightHand.Value.Y * Screen.currentResolution.height);
                    MouseOperations.SetCursorPosition((int)(curpos.x), (int)(curpos.y));
                    active = true;
                    press  = userHands.RightHand.Value.Click;

                    /*if (pressed != press)
                     * {
                     *  pressed = press;
                     *
                     *  if (pressed)
                     *  {
                     *      MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp | MouseOperations.MouseEventFlags.LeftDown);
                     *  }
                     * }*/
                }
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    private void Update()
    {
        if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
        {
            mouseControlled = true;
        }
        else if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            mouseControlled = false;
        }

        if (mouseControlled)
        {
            _cursorPosition = MouseOperations.GetCursorPosition();
        }
        else
        {
            _cursorPosition.X += (int)(Input.GetAxis("Horizontal") * Game.Config.MapMouseEmulationSpeed);
            _cursorPosition.Y -= (int)(Input.GetAxis("Vertical") * Game.Config.MapMouseEmulationSpeed);

            MouseOperations.SetCursorPosition(_cursorPosition);
        }

        if (Input.GetAxis("Fire1") != 0 || Input.GetAxis("Submit") != 0)
        {
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp | MouseOperations.MouseEventFlags.LeftDown);
        }
    }
コード例 #3
0
ファイル: Form1.cs プロジェクト: adryzz/UltraAutoClicker
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (radioButton4.Checked)//move the mouse
            {
                MouseOperations.SetCursorPosition(new MouseOperations.MousePoint(Convert.ToInt32(xCoordinateSelector.Value), Convert.ToInt32(yCoordinateSelector.Value)));
            }

            switch (mouseButtonSelector.SelectedIndex)
            {
            case 0:    //left
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);

                if (clickTypeSelector.SelectedIndex == 1)        //double click
                {
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                }

                break;
            }

            case 1:    //middle
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleUp);

                if (clickTypeSelector.SelectedIndex == 1)        //double click
                {
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleDown);
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleUp);
                }

                break;
            }

            case 2:    //right
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);

                if (clickTypeSelector.SelectedIndex == 1)        //double click
                {
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                }

                break;
            }
            }

            ClicksCount++;

            if (ClicksCount >= ClicksLimit && ClicksLimit != 0)
            {
                StopClicking();
            }
            timer1.Interval = Convert.ToInt32(millisecondsCounter.Value + (secondsCounter.Value * 1000) + (minutesCounter.Value * 60000) + (hoursCounter.Value * 3600000)) + ClickRandomizer.Next(-Convert.ToInt32(randomizerCount.Value * RandomizationMultiplier), Convert.ToInt32(randomizerCount.Value * RandomizationMultiplier));
        }
コード例 #4
0
        public static void LinearSmoothMove(Point newPosition, int steps)
        {
            MouseOperations.MousePoint start = MouseOperations.GetCursorPosition();
            Point  p         = new Point(start.X, start.Y);
            PointF iterPoint = p;

            // Find the slope of the line segment defined by start and newPosition
            PointF slope = new PointF(newPosition.X - start.X, newPosition.Y - start.Y);

            // Divide by the number of steps
            slope.X = slope.X / steps;
            slope.Y = slope.Y / steps;

            // Move the mouse to each iterative point.
            for (int i = 0; i < steps; i++)
            {
                iterPoint = new PointF(iterPoint.X + slope.X, iterPoint.Y + slope.Y);

                MouseOperations.MousePoint o = new MouseOperations.MousePoint((int)iterPoint.X, (int)iterPoint.Y);
                MouseOperations.SetCursorPosition(o);
                Thread.Sleep(1);
            }

            // Move the mouse to the final destination.
            MouseOperations.SetCursorPosition(newPosition.X, newPosition.Y);
        }
コード例 #5
0
ファイル: MouseOperator.cs プロジェクト: gkarapatis/RecAndRep
 public ActionResponse Move(int x, int y)
 {
     MouseOperations.SetCursorPosition(x, y);
     return(new ActionResponse()
     {
         Succeeded = true,
     });
 }
コード例 #6
0
        public void Invoke()
        {
            Vector2 targetPosition         = getPosition();
            Vector2 centerScreen           = GetCenterScreen();
            Vector2 offsetVector           = targetPosition - centerScreen;
            float   xScale                 = Math.Abs(centerScreen.x / offsetVector.x);
            float   yScale                 = Math.Abs(centerScreen.y / offsetVector.y);
            float   finalScale             = offsetVector.x < offsetVector.y ? yScale : xScale;
            Vector2 offsetFromCenterToEdge = offsetVector * finalScale;

            MouseOperations.SetCursorPosition(centerScreen + offsetFromCenterToEdge);
        }
コード例 #7
0
        static void aTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            Console.WriteLine("Click..");
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);

            MouseOperations.MousePoint point = MouseOperations.GetCursorPosition();
            point.X = point.X + (isPositive ? mouseSteps : -1 * mouseSteps);
            //point.Y = point.Y +(isPositive ? mouseSteps : -mouseSteps);
            isPositive = !isPositive;
            MouseOperations.SetCursorPosition(point);
        }
コード例 #8
0
ファイル: ClientApi.cs プロジェクト: ugursoysal/Device
        public static void TryToContinue()
        {
            Random rn = new Random();

            if (GameSession.LOLHandle == IntPtr.Zero && LOLProcess != null && NativeMethods.IsWindow(LOLProcess.Handle) && !LOLProcess.HasExited)
            {
                NativeMethods.Focus(LOLProcess.Handle);
            }
            Thread.Sleep(GameSession.RandomTimeGenerator(6000));
            MouseOperations.SetCursorPosition(712 + rn.Next(-2, 2), 147 + rn.Next(-2, 2));
            Thread.Sleep(GameSession.RandomTimeGenerator(100));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            Thread.Sleep(GameSession.RandomTimeGenerator(25));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            Thread.Sleep(GameSession.RandomTimeGenerator(1000));
            MouseOperations.SetCursorPosition(511 + rn.Next(-3, 3), 488 + rn.Next(-3, 4));
            Thread.Sleep(GameSession.RandomTimeGenerator(100));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            Thread.Sleep(GameSession.RandomTimeGenerator(25));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            //reconnect
            Thread.Sleep(GameSession.RandomTimeGenerator(1000));
            MouseOperations.SetCursorPosition(418 + rn.Next(-3, 3), 364 + rn.Next(-3, 4));
            Thread.Sleep(GameSession.RandomTimeGenerator(100));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            Thread.Sleep(GameSession.RandomTimeGenerator(25));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            //reconnect
            Thread.Sleep(GameSession.RandomTimeGenerator(2000));
            MouseOperations.SetCursorPosition(514 + rn.Next(-5, 5), 588 + rn.Next(-5, 5));
            Thread.Sleep(GameSession.RandomTimeGenerator(100));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            Thread.Sleep(GameSession.RandomTimeGenerator(25));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            // HERO PICK
            Thread.Sleep(GameSession.RandomTimeGenerator(2000));
            MouseOperations.SetCursorPosition(510 + rn.Next(-2, 2), 386 + rn.Next(-2, 2));
            Thread.Sleep(GameSession.RandomTimeGenerator(100));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            Thread.Sleep(GameSession.RandomTimeGenerator(25));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            Thread.Sleep(GameSession.RandomTimeGenerator(1000));
            MouseOperations.SetCursorPosition(507 + rn.Next(-3, 3), 619 + rn.Next(-2, 2));
            Thread.Sleep(GameSession.RandomTimeGenerator(100));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            Thread.Sleep(GameSession.RandomTimeGenerator(25));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            // HERO PICK
        }
コード例 #9
0
        public void ThenJustDoIt()
        {
            var window = Desktop.Instance.Windows().FirstOrDefault(w => w.AutomationElement.Current.ProcessId == 24740);
            var button = window.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByText("Click Here"));

            var clickPoint = button.AutomationElement.GetClickablePoint();

            MouseOperations.MousePoint mousePoint = new MouseOperations.MousePoint((int)clickPoint.X, (int)clickPoint.Y);
            MouseOperations.SetCursorPosition(mousePoint);

            for (int i = 0; i < 20000; i++)
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown | MouseOperations.MouseEventFlags.LeftUp, mousePoint);
            }
        }
コード例 #10
0
        private void FinishGame()
        {
            Logger.Log("Game finished!");
            Server.SetInfoText("Game finished.");
            if (SecondsTimer != null)
            {
                SecondsTimer.Dispose();
            }
            SecondsTimer = null;
            if (TenSecondsTimer != null)
            {
                TenSecondsTimer.Dispose();
            }
            TenSecondsTimer = null;
            if (HalfMinuteTimer != null)
            {
                HalfMinuteTimer.Dispose();
            }
            HalfMinuteTimer = null;
            if (MinuteTimer != null)
            {
                MinuteTimer.Dispose();
            }
            MinuteTimer = null;
            Thread.Sleep(10000);
            ClientApi.TryToContinue();

            MouseOperations.SetCursorPosition(520 + RandomTimeGenerator(3), 380 + RandomTimeGenerator(3));

            Thread.Sleep(RandomTimeGenerator());
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            Thread.Sleep(RandomTimeGenerator(10));
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            Thread.Sleep(RandomTimeGenerator(6000));

            /*for (int a = 0; a < 5; a++)
             * {
             *  MouseOperations.SetCursorPosition(934 + RandomTimeGenerator(5), 850 + RandomTimeGenerator(5));
             *  Thread.Sleep(RandomTimeGenerator());
             *  MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
             *  Thread.Sleep(RandomTimeGenerator(10));
             *  MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
             * }*/
            Server.SetIndicator(IndicatorStates.Wait);
            //Server.GameSession = new GameSession(Server);
            ClientApi.StartNewGame();
        }
コード例 #11
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            wiimoteMode = !wiimoteMode;
        }


        if (wiimoteMode && WiimoteManager.HasWiimote())
        {
            Vector2 vals           = wiimoteController.GetIRValues();
            float   distancePoints = Vector2.Distance(followingPosition, vals);

            float newPercentFollow;

            if (distancePoints < distanceToMinFollow)
            {
                newPercentFollow = .01f;
            }
            else if (distancePoints > distanceToMaxFollow)
            {
                newPercentFollow = .5f;
            }
            else
            {
                newPercentFollow = percentFollowFrame;
            }

            float x = followingPosition.x * (1 - newPercentFollow) + vals.x * newPercentFollow;
            float y = followingPosition.y * (1 - newPercentFollow) + vals.y * newPercentFollow;

            followingPosition = new Vector2(x, y);

            MouseOperations.SetCursorPosition((int)followingPosition.x * 2, (Screen.height - (int)followingPosition.y) * 2);

            if (wiimoteController.isBDown)
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp | MouseOperations.MouseEventFlags.LeftDown);
            }
        }
        else
        {
            followingPosition = Input.mousePosition;
        }
    }
コード例 #12
0
        public override void Invoke()
        {
            Vector2 originalPosition = getPosition();

            if (isUi || DisplayPointTranslator.IsValidPoint(originalPosition))
            {
                MouseOperations.SetCursorPosition(originalPosition);
            }
            else
            {
                var oldNext = next;
                next = new AutoActionBuilder()
                       .Add(new SelfRepeatingAction(new AdjustCamera(getPosition)))
                       .Add(new MoveMouse(getPosition))
                       .Add(oldNext)
                       .Build(this);
            }
        }
コード例 #13
0
        public static void MoveTile(byte tileIndex, byte boardIndex)
        {
            // Get current cursor position
            MouseOperations.MousePoint startPos = MouseOperations.GetCursorPosition();
            //userpb1.Top = 300;
            //userpb1.Left = 800;

            Form form  = Program.MainView;
            int  formX = form.DesktopLocation.X;
            int  formY = form.DesktopLocation.Y;

            // Tile 1
            MouseOperations.SetCursorPosition(formX + 810 + tileIndex * 49, formY + 350);
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            MouseOperations.SetCursorPosition(formX + 30 + boardIndex % 15 * 50, formY + 80 + boardIndex / 15 * 50);
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            Application.DoEvents();

            MouseOperations.SetCursorPosition(startPos);
        }
コード例 #14
0
    private void NuitrackManager_onHandsTrackerUpdate(nuitrack.HandTrackerData handTrackerData)
    {
        active = false;
        press  = false;

        ItemDragHandler drag = GetComponent <ItemDragHandler>();

        if (handTrackerData != null)
        {
            nuitrack.UserHands userHands = handTrackerData.GetUserHandsByID(CurrentUserTracker.CurrentUser);

            if (userHands != null)
            {
                if (userHands.RightHand != null)
                {
                    Vector2 curpos = new Vector2(userHands.RightHand.Value.X * Screen.currentResolution.width, userHands.RightHand.Value.Y * Screen.currentResolution.height);
                    MouseOperations.SetCursorPosition((int)(curpos.x), (int)(curpos.y));
                    active = true;
                    press  = userHands.RightHand.Value.Pressure == 1.0f;

                    if (press)
                    {
                        objectToDrag = drag.GetDraggableTransformUnderMouse();

                        drag.dragObj(objectToDrag);
                        dragging = true;
                    }
                    if (dragging)
                    {
                        drag.dragObj(objectToDrag);
                    }
                    else
                    {
                        drag.endDrag(objectToDrag);
                        dragging = false;
                    }
                }
            }
        }
    }
コード例 #15
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (num > 4)
     {
         CalculationAndDo();
     }
     else
     {
         if (start == true)
         {
             var moc = new MockPoint(num);
             Dictionary <Point, Color> dic = new Dictionary <Point, Color>();
             var hashSet = new HashSet <Color>();
             foreach (var item in moc.lst)
             {
                 var point = item;
                 var color = GetColorAt(point);
                 dic.Add(point, color);
             }
             var dicDistin = dic.Values.Distinct().ToList();
             foreach (var item in dicDistin)
             {
                 if (dic.Values.Where(_ => _ == item).Count() == 1)
                 {
                     var find = dic.FirstOrDefault(_ => _.Value == item);
                     MouseOperations.SetCursorPosition(find.Key.X, find.Key.Y);
                     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                     num++;
                     label1.Text = num.ToString();
                     break;
                 }
             }
         }
     }
 }
コード例 #16
0
ファイル: Key.cs プロジェクト: Ahura007/GameClanLeader
        public static void SendKey(int keyCode, Setting setting)
        {
            if (keyCode == (int)Keys.NumPad1)
            {
                for (var i = 1; i <= 2; i++)
                {
                    SendKeys.SendWait(i.ToString());
                    SendKeys.Flush();
                    Clicker.LeftClick(Cursor.Position.X, Cursor.Position.Y, setting.CompressDelay);
                    SendKeys.Flush();
                }
            }

            if (keyCode == (int)Keys.Add)
            {
                Clicker.RightClick(30);
                var temp = Cursor.Position;
                int x    = 50;
                SendKeys.Send("2");
                Thread.Sleep(20);
                Clicker.LeftClick(180, 705, setting.DelayS);
                Thread.Sleep(x + 30);
                SendKeys.Send("1");
                Thread.Sleep(20);
                Clicker.LeftClick(180, 705, setting.DelayS);
                Thread.Sleep(x + 20);
                MouseOperations.SetCursorPosition(temp.X, temp.Y);
                Thread.Sleep(x + 10);
                Clicker.RightClick(20);
            }

            if (keyCode == (int)Keys.NumPad5)
            {
                ShortcutManager.CtrlWith(Keys.N, setting.DelayS);
            }

            if (keyCode == (int)Keys.N)
            {
                ShortcutManager.CtrlWith(Keys.N, setting.DelayS);
            }

            if (keyCode == (int)Keys.G)
            {
                ShortcutManager.CtrlWith(Keys.G, setting.DelayS);
            }

            if (keyCode == (int)Keys.M)
            {
                ShortcutManager.CtrlWith(Keys.M, setting.DelayS);
            }

            if (keyCode == (int)Keys.H)
            {
                ShortcutManager.CtrlWith(Keys.H, setting.DelayS);
            }

            if (keyCode == (int)Keys.B)
            {
                ShortcutManager.CtrlWith(Keys.B, setting.DelayS);
            }

            if (keyCode == (int)Keys.I)
            {
                ShortcutManager.CtrlWith(Keys.I, setting.DelayS);
            }

            if (keyCode == (int)Keys.E)
            {
                var pos = Cursor.Position;
                Clicker.LeftClick(pos.X, pos.Y, setting.DelayS);
                Clicker.LeftClick(586, 707, setting.DelayS);
                MouseOperations.SetCursorPosition(pos.X, pos.Y);
            }

            if (keyCode == (int)Keys.S)
            {
                MoveDirection.Direction(Keys.Down, setting.Direction);
            }

            if (keyCode == (int)Keys.W)
            {
                MoveDirection.Direction(Keys.Up, setting.Direction);
            }

            if (keyCode == (int)Keys.A)
            {
                MoveDirection.Direction(Keys.Left, setting.Direction);
            }

            if (keyCode == (int)Keys.D)
            {
                MoveDirection.Direction(Keys.Right, setting.Direction);
            }

            if (keyCode == (int)Keys.Q)
            {
                var corner = new List <Point>()
                {
                    new Point(159, 732),
                    new Point(192, 730),
                    new Point(162, 760),
                    new Point(192, 759),
                };
                var p = Pip.PointInPolygan(corner).FirstOrDefault();

                var current = new Point(Cursor.Position.X, Cursor.Position.Y);

                Clicker.LeftClick(10);
                MouseMoves.LinearSmoothMove(p, setting.MouseSpeed);
                Clicker.LeftClick(10);
                MouseMoves.LinearSmoothMove(current, setting.MouseSpeed);
            }



            //if (keyCode == (int)Keys.W)
            //{
            //    var p1 = Cursor.Position;
            //    int dddd = 100;
            //    Clicker.LeftClick(p1.X, p1.Y, delayNumber + dddd);
            //    Clicker.LeftClick((p1.X - 63), (p1.Y - 33), delayNumber + dddd);
            //    Clicker.LeftClick((p1.X + 66), (p1.Y - 33), delayNumber + dddd);
            //    Clicker.LeftClick((p1.X), (p1.Y - 66), delayNumber + dddd);
            //}
        }
コード例 #17
0
 private void CalculationAndDo()
 {
     if (start == true)
     {
         var   flgNextCanbeChooseColor = false;
         var   moc                     = new MockPoint(num);
         Color colorCompare            = Color.Black;
         Dictionary <Point, Color> dic = new Dictionary <Point, Color>();
         var hashSet                   = new HashSet <Color>();
         foreach (var item in moc.lst)
         {
             var point = item;
             var color = GetColorAt(point);
             if (flgNextCanbeChooseColor && colorCompare != color)
             {
                 MouseOperations.SetCursorPosition(point.X, point.Y);
                 MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                 MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                 num++;
                 label1.Text = num.ToString();
                 break;
             }
             if (!dic.Values.Contains(color))
             {
                 dic.Add(point, color);
             }
             else // chua
             {
                 if (dic.Count() == 1)
                 {
                     colorCompare            = dic.Values.First();
                     flgNextCanbeChooseColor = true;
                 }
                 else if (dic.Count() == 2) // 2 mau khac nhau, them 1 mau moi
                 {
                     var cl1 = dic.Values.First();
                     if (cl1 == color)
                     {
                         var find = dic.Keys.Last();
                         MouseOperations.SetCursorPosition(find.X, find.Y);
                         MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                         MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                         num++;
                         label1.Text = num.ToString();
                         break;
                     }
                     else
                     {
                         var find = dic.Keys.First();
                         MouseOperations.SetCursorPosition(find.X, find.Y);
                         MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                         MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                         num++;
                         label1.Text = num.ToString();
                         break;
                     }
                 }
             }
         }
     }
 }
コード例 #18
0
ファイル: ClientApi.cs プロジェクト: ugursoysal/Device
        private static bool EnterPassword(ClientWindow clientWindow, string[] par)
        {
            try
            {
                //hWnd = clientWindow.Handle.ToInt32();
                NativeMethods.Focus(clientWindow.InnerWindow.Handle);
                //Logger.Log("hWnd: " + hWnd.ToString());
                Thread.Sleep(1000);
                //NativeMethods.ShowWindow(hWnd, SW_HIDE);
                Thread.Sleep(5000);

                Rectangle userBox     = clientWindow.UsernameBox;
                Rectangle passwordBox = clientWindow.PasswordBox;
                NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, userBox.Left + passwordBox.Width / 2, userBox.Top + userBox.Height / 2);
                NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, userBox.Left + passwordBox.Width / 2, userBox.Top + userBox.Height / 2);

                for (int i = 0; i < 20; i++)
                {
                    NativeMethods.SendKey(clientWindow.InnerWindow.Parent.Handle, VKey.BACK);
                    NativeMethods.SendKey(clientWindow.InnerWindow.Parent.Handle, VKey.DELETE);
                }
                NativeMethods.SendText(clientWindow.InnerWindow.Parent.Handle, par[0]);

                NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, passwordBox.Left + passwordBox.Width / 2, passwordBox.Top + passwordBox.Height / 2);
                NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, passwordBox.Left + passwordBox.Width / 2, passwordBox.Top + passwordBox.Height / 2);

                for (int i = 0; i < 20; i++)
                {
                    NativeMethods.SendKey(clientWindow.InnerWindow.Parent.Handle, VKey.BACK);
                    NativeMethods.SendKey(clientWindow.InnerWindow.Parent.Handle, VKey.DELETE);
                }
                NativeMethods.SendText(clientWindow.InnerWindow.Parent.Handle, par[1]);

                for (int i = 0; i < 20; i++)
                {
                    NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, clientWindow.DialogBox.Left + clientWindow.DialogBox.Width / 2, clientWindow.DialogBox.Top + clientWindow.DialogBox.Height / 2 - (int)(i * 2 * clientWindow.Scale));
                }
                Thread.Sleep(10000);

                for (int i = 0; i < 4; i++)
                {
                    MouseOperations.SetCursorPosition(500 + GameSession.RandomTimeGenerator(50), 350 + GameSession.RandomTimeGenerator(50));
                    Thread.Sleep(500);
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                    Thread.Sleep(GameSession.RandomTimeGenerator(24));
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                }
                Thread.Sleep(6000);
                Server.SetInfoText("Checking login status...");
                //NativeMethods.ShowWindow(hWnd, SW_HIDE);
                //NativeMethods.ShowWindow(clientWindow.InnerWindow.Handle.ToInt32(), SW_HIDE);
                try
                {
                    if (!CheckLockfile())
                    {
                        var newCapture = clientWindow.InnerWindow.Capture();
                        for (int i = 0; i < 2; i++)
                        {
                            NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, newCapture.Width / 2, newCapture.Height / 2);
                            NativeMethods.SendKey(clientWindow.InnerWindow.Parent.Handle, VKey.END);
                        }
                        Thread.Sleep(1000);

                        /*newCapture = clientWindow.InnerWindow.Capture();
                         * Bitmap output = new Bitmap(newCapture);
                         * using (var graphics = Graphics.FromImage(output)){*/
                        int baseCaptureWidth  = newCapture.Width / 2 - newCapture.Width / 50;
                        int baseCaptureHeight = newCapture.Height / 2 + newCapture.Height / 40;
                        for (int i = 0; i < 10; i++)
                        {
                            /* Rectangle tang = new Rectangle(baseCaptureWidth - i * (newCapture.Width / 90), baseCaptureHeight + i * (newCapture.Height / 45), 7, 3);
                             *
                             * graphics.DrawRectangle(new Pen(Color.Gold, 1), tang);
                             * tang = new Rectangle(baseCaptureWidth - i * (newCapture.Width / 90), baseCaptureHeight + i * (newCapture.Height / 45) + (newCapture.Height / 6), 7, 3);
                             *
                             * graphics.DrawRectangle(new Pen(Color.AliceBlue, 1), tang);*/

                            NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, baseCaptureWidth - i * (newCapture.Width / 90), baseCaptureHeight + i * (newCapture.Height / 45) + (newCapture.Height / 6));
                            NativeMethods.SendMouseClick(clientWindow.InnerWindow.Handle, baseCaptureWidth - i * (newCapture.Width / 90), baseCaptureHeight + i * (newCapture.Height / 45));
                        }/*
                          * Util.SaveDebugImage(output, @"okk.png");*/
                        clientWindow.RefreshStatus();
                        // }
                    }
                }
                catch (Exception x)
                {
                    Server.SetInfoText("Can't enter password.");
                    Logger.Log("Can't enter password. Details: " + x.Message);
                }
            }
            catch (Exception x)
            {
                Server.SetInfoText("Couldn't log in with the provided credentials.");
                Logger.Log("Couldn't log in with the provided credentials. Details: " + x.Message);
                StopLOLClient();
            }

            Thread.Sleep(6000);
            if (!CheckLockfile())
            {
                return(false);
            }
            return(true);

            /*Thread.Sleep(30000);
             * if (!Util.CheckLockfile())
             * {
             *  Util.KillAllLeagueClientProcesses();
             *  Message.Error($"Hesap bilgileri programa aktarılamadı. (0x90)");
             * }*/
            //clientWindow.InnerWindow.Parent.SendKey(VirtualKeyCode.RETURN);

            //Logger.Info("Successfully entered password (well, hopefully)");
        }
コード例 #19
0
        private void SecondsTimerCallback(object state)
        {
            //Logger.Log("sec tim");
            if (GameState.Started == true && !Player.Dead())
            {
                /*Stopwatch all = new Stopwatch();
                 * all.Start();*/
                // var bmp = ImageUtils.TakeSmallCapture(0, 0, 1024, 768);
                try
                {
                    var   bmp = PixelCache.GetScreenshot();
                    Color col = bmp.GetPixel(300, 300);
                    if (col != LastScreenColor)
                    {
                        TimerTick = DateTime.Now.Ticks;
                    }
                    LastScreenColor = col;
                    me = ImageValues.GetMyPosition(bmp);
                    Point tower      = ImageValues.EnemyTowerPosition(bmp);
                    Point enemy      = ImageValues.EnemyPosition(bmp);
                    Point enemyCreep = ImageValues.EnemyCreepPosition(bmp);
                    Point ally       = ImageValues.AllyPosition(bmp);
                    Point allyCreep  = ImageValues.AllyCreepPosition(bmp);

                    int hpercent    = Player.GetHealthPercent();
                    int hpDiff      = ImageValues.GetHPDifference(bmp);
                    int creepHpDiff = ImageValues.GetCreepHPDifference(bmp);
                    //int distanceEnemyCreep = ImageValues.GetDistanceFromOrigin(enemyCreep);
                    var  pressNothing = false;
                    bool Attack       = false;
                    int  baseX        = 757;
                    int  baseY        = 145;
                    if (tower.Y > 5 || enemy.Y > 15 || enemyCreep.Y > 15)
                    {
                        baseX = 566; //allyCreep.X;
                        baseY = 350; //allyCreep.Y;*/
                    }
                    //Server.SetInfoText("Calculating...");

                    /* FORWARD
                     *  baseX = 757;//allyCreep.X;
                     *  baseY = 145;//allyCreep.Y;*/
                    /* MIDDLE
                     *  baseX = 566;//allyCreep.X;
                     *  baseY = 357;//allyCreep.Y;*/
                    /* BACK
                     *  baseX = 46;
                     *  baseY = 695;*/
                    if (hpDiff < -50 || creepHpDiff < -40)
                    {/*
                      * Server.SetInfoText("OK."
                      + Environment.NewLine + (hpDiff < -50).ToString()
                      + Environment.NewLine + (creepHpDiff < -40).ToString());*/
                        Attack = true;
                        if (goB > 0)
                        {
                            goB = 20;
                        }
                    }
                    if (Player.game.CurrentHealth < healthBefore ||
                        (goB < 1 && hpercent < 20) ||
                        tower.Y > 100 ||
                        hpDiff + (hpercent / 2) < -245 ||
                        (creepHpDiff < -150 && allyCreep.X == 0) ||
                        enemyCreep.Y > 380)
                    {
                        /*if (tower.Y > 110)
                         *  Logger.Log("tower.Y = " + tower.Y + " > 110");
                         * else if (Player.game.Level < 13 && creepHpDiff < -150 && allyCreep.X == 0)
                         *  Logger.Log("creepHpDiff = " + creepHpDiff + " < -150 && allyCreep.X = 0");
                         * else if (hpDiff + (hpercent / 2) < -260)
                         *  Logger.Log("hpDiff + (hpercent / 2) = " + (hpDiff + (hpercent / 2)).ToString() + " < -245");
                         * else if (enemyCreep.Y > 380)
                         *  Logger.Log("enemyCreep.Y = " + enemyCreep.Y + " > 380");*/
                        //Server.SetInfoText("Need to get back.");
                        if (tower.Y > 110 || hpDiff < -700)
                        {
                            secondHP = 2;
                        }
                        else
                        {
                            secondHP = 1;
                        }
                        if (goB > 0)
                        {
                            goB = 20;
                        }
                    }
                    if (secondHP > 0)
                    {
                        Attack = false;
                        baseX  = 46;
                        baseY  = 695;
                        secondHP--;
                    }
                    else if (goB > 0)
                    {
                        if (hpercent > 90)
                        {
                            goB = 1;
                        }
                        if (goB == 20)
                        {
                            if (enemy.X > 0 || enemyCreep.X > 0 || tower.X > 0)
                            {
                                secondHP = 2;
                            }
                            else
                            {
                                Keyboard.KeyPress(System.Windows.Forms.Keys.B);
                                goB--;
                                pressNothing = true;
                            }
                        }
                        else if (goB < 20)
                        {
                            goB--;
                            pressNothing = true;
                        }
                        if (goB == 0)
                        {
                            if (hpercent < 95)
                            {
                                goB = 5;
                            }
                            else if (hpercent < 50)
                            {
                                goB = 20;
                            }
                            else
                            {
                                //-----buyitems
                                Server.SetInfoText("Buying items...");
                                int gold = Player.GetGold();
                                foreach (var x in items)
                                {
                                    if (x.got == false)
                                    {
                                        if (gold > x.cost)
                                        {
                                            if (!Shop.Opened)
                                            {
                                                Shop.Toggle();
                                                Thread.Sleep(RandomTimeGenerator(500));

                                                /*MouseOperations.SetCursorPosition(420 + RandomTimeGenerator(5), 80 + RandomTimeGenerator(4));
                                                 * Thread.Sleep(RandomTimeGenerator(200));
                                                 * MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                                                 * Thread.Sleep(RandomTimeGenerator(50));
                                                 * MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);*/
                                                Keyboard.ShortcutKeys(new System.Windows.Forms.Keys[] { System.Windows.Forms.Keys.ControlKey, System.Windows.Forms.Keys.L }, RandomTimeGenerator(40));
                                                Thread.Sleep(RandomTimeGenerator(1000));
                                            }
                                            Thread.Sleep(RandomTimeGenerator());
                                            string str = x.phrase;
                                            foreach (char c in str)
                                            {
                                                Thread.Sleep(RandomTimeGenerator(150));
                                                Keyboard.KeyPress((System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), c.ToString()), RandomTimeGenerator(50));
                                            }
                                            Thread.Sleep(RandomTimeGenerator(500));
                                            MouseOperations.SetCursorPosition(377 + RandomTimeGenerator(15), 146 + RandomTimeGenerator(8));

                                            Thread.Sleep(RandomTimeGenerator(150));
                                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                                            Thread.Sleep(RandomTimeGenerator(40));
                                            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                                            Thread.Sleep(RandomTimeGenerator(500));
                                            Server.SetInfoText("Bought " + x.name);

                                            for (int i = 0; i < str.Length; i++)
                                            {
                                                Thread.Sleep(RandomTimeGenerator(100));
                                                Keyboard.KeyPress(System.Windows.Forms.Keys.Back);
                                            }
                                            x.got = true;
                                            gold -= x.cost;
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                }
                                Thread.Sleep(RandomTimeGenerator());
                                if (Shop.Opened)
                                {
                                    Shop.Toggle();
                                }
                                //-----buyitems
                                pressNothing = true;

                                /* baseX = 566;//allyCreep.X;
                                 * baseY = 357;//allyCreep.Y;*/
                                goB = -1;
                            }
                        }
                    }
                    else if (allyCreep.X == 0)
                    {
                        //Server.SetInfoText("No ally in sight.");
                        if (enemyCreep.X != 0 || enemy.X != 0 || tower.X != 0)
                        {
                            secondHP = 2;
                        }
                    }
                    else
                    {
                        baseX = allyCreep.X;
                        baseY = allyCreep.Y;
                        if (enemyCreep.X != 0)
                        {
                            Attack = true;
                            Server.SetInfoText("Attacking creeps.");
                            baseX = 566; //allyCreep.X;
                            baseY = 350; //allyCreep.Y;
                        }
                        else if (tower.Y < 15 && enemy.X != 0 && (allyCreep.X != 0 || ally.X != 0) && hpDiff > -400)
                        {
                            Attack = true;
                            Server.SetInfoText("Attacking enemy.");
                            baseX = 566; //allyCreep.X;
                            baseY = 350; //allyCreep.Y;
                        }
                        else if (tower.X != 0)
                        {
                            Attack = true;
                            Server.SetInfoText("Attacking tower.");
                            baseX = 566; //allyCreep.X;
                            baseY = 350; //allyCreep.Y;
                        }
                    }
                    //Server.SetInfoText("Calculated...");
                    if (!pressNothing)
                    {
                        Random rand = new Random();
                        int    r1   = rand.Next(-15, 15);
                        int    r2   = rand.Next(-14, 14);

                        if (hpercent > 10 && Attack && (ally.X != 0 || r1 > 8) && (enemyCreep.X > 0 || enemy.X > 0) && hpercent > 30 && Player.GetManaPercent() > 30)
                        {
                            new Thread(() =>
                            {
                                if (enemy.X > 0)
                                {
                                    MouseOperations.SetCursorPosition(enemy.X, enemy.Y + RandomTimeGenerator(10));
                                }
                                else
                                {
                                    MouseOperations.SetCursorPosition(enemyCreep.X, enemyCreep.Y + RandomTimeGenerator(10));
                                }
                                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                                Thread.Sleep(RandomTimeGenerator(30));
                                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                                Thread.Sleep(RandomTimeGenerator(100));
                                int choice = rand.Next(1, 4);
                                if (enemy.X > 0)
                                {
                                    choice += 1;
                                }
                                DoRandomSkill(choice);
                                //Server.SetInfoText("doskill: " + choice);
                            }).Start();
                        }
                        else
                        {
                            MouseOperations.SetCursorPosition(baseX + r1, baseY + r2);
                            if (Attack && hpercent > 20)
                            {
                                Keyboard.KeyPress(System.Windows.Forms.Keys.A);
                            }
                            else if (!Attack)
                            {
                                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                                Thread.Sleep(RandomTimeGenerator(12));
                                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                            }
                        }
                    }
                    bmp.Dispose();
                    //all.Stop();
                    healthBefore = Player.game.CurrentHealth;

                    /* Logger.Log("ms: " + all.ElapsedMilliseconds.ToString());
                     * string ftr = "me:" + me.ToString() + Environment.NewLine
                     + "tower:" + tower.ToString() + Environment.NewLine
                     + "e:" + enemy.ToString() + Environment.NewLine
                     + "ec:" + enemyCreep.ToString() + Environment.NewLine
                     + "a:" + ally.ToString() + Environment.NewLine
                     + "a:" + allyCreep.ToString() + Environment.NewLine
                     + "hpDiff:" + hpDiff.ToString() + Environment.NewLine
                     + "creepHpDiff:" + creepHpDiff.ToString() + Environment.NewLine;
                     + Logger.Log(ftr);*/
                    //Logger.Log("me:" + me.ToString());
                    //Server.SetInfoText(ftr);
                }
                catch (Exception x)
                {
                    Logger.Log("seconds timer error: " + x.Message);
                }
            }

            GameState.Started = (Player.GetGold() != 0);
            if (GameState.Started == false)
            {
                Logger.Log("seconds timer stopped - finish game...");
                FinishGame();
            }
            else
            {
                if (SecondsTimer != null)
                {
                    ClientApi.TimerChange(SecondsTimer, RandomTimeGenerator());
                }
                else
                {
                    Logger.Log("seconds timer stopped - restarting...");
                    SecondsTimer = new Timer(SecondsTimerCallback, null, RandomTimeGenerator(), Timeout.Infinite);
                    if (TenSecondsTimer == null)
                    {
                        Logger.Log("10sec timer stopped - restarting...");
                        TenSecondsTimer = new Timer(TenSecondsTimerCallback, null, RandomTimeGenerator(10000), Timeout.Infinite);
                    }
                }
            }
        }
コード例 #20
0
        private void GameTimerCallback(object state)
        {
            try
            {
                //Logger.Log("game tim: " + GameState.Started);
                GameTimerTry++;
                TimerTick = DateTime.Now.Ticks;
                // waiting for game to start
                if (GameState.Started == false)
                {
                    //Logger.Log("ee");
                    try
                    {
                        //Logger.Log("k1");
                        Player = new MainPlayer(((Port = GetPort()) != 0) ? Port : 2999);
                        //Logger.Log("k3 p: " + Port);

                        /*if (Player != null)
                         *  Logger.Log("gts p: " + Port + " currenthealth: " + Player.game.CurrentHealth + " money: " + Player.GetGold());
                         */
                        if (Player != null && Player?.game?.CurrentHealth != 1)
                        {
                            GameState.Started = Player.GetGold() != 0;
                            //er.Log("k4 "+ GameState.Started);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Waiting for game to start... (err)");
                        Logger.Log("wait err: " + ex.Message);
                        Server.SetInfoText("Waiting for game to start... (err)");
                    }
                    if (GameTimerTry == 50)
                    {
                        Server.SetInfoText("Still waiting...");
                        Control();
                    }
                    //Logger.Log("gtfalse2");
                    if (GameTimerTry > 55)
                    {
                        Control();
                        if (LCU.SummonerID == 0)
                        {
                            if (Server.LoadedAccount != null)
                            {
                                GameTimerTry = 0;
                                ClientApi.Stop();
                                Logger.Log("Restarting bot...");
                                Server.SetInfoText("Restarting bot...");
                                Thread.Sleep(10000);
                                ClientApi.Start();
                            }
                            else
                            {
                                Logger.Log("Can't find the loaded account.");
                                Server.SetInfoText("Can't find the loaded account.");
                            }
                        }
                        else
                        {
                            var process = ClientApi.GetProcessByName("League of Legends");
                            if (process == null)
                            {
                                try
                                {
                                    Logger.Log("Trying to continue...");
                                    Server.SetInfoText("Trying to continue...");
                                    var bmp = PixelCache.GetScreenshot();
                                    bmp.Bitmap.Save("qr1.bmp");
                                    bmp.Dispose();
                                    ClientApi.TryToContinue();
                                    Logger.Log("Restarting queue...");
                                    Server.SetInfoText("Restarting queue...");
                                    GameTimerTry = 0;
                                    ClientApi.StartNewGame();
                                }
                                catch (Exception x)
                                {
                                    Logger.Log("queuerestart1 (1) image error..." + x.Message);
                                    Thread.Sleep(5000);
                                    ClientApi.Stop();
                                    Logger.Log("Can't take screenshots. Trying to continue...");
                                    Server.SetInfoText("Can't take screenshots. Trying to continue...");
                                    Control(false);
                                    ClientApi.Start();
                                }
                            }
                            else
                            {
                                bool flag = false;
                                try
                                {
                                    var bmp = PixelCache.GetScreenshot();
                                    bmp.Bitmap.Save("copen.bmp");
                                    if (bmp.GetPixel(495, 352) == Color.FromArgb(59, 45, 24) ||
                                        bmp.GetPixel(507, 344) == Color.FromArgb(255, 255, 255))
                                    {
                                        flag = true;
                                    }
                                    bmp.Dispose();
                                    if (flag)
                                    {
                                        Logger.Log("connection lost");
                                    }
                                    else
                                    {
                                        Logger.Log("copen ok");
                                    }
                                }
                                catch (Exception x)
                                {
                                    Logger.Log("copen (1) image error..." + x.Message);
                                    flag = true;
                                }
                                if (flag)
                                {
                                    ClientApi.Stop();
                                    Logger.Log("Connection lost. Trying to continue...");
                                    Server.SetInfoText("Connection lost. Trying to continue...");
                                    Thread.Sleep(5000);
                                    ClientApi.Restart = true;
                                    ClientApi.Start();
                                }
                            }
                        }
                    }
                    else if (GameTimer != null)
                    {
                        ClientApi.TimerChange(GameTimer, 8000);
                    }

                    //Logger.Log("gtfalse3");
                }
                else
                {
                    //Logger.Log("gttrue1");
                    if (LOLHandle != null)
                    {
                        NativeMethods.Focus(LOLHandle);
                    }
                    else
                    {
                        Logger.Log("LOLHandle = null (?)");
                    }
                    ClientApi.SetState(ClientStates.InGame);
                    Server.SetIndicator(IndicatorStates.On);
                    TimerTick = DateTime.Now.Ticks;
                    //Logger.Log("gttrue2");

                    if (Port != 0 && Player == null)
                    {
                        Player = new MainPlayer(Port);
                    }
                    Shop = new Shop();
                    if (Start == 0)
                    {
                        Logger.Log("Game started.");
                        Server.SetInfoText("Game started.");
                        try
                        {
                            int gold = Player.GetGold();
                            foreach (var x in items)
                            {
                                if (x.got == false)
                                {
                                    if (gold > x.cost)
                                    {
                                        if (!Shop.Opened)
                                        {
                                            //Logger.Log("opening shop");
                                            Shop.Toggle();
                                            Thread.Sleep(RandomTimeGenerator(500));/*
                                                                                    * MouseOperations.SetCursorPosition(420 + RandomTimeGenerator(5), 80 + RandomTimeGenerator(4));
                                                                                    * Thread.Sleep(RandomTimeGenerator(200));
                                                                                    * MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                                                                                    * Thread.Sleep(RandomTimeGenerator(50));
                                                                                    * MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);*/
                                            Keyboard.ShortcutKeys(new System.Windows.Forms.Keys[] { System.Windows.Forms.Keys.ControlKey, System.Windows.Forms.Keys.L }, 40);
                                            Thread.Sleep(RandomTimeGenerator(1000));
                                        }
                                        Thread.Sleep(RandomTimeGenerator());
                                        string str = x.phrase;

                                        //Logger.Log("buying: " + x.name);
                                        foreach (char c in str)
                                        {
                                            Thread.Sleep(RandomTimeGenerator(150));
                                            Keyboard.KeyPress((System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), c.ToString()), RandomTimeGenerator(50));
                                        }
                                        Thread.Sleep(RandomTimeGenerator(500));
                                        MouseOperations.SetCursorPosition(377 + RandomTimeGenerator(15), 146 + RandomTimeGenerator(8));

                                        Thread.Sleep(RandomTimeGenerator(150));
                                        MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                                        Thread.Sleep(RandomTimeGenerator(40));
                                        MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                                        Thread.Sleep(RandomTimeGenerator(500));
                                        Server.SetInfoText("Bought " + x.name);
                                        //Logger.Log("bought: " + x.name);

                                        for (int i = 0; i < str.Length; i++)
                                        {
                                            Thread.Sleep(RandomTimeGenerator(100));
                                            Keyboard.KeyPress(System.Windows.Forms.Keys.Back);
                                        }
                                        x.got = true;
                                        gold -= x.cost;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                            Thread.Sleep(RandomTimeGenerator());

                            /*if (Shop.Opened)
                             *  Logger.Log("closing shop");*/
                            if (Shop.Opened)
                            {
                                Shop.Toggle();
                            }
                            Thread.Sleep(RandomTimeGenerator());
                            Server.SetInfoText("Bought first items.");
                            Thread.Sleep(RandomTimeGenerator(35000) + 7500);
                        }
                        catch (Exception x)
                        {
                            Logger.Log("gg: " + x.Message);
                        }
                    }
                    else
                    {
                        Thread.Sleep(RandomTimeGenerator(10000));
                        Logger.Log("Game (re)started.");
                        Server.SetInfoText("Game (re)started.");
                        Start        = 0;
                        items[0].got = true;
                    }
                    //Logger.Log("gttrue3 - after start");
                    try
                    {
                        var   bmp = PixelCache.GetScreenshot();
                        Color col = bmp.GetPixel(795, 756);
                        if (col.R != 0 && col.R != 255 && col.R != 165 && col.G != 142 && col.B != 99)
                        {
                            Keyboard.KeyPress(System.Windows.Forms.Keys.Y, RandomTimeGenerator(50));
                            string str = "Fixed camera." /* + Environment.NewLine + "R:" + col.R + " G:" + col.G + " B:" + col.B*/;
                            Server.SetInfoText(str);
                            Logger.Log(str);
                        }
                        if (bmp != null)
                        {
                            bmp.Dispose();
                        }
                    }
                    catch (Exception x)
                    {
                        Logger.Log("getscreen problem: " + x.Message);
                    }
                    Logger.Log("starting timers");
                    MinuteTimer     = new Timer(MinuteTimerCallback, null, MinuteTimerInterval, Timeout.Infinite);
                    HalfMinuteTimer = new Timer(HalfMinuteTimerCallback, null, 30000, Timeout.Infinite);
                    TenSecondsTimer = new Timer(TenSecondsTimerCallback, null, 10000, Timeout.Infinite);
                    SecondsTimer    = new Timer(SecondsTimerCallback, null, 1000, Timeout.Infinite);
                    Logger.Log("started");
                    SkillUp(2);
                    if (GameTimer != null)
                    {
                        GameTimer.Dispose();
                        GameTimer = null;
                    }
                    //Logger.Log("gtend");
                }
            }
            catch (Exception e)
            {
                try
                {
                    var bmp = PixelCache.GetScreenshot();
                    bmp.Bitmap.Save("fe1.bmp");
                    bmp.Dispose();
                }
                catch (Exception x)
                {
                    Logger.Log("fatal (1) image error..." + x.Message);
                }
                Logger.Log("fatal error: gametimer \r\n" + e.Message);

                /*
                 * MinuteTimer = new Timer(MinuteTimerCallback, null, MinuteTimerInterval, Timeout.Infinite);
                 * HalfMinuteTimer = new Timer(HalfMinuteTimerCallback, null, 30000, Timeout.Infinite);
                 * TenSecondsTimer = new Timer(TenSecondsTimerCallback, null, 10000, Timeout.Infinite);
                 * SecondsTimer = new Timer(SecondsTimerCallback, null, 1000, Timeout.Infinite);
                 * SkillUp(2);*/
                if (GameTimer != null)
                {
                    GameTimer.Dispose();
                    GameTimer = null;
                }
            }
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: adryzz/PCRemote
 public static byte MoveMouse(int x, int y)
 {
     MouseOperations.SetCursorPosition(x, y);
     Console.WriteLine("Moving the mouse to " + x + ", " + y);
     return(0x01);
 }
コード例 #22
0
 public void CleanUp()
 {
     MouseOperations.SetCursorPosition(GetCenterScreen());
 }