Beispiel #1
0
        public static byte ClickMouse(byte button)
        {
            byte result = 0x02;

            switch (button)
            {
            case 0x00:    //left
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                Console.WriteLine("Mouse click: left button");
                result = 0x01;
                break;
            }

            case 0x01:    //middle
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.MiddleUp);
                Console.WriteLine("Mouse click: middle button");
                result = 0x01;
                break;
            }

            case 0x02:    //right
            {
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                Console.WriteLine("Mouse click: right button");
                result = 0x01;
                break;
            }
            }
            return(result);
        }
Beispiel #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);
        }
    }
Beispiel #3
0
        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));
        }
Beispiel #4
0
 // Update is called once per frame
 void Update()
 {
     if (Controller.GetHairTriggerUp())
     {
         Debug.Log("controller input");
         MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp | MouseOperations.MouseEventFlags.LeftDown);
     }
 }
Beispiel #5
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);
        }
Beispiel #6
0
        /// <summary> Performs a sequence of screen captures </summary>
        /// <para>* This function is hand-written for a particular scenario and it is only interesting for the bits of code inside, not so much for reuse</para>
        static void SequencedCapture()
        {
            for (int i = 0; i < 200; i++)
            {
                ScreenOperations.ImageSave("%NOW%"
                                           , System.Drawing.Imaging.ImageFormat.Png
                                           , ScreenOperations.CaptureWindow(80, 297, 2040, 2850));

                System.Threading.Thread.Sleep(2000);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            }
        }
Beispiel #7
0
        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
        }
        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);
            }
        }
Beispiel #9
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();
        }
    // 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;
        }
    }
Beispiel #11
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);
        }
Beispiel #12
0
    /// <summary>
    /// Send a left click with a hold time defined by "holdTime". Used to find a new random location to click and store if moved towards goal.
    /// </summary>
    /// <returns></returns>
    IEnumerator LeftClickForever()
    {
        while (isRunning)
        {
            // If not above the gate
            if (gateLocation.x - bodyPosition.x >= 3 || gateLocation.x - bodyPosition.x <= -3)
            {
                // Get a random location to try
                GetRayClickLocation();

                // If a new click location was found, then click
                if (newClickLocationFound)
                {
                    // Hold left click on the location
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                    // Wait for holdTime
                    yield return(new WaitForSeconds(holdTime));

                    // Let go of left click
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                    // Wait for longer
                    yield return(new WaitForSeconds(timeBetweenSwings));

                    // Reset click location bool
                    newClickLocationFound = false;
                }
                else
                {
                    // Wait for noClickWaitTime
                    yield return(new WaitForSeconds(noClickWaitTime));
                }
            }
            // If above the gate
            else
            {
                // Wait for noClickWaitTime
                yield return(new WaitForSeconds(noClickWaitTime));
            }
        }
    }
Beispiel #13
0
        private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            switch (msg)
            {
            case WM_HOTKEY:
                switch (wParam.ToInt32())
                {
                case HOTKEY_ID:
                    int vkey = (((int)lParam >> 16) & 0xFFFF);
                    if (vkey == KeyInterop.VirtualKeyFromKey((Key)Properties.Settings.Default.Key))
                    {
                        MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                    }
                    handled = true;
                    break;
                }
                break;
            }
            return(IntPtr.Zero);
        }
Beispiel #14
0
        private void HandleHotkey()
        {
            if (hg_w1.X == -1)
            {
                hg_w1 = Cursor.Position;
            }
            else if (hg_w2.X == -1)
            {
                hg_w2 = Cursor.Position;
            }
            else
            {
                var currentPos = Cursor.Position;
                Cursor.Position = new Point(currentPos.X + (hg_w2.X - hg_w1.X), currentPos.Y);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);

                Cursor.Position = currentPos;

                //MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                //MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            }
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                SequencedCapture();
            }

            try
            {
                int delay = int.Parse(args[0]);
                while (true)
                {
                    //MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                    //MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.Move);
                    //Console.WriteLine("Clicked");
                    System.Threading.Thread.Sleep(delay * 1000);
                }
            }
            catch (Exception e) {
                Console.WriteLine("Could not parse argument as numeric");
                Console.ReadKey();
            }
        }
