/// <summary> /// Check if Size of Emulator windows match with the loaded/pre-defined windows size /// Resize window if it doesnt match the pre-defined sizes /// </summary> /// <param name="emulator"></param> public static void checkEmulatorSize(IntPtr emulator) { // Get window parameters WinAPI.RECT rect = new WinAPI.RECT(); WinAPI.GetWindowRect(emulator, out rect); // Check if match and resize if necessary if (rect.Width != GlobalSettings.General.EmulatorWidth || rect.Height != GlobalSettings.General.EmulatorWidth) { WinAPI.MoveWindow(emulator, rect.X, rect.Y, GlobalSettings.General.EmulatorWidth, GlobalSettings.General.EmulatorHeight, true); System.Threading.Thread.Sleep(100); } }
/// <summary> /// Capture Screenshot from window-pointer /// </summary> /// <param name="procName"></param> /// <returns></returns> public static Bitmap CaptureApplication(IntPtr procName) { WinAPI.RECT rect = new WinAPI.RECT(); WinAPI.GetWindowRect(procName, out rect); int width = rect.Right - rect.Left; int height = rect.Bottom - rect.Top; Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(bmp)) { bmp.SetResolution(graphics.DpiX, graphics.DpiY); graphics.CopyFromScreen(rect.Left, rect.Top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy); return(bmp); } }
/// <summary> /// Get Infos from Table to set NoteWindow appearance into the center of the table /// </summary> /// <param name="table"></param> private void setAppearanceLocation(string table) { // retrieve needed table from sessions list foreach (KeyValuePair <IntPtr, TableData> kvp in TableHandler.tableSessions) { TableData data = kvp.Value; if (data.tablename.Equals(table)) { IntPtr tableHandle = kvp.Key; WinAPI.RECT rect = new WinAPI.RECT(); WinAPI.GetWindowRect(tableHandle, out rect); int a = rect.Width / 4; int b = rect.Height / 3; WinAPI.MoveWindow(this.Handle, rect.X + a, rect.Y + b, this.Width, this.Height, true); break; } } }
/// <summary> /// Check for action buttons on the table with the help of preset Color in hardcoded place /// </summary> private void playerHasOptions() { // Get open tables emu = new EmulatorHandler(GlobalSettings.General.EmulatorRegex); List <IntPtr> openTables = emu.getEmulatorList(); Color options = GlobalSettings.General.AlerterButtonColor; // Check for each open table... foreach (IntPtr pointer in openTables) { if (TableHandler.alerter.ContainsKey(pointer)) { // ...if CheckBox on top was ticked bool tick = TableHandler.alerter[pointer]; if (!tick) { continue; } // Get Area of the table with buttons WinAPI.RECT r = new WinAPI.RECT(); r.Width = 848; r.Height = 1318; // Get table screenshot and crop image roughly to the area where buttons will appear Bitmap bmp = Screenshot.CaptureApplication(pointer); Bitmap crop = Screenshot.CropImage(bmp, 0, Math.Abs((bmp.Height / 100) * 85), bmp.Width, 30); // Check if actions are available bool itsonme = checkColor(crop, options); if (itsonme) // Play sound on available options { simpleSound.Play(); System.Threading.Thread.Sleep(1500); } } } }