Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MainV2: Fix console window hide in windows11 #3214

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MainV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,8 @@ public MainV2()
}
else
{
int win = NativeMethods.FindWindow("ConsoleWindowClass", null);
NativeMethods.ShowWindow(win, NativeMethods.SW_HIDE); // hide window
NativeMethods.ShowWindow(NativeMethods.GetConsoleWindow(), NativeMethods.SW_HIDE);

}

// prevent system from sleeping while mp open
Expand Down
6 changes: 5 additions & 1 deletion NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ internal static class NativeMethods
public static extern int FindWindow(string szClass, string szTitle);

[DllImport("user32.dll")]
public static extern int ShowWindow(int Handle, int showState);
public static extern bool ShowWindow(IntPtr Handle, int showState);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern IntPtr RegisterDeviceNotification
(IntPtr hRecipient,
IntPtr NotificationFilter,
Int32 Flags);


[DllImport("kernel32.dll")]
public static extern IntPtr GetConsoleWindow();

// Import SetThreadExecutionState Win32 API and necessary flags

[DllImport("kernel32.dll")]
Expand Down
Loading