Beispiel #16
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;
                 }
             }
         }
     }
 }
 private void LeftRelease()
 {
     _isLeftHeldDown = false;
     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
 }
Beispiel #18
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;
                }
            }
        }
Beispiel #19
0
        private void isOnGui()
        {
            if (LocalPlayer.Base == null)
            {
                return;
            }

            if (Settings.CAimH.KillaMode)
            {
                Print.Special.DrawText("KillaMode", vars.box2, vars.drawTextStyle);
            }
            else
            {
                Print.Special.DrawText(onWhatImGonnaAimAt(), vars.box2, vars.drawTextStyle);
            }
            if (Settings.CAimH.AimkeyFS && !Settings.CAimH.AimkeyFOV)
            {
                Print.Special.DrawText("Aim FS " + vars.vector.ToString() + " - " + vars.BodyPart_AimedAt.ToString(), vars.box, vars.drawTextStyle);
            }
            if (Settings.CAimH.AimkeyFOV && !Settings.CAimH.AimkeyFS)
            {
                Print.Special.DrawText("Aim FOV", vars.box, vars.drawTextStyle);
            }
            if (!Settings.CAimH.AimkeyFOV && !Settings.CAimH.AimkeyFS)
            {
                return;
            }
            vars.camera = Camera.main;
            if (!vars.camera)
            {
                return;
            }
            if (vars.countObj == 0)
            {
                return; // return if no object found
            }
            if (vars.PlayerAimedAt == null)
            {
                return; // oh somehow you get a default player object ... LOL
            }
            if (vars.BodyPart_AimedAt != AimBodyPart.Null)
            {
                vars.vector = Functions.PlayerBones.FinalVector(vars.PlayerAimedAt.PlayerBody.SkeletonRootJoint, (int)vars.BodyPart_AimedAt);// vars.PlayerAimedAt.PlayerBones.Head.position;// Functions.PlayerBones.FinalVector(vars.PlayerAimedAt.PlayerBody.SkeletonRootJoint, aimAtBodyPart);
            }
            else
            {
                return;
            }
            if (Settings.CAimH.DrawSnapLine)
            {
                #region DrawLineToTarget
                if (MaociScreen.onScreenStrict(vars.camera.WorldToScreenPoint(vars.PlayerAimedAt.Transform.position)))
                {
                    vars.prioritizeTarget   = vars.camera.WorldToScreenPoint(vars.vector);
                    vars.prioritizeTarget.y = MaociScreen.height - vars.prioritizeTarget.y;
                    Print.Line.Draw(vars.centerOfScreen, vars.prioritizeTarget, vars.colorToTarget, 2f);
                }
                #endregion
            }

            if (vars.vector != Vector3.zero)
            {
                if (!Settings.CAimH.AimkeyFS)
                {
                    if (Vector2.Distance(vars.centerOfScreen, vars.camera.WorldToScreenPoint(vars.vector)) > Settings.CAimH.FOV)
                    {
                        return;                                                                                                          // if not in FOV and FS is not pressed return
                    }
                }
                vars.distanceToTarget = Vector3.Distance(Camera.main.transform.position, vars.vector);
                vars.travelTime       = vars.distanceToTarget / LocalPlayer.Base.Weapon.CurrentAmmoTemplate.InitialSpeed;
                vars.vector          += vars.PlayerAimedAt.Velocity * vars.travelTime; // aim prediction to target move point depends on player movement
                vars.vector          -= LocalPlayer.Base.Velocity * Time.deltaTime;
                // should increase aiming by countind bullet drop
                if (vars.distanceToTarget > 100f)
                {
                    vars.vector = vars.vector + Vector3.up * func.BulletDrop(LocalPlayer.Base.Fireport.position, vars.vector, LocalPlayer.Base.Weapon.CurrentAmmoTemplate.InitialSpeed);
                }
                // predict own player movement and compensage aiming
                // strangely changes position of esp ... //Camera.main.transform.LookAt(vars.vector);
                //LocalPlayer.Base.Transform.LookAt(, Camera.main.transform.up);
                func.AimAtPos(vars.vector);
                if (NextMouseClick < Time.time && Settings.CAimH.AutoShoot && Raycast.isBodyPartVisible(vars.PlayerAimedAt, (int)vars.BodyPart_AimedAt))
                {// no need to viss check here cause we already know target is visible - making less cykles is better
                    MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp | MouseOperations.MouseEventFlags.LeftDown);
                    NextMouseClick = Time.time + 0.064f;
                }
            }
        }
