mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-10-16 22:20:06 +00:00
86 lines
3.3 KiB
C#
86 lines
3.3 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace MSFSPopoutPanelManager.Shared
|
|
{
|
|
public class PInvoke
|
|
{
|
|
[DllImport("user32")]
|
|
public static extern int EnumWindows(CallBack x, int y);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
private static extern int GetClassName(IntPtr hWnd, StringBuilder strPtrClassName, Int32 nMaxCount);
|
|
|
|
public static string GetClassName(IntPtr hwnd)
|
|
{
|
|
StringBuilder sb = new StringBuilder(255);
|
|
GetClassName(hwnd, sb, sb.Capacity);
|
|
return sb.ToString();
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool GetClientRect(IntPtr hWnd, out Rectangle lpRect);
|
|
|
|
[DllImport("user32.dll")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
public static extern bool GetCursorPos(out Point lpPoint);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int GetWindowRect(IntPtr hwnd, out Rectangle lpRect);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount);
|
|
|
|
public static string GetWindowText(IntPtr hwnd)
|
|
{
|
|
StringBuilder sb = new StringBuilder(255);
|
|
GetWindowText(hwnd, sb, sb.Capacity);
|
|
return sb.ToString();
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern void mouse_event(uint dwFlags, int dx, int dy, uint cButtons, uint dwExtraInfo);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
|
|
|
|
[DllImport("User32.dll")]
|
|
public static extern bool SetCursorPos(int X, int Y);
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
public static extern IntPtr SetFocus(IntPtr hWnd);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("USER32.dll")]
|
|
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, uint wFlags);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern bool SetWindowText(System.IntPtr hwnd, System.String lpString);
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
public static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventProc lpfnWinEventProc, int idProcess, int idThread, uint dwflags);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int UnhookWinEvent(IntPtr hWinEventHook);
|
|
|
|
public delegate bool CallBack(IntPtr hwnd, int lParam);
|
|
|
|
public delegate void WinEventProc(IntPtr hWinEventHook, uint iEvent, IntPtr hWnd, int idObject, int idChild, int dwEventThread, int dwmsEventTime);
|
|
}
|
|
}
|