first commit
This commit is contained in:
84
Assets/02_Scripts/Desktop/Win32.cs
Normal file
84
Assets/02_Scripts/Desktop/Win32.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// 데스크톱 오버레이에 필요한 Win32 선언 모음.
|
||||
/// 선언 자체는 무해하며, 실제 호출부에서 에디터 여부를 가드한다.
|
||||
/// </summary>
|
||||
internal static class Win32
|
||||
{
|
||||
public const int GWL_STYLE = -16;
|
||||
public const int GWL_EXSTYLE = -20;
|
||||
|
||||
public const uint WS_POPUP = 0x80000000;
|
||||
public const uint WS_VISIBLE = 0x10000000;
|
||||
|
||||
public const uint WS_EX_TOOLWINDOW = 0x00000080; // 작업표시줄/Alt+Tab 에서 숨김
|
||||
public const uint WS_EX_APPWINDOW = 0x00040000;
|
||||
public const uint WS_EX_TRANSPARENT = 0x00000020; // 마우스 히트테스트 통과
|
||||
public const uint WS_EX_NOACTIVATE = 0x08000000; // 클릭해도 포커스를 뺏지 않음
|
||||
public const uint WS_EX_LAYERED = 0x00080000; // 최상위 창의 클릭 통과에 필요
|
||||
|
||||
public const uint LWA_COLORKEY = 0x00000001;
|
||||
public const uint LWA_ALPHA = 0x00000002;
|
||||
|
||||
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
||||
public const uint SWP_NOSIZE = 0x0001;
|
||||
public const uint SWP_NOMOVE = 0x0002;
|
||||
public const uint SWP_NOACTIVATE = 0x0010;
|
||||
public const uint SWP_FRAMECHANGED = 0x0020;
|
||||
public const uint SWP_SHOWWINDOW = 0x0040;
|
||||
|
||||
public const int SM_XVIRTUALSCREEN = 76;
|
||||
public const int SM_YVIRTUALSCREEN = 77;
|
||||
public const int SM_CXVIRTUALSCREEN = 78;
|
||||
public const int SM_CYVIRTUALSCREEN = 79;
|
||||
|
||||
public const int SW_HIDE = 0;
|
||||
public const int SW_SHOW = 5;
|
||||
|
||||
public const int VK_SHIFT = 0x10;
|
||||
public const int VK_CONTROL = 0x11;
|
||||
public const int VK_MENU = 0x12; // Alt
|
||||
public const int VK_1 = 0x31;
|
||||
public const int VK_2 = 0x32;
|
||||
public const int VK_3 = 0x33;
|
||||
public const int VK_N = 0x4E;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MARGINS
|
||||
{
|
||||
public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct POINT
|
||||
{
|
||||
public int x, y;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int left, top, right, bottom;
|
||||
public int Width => right - left;
|
||||
public int Height => bottom - top;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")] public static extern IntPtr GetActiveWindow();
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindowW(string lpClassName, string lpWindowName);
|
||||
[DllImport("user32.dll")] public static extern uint GetWindowLongW(IntPtr hWnd, int nIndex);
|
||||
[DllImport("user32.dll")] public static extern uint SetWindowLongW(IntPtr hWnd, int nIndex, uint dwNewLong);
|
||||
[DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||
[DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||
[DllImport("user32.dll")] public static extern int GetSystemMetrics(int nIndex);
|
||||
[DllImport("user32.dll")] public static extern bool GetCursorPos(out POINT lpPoint);
|
||||
[DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
|
||||
[DllImport("user32.dll")] public static extern short GetAsyncKeyState(int vKey);
|
||||
[DllImport("user32.dll")] public static extern bool SetLayeredWindowAttributes(IntPtr hWnd, uint crKey, byte bAlpha, uint dwFlags);
|
||||
[DllImport("dwmapi.dll")] public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
|
||||
|
||||
public static bool IsKeyDown(int vKey) => (GetAsyncKeyState(vKey) & 0x8000) != 0;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user