private void button5_Click(object sender, EventArgs e) { AutoItX3 autoItX3 = new AutoItX3(); Point LOLlocation = new Point(805, 175); IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(null, "Garena - Game Center"); var child = AutoControl.FindHandle(hWnd, "Chrome_RenderWidgetHostHWND", null); var point = AutoControl.GetGlobalPoint(child, LOLlocation); int num = Convert.ToInt32(textBox1.Text); AutoControl.BringToFront(hWnd); AutoControl.MouseClick(point); Thread.Sleep(3000); var belowdiendan = new Point(425, 4); var pointBelowdiendan = (Point)AutoControl.GetGlobalPoint(child, belowdiendan); pointBelowdiendan.Y -= 20; AutoControl.MouseClick(pointBelowdiendan); Thread.Sleep(3000); Point writebutton = new Point(774, 578); var WritePostButton = (Point)AutoControl.GetGlobalPoint(child, writebutton); //autoItX3.MouseMove(WritePostButton) AutoControl.MouseClick(WritePostButton); Thread.Sleep(2000); var title = (Point)AutoControl.GetGlobalPoint(child, 172, 221); AutoControl.MouseClick(title); autoItX3.Send("some trash title i can put in"); Thread.Sleep(1000); var content = (Point)AutoControl.GetGlobalPoint(child, 170, 269); AutoControl.MouseClick(content); autoItX3.Send("test"); Thread.Sleep(1000); var uploadImage = (Point)AutoControl.GetGlobalPoint(child, 178, 493); AutoControl.MouseClick(uploadImage); Thread.Sleep(2000); //Thread. Sleep and send key like someimage.png; autoItX3.Send("Normal.png"); Thread.Sleep(1000); AutoControl.SendKeyPress(KeyCode.ENTER); Thread.Sleep(2000); var link = (Point)AutoControl.GetGlobalPoint(child, 232, 535); AutoControl.MouseClick(link); var linkloc = (Point)AutoControl.GetGlobalPoint(child, 186, 560); AutoControl.MouseClick(linkloc); autoItX3.Send("https://www.youtube.com/watch?v=HKS6cp5OGMo&list=RDzhqvxdx8kIM&index=2"); var Send = (Point)AutoControl.GetGlobalPoint(child, 772, 516); AutoControl.MouseClick(Send); // done }
private void button2_Click(object sender, EventArgs e) { int x = 947; int y = 118; IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(null, "Garena - Game Center"); var child = AutoControl.FindHandle(hWnd, "Chrome_RenderWidgetHostHWND", null); var point = AutoControl.GetGlobalPoint(child, x, y); AutoControl.BringToFront(hWnd); AutoControl.MouseClick(AutoControl.GetGlobalPoint(child, 10, 10)); mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -720, (UIntPtr)0); AutoControl.Click(); //AutoControl.SendKeyDown() }
private void button8_Click(object sender, EventArgs e) { int x = (int)numericUpDown1.Value; int y = (int)numericUpDown2.Value; IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(null, textBox1.Text); var childhWnd = IntPtr.Zero; // Tìm ra handle con mà thỏa điều kiện text và class y chang //childhWnd = AutoControl.FindWindowExFromParent(hWnd, null, textBox2.Text); //Tìm ra handle con mà thỏa text hoặc class giống childhWnd = AutoControl.FindHandle(hWnd, textBox2.Text, textBox2.Text); // lấy ra tọa độ trên màn hình của tọa độ bên trong cửa sổ var pointToClick = AutoControl.GetGlobalPoint(childhWnd, x, y); EMouseKey mouseKey = EMouseKey.LEFT; if (checkBox1.Checked) { if (checkBox2.Checked) { mouseKey = EMouseKey.DOUBLE_RIGHT; } else { mouseKey = EMouseKey.RIGHT; } } else { if (checkBox2.Checked) { mouseKey = EMouseKey.DOUBLE_LEFT; } } AutoControl.BringToFront(hWnd); AutoControl.MouseClick(pointToClick, mouseKey); }
private void btnFo4_Click_1(object sender, EventArgs e) { FO4.StartInfo.FileName = "E:\\FileDesktop\\FOT4"; FO4.Start(); FO4.StartInfo.FileName = "E:\\FileDesktop\\Garena"; FO4.Start(); FO4.WaitForInputIdle(); IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(tbClickApp.Text, null); var pointToClick = AutoControl.GetGlobalPoint(hWnd, 600, 430); EMouseKey mousekey = EMouseKey.LEFT; if (cbRightMouse.Checked) { if (cbDoubleClick.Checked) { mousekey = EMouseKey.DOUBLE_RIGHT; } else { mousekey = EMouseKey.RIGHT; } } else { if (cbDoubleClick.Checked) { mousekey = EMouseKey.DOUBLE_LEFT; } } AutoControl.BringToFront(hWnd); //Cursor.Position = new Point(x, y); AutoControl.MouseClick(pointToClick, mousekey); }
private void btnClickControlApp_Click(object sender, EventArgs e) { int x = (Int32)pointCursorX.Value; int y = (Int32)pointCursorY.Value; //var hWnd = Process.GetProcessById(3652).MainWindowHandle; IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(null, txtApplicationName.Text.Trim()); var childWnd = IntPtr.Zero; childWnd = AutoControl.FindHandle(hWnd, txtClass.Text, txtClass.Text); var pointToClick = AutoControl.GetGlobalPoint(childWnd, x, y); EMouseKey eMouseKey = EMouseKey.LEFT; if (chkMouseRightClick.Checked) { if (chkMouseDoubleClick.Checked) { eMouseKey = EMouseKey.DOUBLE_RIGHT; } else { eMouseKey = EMouseKey.RIGHT; } } else { if (chkMouseDoubleClick.Checked) { eMouseKey = EMouseKey.DOUBLE_LEFT; } } AutoControl.BringToFront(hWnd); AutoControl.MouseClick(pointToClick, eMouseKey); }
void ScrollDown() { Point startpoint = new Point(951, 12); Point endPoint = new Point(952, 202); IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(null, "Garena - Game Center"); var child = AutoControl.FindHandle(hWnd, "Chrome_RenderWidgetHostHWND", null); var spoint = AutoControl.GetGlobalPoint(child, startpoint); var endP = AutoControl.GetGlobalPoint(child, endPoint); int[] arrEndPoint = { 202, 315, 341, 358, 432, 471, 500, 570, 630 }; AutoControl.BringToFront(hWnd); AutoItX3Lib.AutoItX3 autoItX = new AutoItX3(); autoItX.MouseMove(spoint.X, spoint.Y); autoItX.MouseDown("LEFT"); autoItX.MouseMove(endP.X, endP.Y); autoItX.MouseUp("LEFT"); }
void dothing() { int x = 800; int y = 173; IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle("Qt5QWindowIcon", null); var child = AutoControl.FindHandle(hWnd, "Chrome_WidgetWin_0", null); MessageBox.Show(child.ToString()); var pointoClick = AutoControl.GetGlobalPoint(hWnd, x, y); AutoControl.SendClickOnPosition(child, x, y); SendKeys.SendWait("hello"); //AutoControl.BringToFront(hWnd); //AutoControl.MouseClick(pointoClick); AutoControl.SendClickOnControlByHandle(child); }
private void button7_Click(object sender, EventArgs e) { try { int x = (int)numericUpDown1.Value; int y = (int)numericUpDown2.Value; Point pointToClick = new Point(x, y); EMouseKey key = EMouseKey.LEFT; IntPtr handle = IntPtr.Zero; if (textBox3.Text != null && textBox4.Text != null) { handle = AutoControl.FindWindowHandle(textBox4.Text, textBox3.Text); pointToClick = AutoControl.GetGlobalPoint(handle, x, y); } if (checkBox1.Checked) { key = EMouseKey.RIGHT; } else { key = EMouseKey.DOUBLE_RIGHT; } if (checkBox2.Checked) { key = EMouseKey.LEFT; } else { key = EMouseKey.DOUBLE_LEFT; } AutoControl.BringToFront(handle); AutoControl.MouseClick(pointToClick, key); } catch (Exception) { MessageBox.Show("Error!"); } }
private void button7_Click(object sender, EventArgs e) { int x = (int)numericUpDown1.Value; int y = (int)numericUpDown2.Value; //var hWnd = Process.GetProcessById(12012).MainWindowHandle; //var hWnd = Process.GetProcessesByName("Remote Desktop Connection")[0].MainWindowHandle; IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(null, textBox1.Text); // lấy ra tọa độ trên màn hình của tọa độ bên trong cửa sổ. Use Autoit window info var pointToClick = AutoControl.GetGlobalPoint(hWnd, x, y); EMouseKey mouseKey = EMouseKey.LEFT; if (checkBox1.Checked) { if (checkBox2.Checked) { mouseKey = EMouseKey.DOUBLE_RIGHT; } else { mouseKey = EMouseKey.RIGHT; } } else { if (checkBox2.Checked) { mouseKey = EMouseKey.DOUBLE_LEFT; } } AutoControl.BringToFront(hWnd); // Cursor.Position = new Point(x, y); AutoControl.MouseClick(pointToClick, mouseKey); }
private void button1_Click(object sender, EventArgs e) { int x = (int)numericUpDown1.Value; int y = (int)numericUpDown2.Value; IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(tbClickApp.Text, null); var pointToClick = AutoControl.GetGlobalPoint(hWnd, x, y); EMouseKey mousekey = EMouseKey.LEFT; if (cbRightMouse.Checked) { if (cbDoubleClick.Checked) { mousekey = EMouseKey.DOUBLE_RIGHT; } else { mousekey = EMouseKey.RIGHT; } } else { if (cbDoubleClick.Checked) { mousekey = EMouseKey.DOUBLE_LEFT; } } AutoControl.BringToFront(hWnd); //Cursor.Position = new Point(x, y); AutoControl.MouseClick(pointToClick, mousekey); }
private void button18_Click(object sender, EventArgs e) { var handle = AutoControl.FindWindowHandle("LDMultiPlayerMainFrame" == "" ? null : "LDMultiPlayerMainFrame", "" == "" ? null : ""); #region // khởi tạo và restore file backup #endregion #region // ấn nút bắt đầu var sub = (Bitmap)Bitmap.FromFile("data//data.png"); var main = (Bitmap)CaptureHelper.CaptureWindow(handle); var point = ImageScanOpenCV.FindOutPoint(main, sub); if (point != null) { // AutoControl.SendClickOnPosition(handle, point.Value.X, point.Value.Y); var pointToClick = AutoControl.GetGlobalPoint(handle, point.Value.X + 7, point.Value.Y + 5); EMouseKey mouseKey = EMouseKey.DOUBLE_LEFT; AutoControl.BringToFront(handle); AutoControl.MouseClick(pointToClick, mouseKey); } #endregion }
private void button6_Click(object sender, EventArgs e) { IntPtr @int = AutoControl.FindWindowHandle("Microsoft Visual Studio ", null); int x = (int)trucX.Value; int y = (int)trucY.Value; var pointToClick = AutoControl.GetGlobalPoint(@int, x, y); AutoControl.BringToFront(@int); AutoControl.MouseClick(pointToClick); MessageBox.Show(@int.ToString()); //var aaa = Process.GetProcessesByName("devenv").FirstOrDefault(); //if (aaa != null) //{ // aaa.Kill(); //} //else //{ // Process.Start("devenv"); //} }
private void button4_Click(object sender, EventArgs e) { AutoItX3 autoItX3 = new AutoItX3(); Point LOLlocation = new Point(805, 175); IntPtr hWnd = IntPtr.Zero; hWnd = AutoControl.FindWindowHandle(null, "Garena - Game Center"); var child = AutoControl.FindHandle(hWnd, "Chrome_RenderWidgetHostHWND", null); var point = AutoControl.GetGlobalPoint(child, LOLlocation); int num = Convert.ToInt32(textBox1.Text); AutoControl.BringToFront(hWnd); AutoControl.MouseClick(point); Thread.Sleep(3000); autoItX3.MouseWheel("down", 2); Thread.Sleep(3000); //var postPoint = AutoControl.GetGlobalPoint(child, 147, 113);// 147 113 //AutoControl.MouseClick(postPoint); //Thread.Sleep(2000); int[] arrEndPoint = { 202, 315, 341, 358, 432, 471, 500, 570, 630 }; // for y for (int i = 0; i < 2; i++) { Point startpoint = new Point(951, 12); Point endPoint = new Point(952, 202); var fpoint = AutoControl.GetGlobalPoint(child, 150, 149); for (int j = 0; j < 3; j++) { AutoControl.MouseClick(fpoint); Thread.Sleep(3000); var spoint = AutoControl.GetGlobalPoint(child, startpoint); autoItX3.MouseMove(spoint.X, spoint.Y); autoItX3.MouseDown("LEFT"); Bitmap screen; for (int p = 0; p < arrEndPoint.Length; p++) { endPoint.Y = arrEndPoint[p]; var endP = AutoControl.GetGlobalPoint(child, endPoint); autoItX3.MouseMove(endP.X, endP.Y); screen = (Bitmap)CaptureHelper.CaptureScreen(); var subBit = ImageScanOpenCV.GetImage("commentSection.PNG"); var sendpost = ImageScanOpenCV.GetImage("SendComment.PNG"); var ComsecLocation = ImageScanOpenCV.FindOutPoint((Bitmap)screen, subBit); if (ComsecLocation != null) { autoItX3.MouseUp("LEFT"); AutoControl.MouseClick((Point)ComsecLocation); autoItX3.Send("Hello"); Thread.Sleep(1000); screen = (Bitmap)CaptureHelper.CaptureScreen(); var sendLocation = ImageScanOpenCV.FindOutPoint((Bitmap)screen, sendpost); Point sendlo = (Point)sendLocation; // can not find the right so find the near and add a few unit to right point sendlo.X += 3; sendlo.Y += 7; AutoControl.MouseClick((Point)sendlo); screen.Dispose(); break; } } var exitpost = AutoControl.GetGlobalPoint(child, 62, 6); exitpost.Y -= 37; AutoControl.MouseClick(exitpost); Thread.Sleep(2000); fpoint.X += 325; } Thread.Sleep(1000); Point zone = AutoControl.GetGlobalPoint(child, 20, 20); autoItX3.MouseMove(zone.X, zone.Y); autoItX3.MouseWheel("down", 4); Thread.Sleep(3000); } }