private void btnStart_Click(object sender, EventArgs e) { int Handle = GetHandle(); // ShowDebugInfo(Handle.ToString()); dm.BindWindowEx(Handle, "gdi", "windows", "windows", "", 0); // chức năng findstr của dm . add dict vào , cái này rất hay . dm.SetDict(0, "dm_soft.txt"); this.timer.Enabled = true; this.txtInfo.Text = ""; if (chkAutoRestart.Checked) { StartGame(); } }
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 button1_Click(object sender, EventArgs e) { int handle = gethandle(); dm.ForceUnBindWindow(handle); dm.BindWindowEx(handle, "gdi", "windows", "windows", "", 0); // MessageBox.Show(handle.ToString()); // dm.SetMouseDelay("windows", 180); // Đọc hình ảnh thành tọa độ , có 9 dòng và 16 cột , Ta cho thêm rìa ngoài 1 cột để tìm đường đi thành 11 dòng và 18 cột // ví dụ rắn ở tọa đô 1 1 , vậy là tọa dộ [1,1] = 1 ( ta gán ở func dưới ) quét 1 lượt int[,] toado = new int[18, 11]; do { for (int x = 0; x <= 17; x++) { for (int y = 0; y <= 10; y++) { // toa do ngoài thì giá trị = 0 khỏi quét if (x == 0 || y == 0 || x == 17 || y == 10) { toado[x, y] = 0; } else { //quét tọa độ của pikachu toado[x, y] = findpikachu(x, y); } } } int[] arrayx = new int[18]; int[] arrayy = new int[11]; int count = 0; for (int z = 1; z <= 36; z++) { for (int i = 1; i <= 16; i++) { for (int j = 1; j <= 9; j++) { if (toado[i, j] == z) { //gán tọa độ vào arrayx và y arrayx[count] = i; arrayy[count] = j; count++; if (count >= 4) { count = 0; } } } } //check có bị dính click ko // sau khi gán ta có 2 hoặc 4 array , ta cho vào vòng lập check link và click lần lượt với nhau bool isbool = true; while (isbool) { isbool = false; for (int i = 0; i <= 2; i++) { for (int j = i + 1; j <= 3; j++) { if (CheckLink(toado, arrayx[i], arrayy[i], arrayx[j], arrayy[j]) == true) { //tìm toàn màn hình có bị dính màu đo đỏ khi lần trước click còn lưu lại, có thì click vào con đó dm.FindMultiColor(0, 0, 960, 540, "d24d57", "6|5|d24d57", 1, 0, out object x, out object y); int intX = Convert.ToInt32(x); int intY = Convert.ToInt32(y); if (intX != -1) { dm.MoveTo(intX, intY); dm.LeftClick(); } Thread.Sleep(500); //ghi tọa độ ra để dễ nhìn Console.WriteLine((arrayx[i] + " " + arrayy[i] + " ," + arrayx[j] + " " + arrayy[j])); // move chuột lại và click vào tọa độ pikachu dm.MoveTo(43 + 55 * (arrayx[i] - 1), 68 + 55 * (arrayy[i] - 1)); dm.LeftClick(); Thread.Sleep(300); //do mình hay bị không click được con đầu nên mình làm thêm cái check có click được không, không được thì click tiếp . dm.FindMultiColor(0, 0, 960, 540, "d24d57", "6|5|d24d57", 1, 0, out x, out y); intX = Convert.ToInt32(x); intY = Convert.ToInt32(y); if (intX == -1) { dm.MoveTo(43 + 55 * (arrayx[i] - 1), 68 + 55 * (arrayy[i] - 1)); dm.LeftClick(); } Thread.Sleep(500); //move và click con thứ 2 dm.MoveTo(43 + 55 * (arrayx[j] - 1), 68 + 55 * (arrayy[j] - 1)); dm.delay(50); dm.LeftClick(); Thread.Sleep(1000); // xóa phần từ để không check lại . Array.Clear(arrayx, i, j); Array.Clear(arrayy, i, j); isbool = true; break; } } } } Thread.Sleep(10); Array.Clear(arrayx, 0, arrayx.Length); Array.Clear(arrayy, 0, arrayy.Length); } } while (true); }
private void btn_bind_Click(object sender, EventArgs e) { int dm_ret = dm.BindWindowEx((int)hwdTemp, "gdi2", "windows", "windows", "", 4); }