diff --git a/VAR.Toolbox/Code/Bots/WindowHandling.cs b/VAR.Toolbox/Code/Bots/WindowHandling.cs
deleted file mode 100644
index fe9f5a4..0000000
--- a/VAR.Toolbox/Code/Bots/WindowHandling.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Windows.Forms;
-
-// ReSharper disable InconsistentNaming
-
-namespace VAR.ScreenAutomation.Code
-{
- public static class WindowHandling
- {
- private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
- private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
- private const UInt32 SWP_NOSIZE = 0x0001;
- private const UInt32 SWP_NOMOVE = 0x0002;
- private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
-
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy,
- uint uFlags);
-
- public static void WindowSetTopLevel(Form form, bool top = true)
- {
- SetWindowPos(form.Handle, top
- ? HWND_TOPMOST
- : HWND_NOTOPMOST,
- 0, 0, 0, 0, TOPMOST_FLAGS);
- }
-
- public static bool ApplicationIsActivated()
- {
- var activatedHandle = GetForegroundWindow();
- if (activatedHandle == IntPtr.Zero)
- {
- return false;
- }
-
- var procId = Process.GetCurrentProcess().Id;
- GetWindowThreadProcessId(activatedHandle, out int activeProcId);
- return activeProcId == procId;
- }
-
- [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- private static extern IntPtr GetForegroundWindow();
-
- [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- private static extern int GetWindowThreadProcessId(IntPtr handle, out int processId);
- }
-}
\ No newline at end of file
diff --git a/VAR.Toolbox/Code/WindowHandling.cs b/VAR.Toolbox/Code/WindowHandling.cs
new file mode 100644
index 0000000..320921a
--- /dev/null
+++ b/VAR.Toolbox/Code/WindowHandling.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Diagnostics;
+using System.Windows.Forms;
+using VAR.Toolbox.Code.Windows;
+
+// ReSharper disable InconsistentNaming
+
+namespace VAR.Toolbox.Code
+{
+ public static class WindowHandling
+ {
+ public static void WindowSetTopLevel(Form form, bool top = true)
+ {
+ User32.SetWindowPos(form.Handle, top
+ ? User32.HWND_TOPMOST
+ : User32.HWND_NOTOPMOST,
+ 0, 0, 0, 0, User32.TOPMOST_FLAGS);
+ }
+
+ public static bool ApplicationIsActivated()
+ {
+ var activatedHandle = User32.GetForegroundWindow();
+ if (activatedHandle == IntPtr.Zero)
+ {
+ return false;
+ }
+
+ var procId = Process.GetCurrentProcess().Id;
+ User32.GetWindowThreadProcessId(activatedHandle, out int activeProcId);
+ return activeProcId == procId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/VAR.Toolbox/Code/Windows/User32.cs b/VAR.Toolbox/Code/Windows/User32.cs
index 54c77e8..5a779cb 100644
--- a/VAR.Toolbox/Code/Windows/User32.cs
+++ b/VAR.Toolbox/Code/Windows/User32.cs
@@ -175,6 +175,9 @@ namespace VAR.Toolbox.Code.Windows
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern int GetWindowThreadProcessId(IntPtr handle, out int processId);
+
public static string GetActiveWindowTitle()
{
const int NChars = 256;
@@ -188,5 +191,17 @@ namespace VAR.Toolbox.Code.Windows
return null;
}
+
+ public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
+ public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
+ public const UInt32 SWP_NOSIZE = 0x0001;
+ public const UInt32 SWP_NOMOVE = 0x0002;
+ public const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy,
+ uint uFlags);
+
}
}
\ No newline at end of file
diff --git a/VAR.Toolbox/VAR.Toolbox.csproj b/VAR.Toolbox/VAR.Toolbox.csproj
index a33dcef..007da64 100644
--- a/VAR.Toolbox/VAR.Toolbox.csproj
+++ b/VAR.Toolbox/VAR.Toolbox.csproj
@@ -81,7 +81,6 @@
-
@@ -122,6 +121,7 @@
+