private bool bind_window() { int hwnd = dm.FindWindow("LDPlayerMainFrame", "雷電模擬器"); hwnd = Int32.Parse(dm.EnumWindow(hwnd, "TheRender", "RenderWindow", 4)); //hwnd = Int32.Parse(dm.EnumWindow(hwnd, "sub", "subWin", 4)); int dm_ret = dm.BindWindowEx(hwnd, "gdi", "windows", "windows", "", 0); //int dm_ret = dm.BindWindow(hwnd, "normal", "normal", "dx", 0); if (dm_ret != 1) { MessageBox.Show("我找不到模擬器!"); return(false); } return(true); }
public void 循环找图主进程() { i = 0; while (true) { Stopwatch 运行时间 = new Stopwatch(); 运行时间.Start(); foreach (String 图片 in 截图.需要点击的) { 查找图片点击(图片 + ".bmp"); } if (!查找图片点击(截图.人机对战)) { 查找图片点击(截图.模式确认); } //查找图片点击(截图.锁定英雄); if (查找图片(截图.回城技能, out 横坐标, out 纵坐标))//游戏中----回城技能截图改成了左上角图标 { My.Computer.MouseMoveToPixel(横坐标 + 1170 + 随机数.Next(0, 5) - 随机数.Next(0, 5), 纵坐标 + 650 + 随机数.Next(0, 5) - 随机数.Next(0, 5)); dm.KeyDown(65);//"a"键 Delay(20 + 随机数.Next(0, 20)); My.Computer.MouseLeftClick(); Delay(30 + 随机数.Next(0, 20)); dm.KeyUp(65); Delay(500 + 随机数.Next(0, 20)); dm.KeyPressChar("space"); My.Computer.MouseMoveToPixel(600 + 随机数.Next(0, 50) - 随机数.Next(0, 50), 300 + 随机数.Next(0, 50) - 随机数.Next(0, 50)); Delay(100 + 随机数.Next(100, 200)); //if (查找图片(截图.聊天框, out 横坐标, out 纵坐标)) //{ // dm.KeyPress(13); //} } else if (My.Computer.FindWindow("League of Legends (TM) Client").Width != 0) { //横坐标 = 1191; //纵坐标 = 629; this.Text = "第二种查找方式(固定的XY坐标而不是按查找图片来寻找)"; My.Computer.MouseMoveToPixel(1191 + 随机数.Next(0, 5) - 随机数.Next(0, 5), 629 + 随机数.Next(0, 5) - 随机数.Next(0, 5)); dm.KeyDown(65);//"a"键 Delay(20 + 随机数.Next(0, 20)); My.Computer.MouseLeftClick(); Delay(30 + 随机数.Next(0, 20)); dm.KeyUp(65); Delay(500 + 随机数.Next(0, 20)); My.Computer.MouseMoveToPixel(1191 + 随机数.Next(0, 5) - 随机数.Next(0, 5), 629 + 随机数.Next(0, 5) - 随机数.Next(0, 5)); dm.KeyDown(65);//"a"键 Delay(20 + 随机数.Next(0, 20)); My.Computer.MouseLeftClick(); Delay(30 + 随机数.Next(0, 20)); dm.KeyUp(65); Delay(500 + 随机数.Next(0, 20)); My.Computer.MouseMoveToPixel(600 + 随机数.Next(0, 50) - 随机数.Next(0, 50), 300 + 随机数.Next(0, 50) - 随机数.Next(0, 50)); Delay(100 + 随机数.Next(100, 200)); My.Computer.MouseMoveToPixel(600 + 随机数.Next(0, 50) - 随机数.Next(0, 50), 300 + 随机数.Next(0, 50) - 随机数.Next(0, 50)); Delay(100 + 随机数.Next(100, 200)); dm.KeyPress(13); Delay(200 + 随机数.Next(0, 50)); Delay(300 + 随机数.Next(0, 50)); dm.KeyPress(13); } if (查找图片(截图.再玩一次, out 横坐标, out 纵坐标)) { 第一次进游戏 = true; if (checkBox1.Checked) { this.Text = "停止状态"; 运行时间.Stop(); break; } else { Delay(50); 标移动左键单击(横坐标, 纵坐标); } } if (查找图片(截图.锁定视角, out 横坐标, out 纵坐标)) { Delay(50); dm.KeyPress(89);//Y键 } if (dm.FindWindow("RiotWindowClass", "") != 0) { dm.GetClientRect(dm.FindWindow("RiotWindowClass", ""), out object x1, out object y1, out object x2, out object y2); if ((int)x1 != 0 || (int)y1 != 0) { dm.MoveWindow(dm.FindWindow("RiotWindowClass", ""), 0, 0); } } if (i > (发送文本间隔时间 * 1000) && 查找图片(截图.回城技能, out 横坐标, out 纵坐标)) { //if (第一次进游戏 == true) //{ // 第一次进游戏 = false; //} //else //{ // 发送文本(); //} 发送文本(); i = 0; } //if (My.Computer.KeyBeingPressed(Keys.D) || 停止按钮) if (停止按钮) { this.Text = "停止状态"; 运行时间.Stop(); break; } 运行时间.Stop(); TimeSpan 时间间隔 = 运行时间.Elapsed; this.Text = (时间间隔.TotalMilliseconds / 1000.00).ToString() + "s"; i += 时间间隔.TotalMilliseconds; } }
private int GetHandle() { return(dm.FindWindow("", "Minesweeper"));; }