Beispiel #20
0
 public static void MouseClick()
 {
     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
     //Thread.Sleep(delay);
     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
 }
Beispiel #21
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;
                     }
                 }
             }
         }
     }
 }
Beispiel #22
0
 public override void Invoke()
 {
     MouseOperations.MouseEvent(mouseEvent);
 }
 private void LeftDown()
 {
     _isLeftHeldDown = true;
     InitLongPress();
     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
 }
Beispiel #24
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);
                    }
                }
            }
        }
Beispiel #25
0
        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)");
        }
 private void RightDown()
 {
     _isRightHeldDown = true;
     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
 }
 private void RightRelease()
 {
     _isRightHeldDown = false;
     MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
 }
        public void wiimoteChanged(String wsJSON)
        {
            if (playerIndex != 1)
            {
                return;
            }

            WiimoteState ws = JsonConvert.DeserializeObject <WiimoteState>(wsJSON);

            MouseOperations mouseOperations = new MouseOperations();

            MouseOperations.MouseEventFlags leftUpMouse    = MouseOperations.MouseEventFlags.LeftUp;
            MouseOperations.MouseEventFlags leftDownMouse  = MouseOperations.MouseEventFlags.LeftDown;
            MouseOperations.MouseEventFlags rightUpMouse   = MouseOperations.MouseEventFlags.RightUp;
            MouseOperations.MouseEventFlags rightDownMouse = MouseOperations.MouseEventFlags.RightDown;

            if (ws.ButtonState.B == true)
            {
                if (this.BButton == false)
                {
                    MouseOperations.MouseEvent(rightDownMouse);
                    this.BButton = true;
                    isRumbling   = true;
                    Delay.executeAfter(50, () =>
                    {
                        isRumbling = false;
                    });
                }
            }
            else
            {
                if (this.BButton == true)
                {
                    MouseOperations.MouseEvent(rightUpMouse);
                    this.BButton = false;
                    isRumbling   = false;
                }
            }


            if (ws.ButtonState.A == true)
            {
                if (this.AButton == false)
                {
                    MouseOperations.MouseEvent(leftDownMouse);
                    this.AButton = true;
                }
            }
            else
            {
                if (this.AButton == true)
                {
                    MouseOperations.MouseEvent(leftUpMouse);
                    this.AButton = false;
                }
            }

            if (ws.ButtonState.One == true)
            {
                generateKeyPressThread(Keys.A, 0, 0);
            }

            if (ws.ButtonState.Up == true)
            {
                generateKeyPressThread(Keys.Up, 0, 0);
            }

            if (ws.ButtonState.Down == true)
            {
                generateKeyPressThread(Keys.Down, 0, 0);
            }

            if (ws.ButtonState.Left == true)
            {
                generateKeyPressThread(Keys.Left, 0, 0);
            }

            if (ws.ButtonState.Right == true)
            {
                generateKeyPressThread(Keys.Right, 0, 0);
            }


            if (ws.ButtonState.Plus == true)
            {
                if (plusLag > 4)
                {
                    generateKeyPressThread(Keys.VolumeUp, 0, 0);
                    plusLag = 0;
                }
                plusLag++;
            }

            if (ws.ButtonState.Minus == true)
            {
                if (minusLag > 4)
                {
                    generateKeyPressThread(Keys.VolumeDown, 0, 0);
                    minusLag = 0;
                }
                minusLag++;
            }

            if (ws.ButtonState.Home == true)
            {
                if (this.home == false)
                {
                    startHoldKeyPressThread(Keys.VolumeMute, 0);
                    this.home = true;
                }
            }
            else
            {
                if (this.home == true)
                {
                    releaseHoldKeyPressThread(Keys.VolumeMute, 0);
                    this.home = false;
                }
            }

            if (ws.ButtonState.One == true)
            {
                if (this.one == false)
                {
                    //generateKeyPressThread(MouseButtons.Left, 250,0);
                    //System.Diagnostics.Process.Start("TabTip.exe");

                    this.one = true;
                }
            }
            else
            {
                if (this.one == true)
                {
                    this.one = false;
                }
            }
        }