Skip to content

Commit

Permalink
MainV2: Fix console window hide in windows11
Browse files Browse the repository at this point in the history
  • Loading branch information
EosBandi authored and meee1 committed Oct 21, 2023
1 parent 8770187 commit 2ff1394
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 2ff1394

Please sign in to comment.