Skip to content

Commit 6073d64

Browse files
committed
Quick fix
1 parent 3322d86 commit 6073d64

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

AvatarLockpick.Revised/Utils/AvatarUnlocker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static void Start(int Type, string UserID, string AvatarID)
3232
Console.BackgroundColor = ConsoleColor.Black;
3333
Console.Title = "AvatarLockpick Debug Console";
3434
Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true });
35+
try { WindowUtils.BringConsoleToFrontIfVisible(); } catch { }
3536

3637
switch (Type)
3738
{
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Runtime.InteropServices;
7+
8+
namespace AvatarLockpick.Revised.Utils
9+
{
10+
internal class WindowUtils
11+
{
12+
[DllImport("kernel32.dll", ExactSpelling = true)]
13+
private static extern IntPtr GetConsoleWindow();
14+
15+
[DllImport("user32.dll")]
16+
[return: MarshalAs(UnmanagedType.Bool)]
17+
private static extern bool IsWindowVisible(IntPtr hWnd);
18+
19+
[DllImport("user32.dll")]
20+
[return: MarshalAs(UnmanagedType.Bool)]
21+
private static extern bool IsIconic(IntPtr hWnd);
22+
23+
[DllImport("user32.dll")]
24+
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
25+
26+
[DllImport("user32.dll")]
27+
[return: MarshalAs(UnmanagedType.Bool)]
28+
private static extern bool SetForegroundWindow(IntPtr hWnd);
29+
30+
private const int SW_RESTORE = 9;
31+
32+
public static void BringConsoleToFrontIfVisible()
33+
{
34+
IntPtr consoleHandle = GetConsoleWindow();
35+
if (consoleHandle != IntPtr.Zero)
36+
{
37+
if (IsWindowVisible(consoleHandle))
38+
{
39+
if (IsIconic(consoleHandle))
40+
{
41+
ShowWindow(consoleHandle, SW_RESTORE);
42+
}
43+
SetForegroundWindow(consoleHandle);
44+
}
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)