public void HookProcessHandle(string processName, out HookStates hookState) { var p = Utils.GetProcessByName(processName); if (p != null) { _noxWndHandle = p.MainWindowHandle; if (_noxWndHandle != null) { Utils.Rect rect = GetCurrentWndRect(); if (rect.X < 0 || rect.Y < 0 || rect.Width <= 0 || rect.Height <= 0) { Console.WriteLine("Process hook is succcessful but window is minimized!!"); hookState = HookStates.WindowMinimized; } else { Console.WriteLine("Hook process window successed!!! " + p.ProcessName + " " + rect.Left + " " + rect.Right + " " + rect.Top + " " + rect.Bottom + " !!!!!!"); hookState = HookStates.Successed; } } else { Console.WriteLine("Hook process failed!!!"); hookState = HookStates.Failed; } } else { Console.WriteLine("There is no process!!! " + processName); hookState = HookStates.NoProcess; } }
public Utils.Rect GetCurrentWndRect() { Utils.Rect rect = new Utils.Rect(); Utils.GetWindowRect(_noxWndHandle, ref rect); rect.Top += 33; return(rect); }
public static void ProcessExample() { Process[] processes = Process.GetProcesses(); foreach (var p in processes) { IntPtr ptr = p.MainWindowHandle; Utils.Rect rect = new Utils.Rect(); Utils.GetWindowRect(ptr, ref rect); Console.WriteLine( p.ProcessName + " " + (int)rect.Left + " " + (int)rect.Right + " " + (int)rect.Top + " " + (int)rect.Bottom); } }
private void OnCheckPage(object sender, EventArgs e) { DateTime startTime = DateTime.Now; Utils.Rect rect = GetCurrentWndRect(); int x = rect.Left; int y = rect.Top; int width = rect.Right - x; int height = rect.Bottom - y; Utils.CaptureScreen(x, y, width, height, out _printscreen); if (_printscreen == null) { Console.WriteLine("No window to print screen!"); HookStates hookState; HookProcessHandle(VirtualMachineProcess, out hookState); if (hookState == HookStates.NoProcess) { RestartEmulator(); } return; } Mat mat = Utils.BitmapToMat(_printscreen); ScoreAllMatchPages(mat); //ScoreAllSlicedPages(mat, x, y, width, height); DateTime endTime = DateTime.Now; }