public void TestPrintWindow() { NoxEmulator emulator = new NoxEmulator(); IntPtr parent = AbstractEmulator.FindWindow("Qt5QWindowIcon", "Nox"); IntPtr subWindow = AbstractEmulator.FindWindowEx(parent, IntPtr.Zero, "Qt5QWindowIcon", "ScreenBoardClassWindow"); IntPtr mainWindow = AbstractEmulator.FindWindowEx(subWindow, IntPtr.Zero, "Qt5QWindowIcon", "QWidgetClassWindow"); IntPtr sub = AbstractEmulator.FindWindowEx(mainWindow, IntPtr.Zero, "subWin", "sub"); emulator.PrintWindow(parent); }
public void TestMatchImage() { NoxEmulator emulator = new NoxEmulator(); IntPtr parent = AbstractEmulator.FindWindow("Qt5QWindowIcon", "Nox"); Bitmap source = emulator.PrintWindow(parent); Bitmap crop = BitmapUtils.CropImage(source, new Rectangle(800, 550, 400, 200)); string test1 = @"C:\Users\Administrator\Desktop\1\dungeonEnergy.png"; string test2 = @"E:\SWRunner\Resources\general\gift_box.png"; Assert.AreEqual(1, QuizSolver.FindMatchImage(crop, new Bitmap(test2))); }
public void TestPrintScreen() { NoxEmulator emulator = new NoxEmulator(); IntPtr paintHwnd = AbstractEmulator.FindWindow(null, "Untitled - Paint"); Bitmap src = emulator.PrintWindow(paintHwnd); Rectangle cropRect = new Rectangle(100, 100, 80, 80); Bitmap target = new Bitmap(cropRect.Width, cropRect.Height); using (Graphics g = Graphics.FromImage(target)) { g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), cropRect, GraphicsUnit.Pixel); } target.Save("C:\\TestWin32\\test1.png", ImageFormat.Png); Helper.GetQuizImages(src); }