public Point GetMousePos()
        {
            Rectangle windowPos = AutoItX.WinGetPos(this.Handle);
            Point     mousePos  = AutoItX.MouseGetPos();

            return(new Point(mousePos.X - windowPos.X, mousePos.Y - windowPos.Y));
        }
Exemple #2
0
        private void sprawdzTlo(kolor kolor_tla)
        {
            int wsp_x             = AutoItX.MouseGetPos().X;
            int wsp_y             = AutoItX.MouseGetPos().Y;
            int pobrany_kolor_tla = AutoItX.PixelGetColor(wsp_x, wsp_y);

            int licznik = 0;

            while ((int)kolor_tla == pobrany_kolor_tla)
            {
                AutoItX.Sleep(700);
                licznik += 1;

                if (licznik > 5)
                {
                    licznik = 0;
                    DialogResult dialogResult = MessageBox.Show("Kliknij powrót i wybierz ok", "Błąd", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
        }
        public void MouseMove(int x, int y)
        {
            var tempPos      = AutoItX.MouseGetPos();
            var currMousePos = new Point(tempPos.X, tempPos.Y);
            var endMousePos  = new Point(x, y);

            var rand = new Random();

            var posList = new List <Point>()
            {
                currMousePos,
                new Point(rand.Next(1, 800), rand.Next(1, 800)),
                new Point(rand.Next(1, 800), rand.Next(1, 800)),
                endMousePos
            };

            var result = GetCurve(posList);

            Point priviosPoint = currMousePos;

            foreach (var point in result)
            {
                if (priviosPoint == null)
                {
                    tempPos      = AutoItX.MouseGetPos();
                    priviosPoint = new Point(tempPos.X, tempPos.Y);
                }

                var diffPoint = priviosPoint.GetDifference(point);
                mouse_event(MouseEventFlags.MOVE, diffPoint.X, diffPoint.Y, 0, 0);
                priviosPoint = point;
                AutoItX.Sleep(10);
            }
        }
Exemple #4
0
 private static void ClickBuy(int index)
 {
     AutoItX.MouseMove(600 + index * 200, 1000, 15);
     AutoItX.MouseDown();
     AutoItX.MouseMove(AutoItX.MouseGetPos().X, AutoItX.MouseGetPos().Y - 200, 15);
     AutoItX.MouseUp();
     Info.store[index].name = ChampionName.None;
 }
Exemple #5
0
        public void turnCornerVer3(EsoWindow esoWindow, String addrText, IntPtr processHandle, String targetCorner)
        {
            Point cursorPosition = new Point();

            esoWindow.GetCursorPos(out cursorPosition);

            var    buffer = new byte[8];
            var    addr   = long.Parse(addrText, NumberStyles.HexNumber);
            IntPtr bytesRead;
            var    result = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);

            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberDecimalSeparator = ",";                           //Задаем запятую, как разделитель между числом и дробной частью

            double trgCorner     = Convert.ToDouble(targetCorner, nfi); //Целевой угол
            double acturalCorner = BitConverter.ToDouble(buffer, 0);    //текущий угол
            int    screenX       = Screen.PrimaryScreen.Bounds.Width;
            int    numberОfTurns = 0;

            if (trgCorner > acturalCorner) //Целевой угол больше текущего
            {
                int X = AutoItX.MouseGetPos().X;
                int Y = AutoItX.MouseGetPos().Y;
                if (((trgCorner - acturalCorner) * 8.7184d) > (Screen.PrimaryScreen.Bounds.Width / 2))
                {
                    numberОfTurns = Convert.ToInt32(Math.Truncate(((trgCorner - acturalCorner) * 8.7184d) / (Screen.PrimaryScreen.Bounds.Width / 2)));
                    for (int i = 0; i < numberОfTurns; i++)
                    {
                        AutoItX.MouseMove(X - screenX / 2 + 1, Y, 1);
                        Thread.Sleep(50);;
                    }
                    result        = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    acturalCorner = BitConverter.ToDouble(buffer, 0);
                }
                Thread.Sleep(500);
                AutoItX.MouseMove(X - Convert.ToInt32((trgCorner - acturalCorner) * 8.7184d), Y, 1); //8.7184 - коэффициент, полученный эксперементальным расчетным путем
            }
            else //Целевой угол меньше текущего
            {
                int X = AutoItX.MouseGetPos().X;
                int Y = AutoItX.MouseGetPos().Y;
                if (((acturalCorner - trgCorner) * 8.7184d) > (Screen.PrimaryScreen.Bounds.Width / 2))
                {
                    numberОfTurns = Convert.ToInt32(Math.Truncate(((acturalCorner - trgCorner) * 8.7184d) / (Screen.PrimaryScreen.Bounds.Width / 2)));
                    for (int i = 0; i < numberОfTurns; i++)
                    {
                        AutoItX.MouseMove(X + screenX / 2 - 1, Y, 1);
                        Thread.Sleep(50);
                    }
                    result        = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    acturalCorner = BitConverter.ToDouble(buffer, 0);
                }
                Thread.Sleep(500);
                AutoItX.MouseMove(X + Convert.ToInt32((acturalCorner - trgCorner) * 8.7184d), Y, 1); //8.7184 - коэффициент, полученный эксперементальным расчетным путем
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            //pega a posição do mause
            int x = AutoItX.MouseGetPos().X;
            int y = AutoItX.MouseGetPos().Y;

            Console.WriteLine("x");
            Console.WriteLine(x.ToString());
            Console.WriteLine("y");
            Console.WriteLine(y.ToString());
            //move o mause
            AutoItX.MouseMove(540, 752, 3);
            AutoItX.MouseClick("LEFT", 540, 752, 1);
            AutoItX.ProcessWait(null, 10);
            //AutoItX.Sleep(30000);

            //clica no brauser
            AutoItX.MouseMove(843, 56, 3);
            AutoItX.MouseClick("LEFT", 843, 56, 1);


            Console.WriteLine("esperando");

            //da uma pausa
            AutoItX.ProcessWait(null, 3);
            Console.WriteLine("feito");

            AutoItX.MouseMove(689, 61, 3);
            AutoItX.MouseClick("LEFT", 689, 61, 1);
            AutoItX.Send("http://www.realsis.com.br/teste");
            AutoItX.ProcessWait(null, 3);
            AutoItX.Send("{BACKSPACE}");
            AutoItX.Send("{BACKSPACE}");
            AutoItX.Send("{BACKSPACE}");
            AutoItX.Send("{BACKSPACE}");
            AutoItX.Send("{BACKSPACE}");
            AutoItX.Send("{BACKSPACE}");
            AutoItX.ProcessWait(null, 3);
            AutoItX.Send("{ENTER}");
            AutoItX.ProcessWait(null, 7);
            //click do mouse
            AutoItX.MouseClick("LEFT", 689, 61, 1);
            //copiar
            AutoItX.Send("^c");
            AutoItX.ProcessWait(null, 3);
            //botão do windows
            AutoItX.Send("{LWIN}");
            AutoItX.ProcessWait(null, 2);
            AutoItX.Send("bloco");
            AutoItX.ProcessWait(null, 2);
            AutoItX.Send("{ENTER}");
            AutoItX.ProcessWait(null, 3);
            //colar
            AutoItX.Send("^v");
        }
Exemple #7
0
        private static Task Jiggler()
        {
            var moveBy = 1;

            while (true)
            {
                var point = AutoItX.MouseGetPos();
                AutoItX.MouseMove(point.X + moveBy, point.Y, 0);

                Thread.Sleep(60000);
                moveBy = moveBy * -1;
            }
        }
        public static bool SendKeys(ushort iterations, string keyCombination, string window, IProgress <int> progress,
                                    ushort keyDelay = 150)
        {
            try
            {
                if (AutoItX.WinWaitActive(window, timeout: 15) == 1)
                {
                    if (MessageBox.Show(ActiveWindow.Active,
                                        "Do you confirm that this is desired application instance and that cursor is set appropriately?",
                                        "Confirmation Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return(false);
                    }

                    Point mouseLocation = AutoItX.MouseGetPos();
                    int   x             = mouseLocation.X;
                    int   y             = mouseLocation.Y;

                    AutoItX.AutoItSetOption("SendKeyDelay", keyDelay);

                    AutoItX.Sleep(3000);

                    for (int i = 1; i <= iterations; i++)
                    {
                        mouseLocation = AutoItX.MouseGetPos();

                        if (mouseLocation.X - x < 150 && mouseLocation.X - x > -150 &&
                            mouseLocation.Y - y < 150 && mouseLocation.Y - y > -150)
                        {
                            progress.Report(i);
                            AutoItX.Send(keyCombination);
                        }
                        else
                        {
                            MessageBox.Show(ActiveWindow.Active, "Significant mouse move detected. Breaking execution.",
                                            "Execution Stopped", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(false);
                        }
                    }

                    return(true);
                }

                MessageBox.Show("Application (" + window + ") window has not been activated within 15 seconds.",
                                "Execution Stopped", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }
            finally
            {
            }
        }
Exemple #9
0
        //Wyszukuje przycisk powrót, szuka dopóki nie znajdzie koloru od tla
        private void szukajPowrot()
        {
            int kolorTla = 8554114;
            int x        = 1970;
            int y        = 946;

            int pobranyKolorTla = AutoItX.PixelGetColor(x, y);

            if (pobranyKolorTla != kolorTla)
            {
                AutoItX.MouseClick();
            }
            else
            {
                for (int i = 0; i < 25; i += 2)
                {
                    AutoItX.MouseMove(x, y -= i);

                    //pozycja startowa
                    int x_prawo = x;
                    int x_lewo  = x;

                    //przesuwamy w prawo i lewo
                    for (int j = 0; j < 6; j++)
                    {
                        AutoItX.MouseMove(x_prawo += j, y);
                        int x_aktualna = AutoItX.MouseGetPos().X;
                        int y_aktualna = AutoItX.MouseGetPos().Y;
                        if (kolorTla != AutoItX.PixelGetColor(x_aktualna, y_aktualna))
                        {
                            AutoItX.MouseClick();
                            break;
                        }

                        AutoItX.MouseMove(x_lewo -= j, y);
                        x_aktualna = AutoItX.MouseGetPos().X;
                        y_aktualna = AutoItX.MouseGetPos().Y;

                        if (kolorTla != AutoItX.PixelGetColor(x_aktualna, y_aktualna))
                        {
                            AutoItX.MouseClick();
                            break;
                        }
                    }
                }
            }
        }
Exemple #10
0
        public void VerificaSemaforo()
        {
            // verifica se o semáforo está verde.
            MainForm.clickEditingControl(534, 24);
            Point pos = AutoItX.MouseGetPos();

            this.Cor           = GetColorAt(pos.X, pos.Y);
            this.SemaforoVerde = this.Cor.Name.Equals("ff00ff00");
            // "{Name=ff00ff00, ARGB=(255, 0, 255, 0)}" -- VERDE

            // verifica se o semáforo está amarelo.
            MainForm.clickEditingControl(523, 24);
            pos                  = AutoItX.MouseGetPos();
            this.Cor             = GetColorAt(pos.X, pos.Y);
            this.SemaforoAmarelo = this.Cor.Name.Equals("ffffff00");
            //"{Name=ffffff00, ARGB=(255, 255, 255, 0)}"
        }
 public Point MouseGetPos()
 {
     return(AutoItX.MouseGetPos());
 }
Exemple #12
0
 static public int getMouseY()
 {
     return(AutoItX.MouseGetPos().Y);
 }