Cách Chụp Full Cửa Sổ Auto Nox Trên C# Bằng Thư Viện Kautohelper

KAutoHelper

Nếu bạn đang gặp trường hợp làm Auto Nox trên C#, dùng thư viện KAutoHelper mà không chụp hình được full cửa sổ Nox thì bạn có thể tham khảo cách giải quyết từ Coding Guru:

Sau khi bạn lấy được handle của Window rồi bạn thử show maximized window rồi mới chụp màn hình xem.

Để show được window miximized thì dùng hàm ShowScreen của user32.dll

public enum ShowWindowCommands : int
{
Hide = 0,
Normal = 1,
ShowMinimized = 2,
ShowMaximized = 3,
ShowNoActivate = 4,
Show = 5,
Minimize = 6,
ShowMinNoActive = 7,
ShowNA = 8,
Restore = 9,
ShowDefault = 10,
ForceMinimize = 11
}

[DllImport(“user32.dll”)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);

Code của bạn sẽ trông như sau -->

IntPtr hwid = IntPtr.Zero;
hwid = AutoControl.FindWindowHandle(null, “jorijt”);
if (hwid != IntPtr.Zero)
{
ShowWindow(hwid, ShowWindowCommands.ShowMaximized);
System.Threading.Thread.Sleep(1000); // delay 1 second, wait for window maximized
var screen = CaptureHelper.CaptureWindow(hwid);
screen.Save(“mainScreen.PNG”);
}
else
{
Debug.WriteLine(“Get Window Handle fail”);
}

Trên đây là đoạn hướng dẫn của Coding Guru khi bạn không chụp hình full cửa sổ Auto Nox trên C#. Bạn có thể tham khảo cách sử dụng thư viện KAutoHelper tại https://www.youtube.com/watch?v=SknHr6fASBw. Hi vọng bài viết này hữu ích với bạn!

 

Leave a Reply

Your email address will not be published. Required fields are marked *