본문 바로가기

C# WinAPI - GetWindowPlacement using System.Runtime.InteropServices; [DllImport("user32.dll")] internal static extern bool GetWindowPlacement(int hWnd, ref WINDOWPLACEMENT lpwndpl); internal struct WINDOWPLACEMENT { public int length; public int flags; public ShowWindowCommands showCmd; public System.Drawing.Point ptMinPosition; public System.Drawing.Point ptMaxPosition; public System.Drawing.Rectangle rcNormalPosition; } int..
C# .NET - Image Comp using System.Drawing; private bool ImageComp(Bitmap src, Bitmap bmp) { string strSrc, strBmp; for (int i = 0; i < src.Width; i++) { for (int j = 0; j < src.Height; j++) { strSrc = src.GetPixel(i, j).ToString(); strBmp = bmp.GetPixel(i, j).ToString(); if (srcInfo != bmpInfo) { return false; } } } return true; } // using 사용 public bool ImageComp(string a, statusList b) { using (Bitmap A = new Bitm..
C# WinAPI - Window Capture using System.Runtime.InteropServices; using System.Drawing; [DllImport("user32.dll")] private static extern Boolean PrintWindow(IntPtr hWnd, IntPtr hdcBlt, int nFlags); private Bitmap WinCapture(IntPtr handle) { using (Graphics newGraphics = Graphics.FromHwnd(handle)) { Rectangle rect = Rectangle.Round(newGraphics.VisibleClipBounds); Bitmap bmp = new Bitmap(rect.Width, rect.Height); using (Graph..
C# WinAPI - MoveWindow using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern bool MoveWindow(IntPtr hWnd, int X, int Y, uint nWidth, uint nHeight, bool bRepaint); private void MoveWinResize(IntPtr hWnd, int X, int Y, uint nWidth, uint nHeight, bool bRepaint = true) { MoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint); }
C# WinAPI - PostMessage char, string using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam); private enum WMessages : uint { WM_MOUSEMOVE = 0x200, WM_LBUTTONDOWN = 0x201, //Left mousebutton down WM_LBUTTONUP = 0x202, //Left mousebutton up WM_LBUTTONDBLCLK = 0x203, //Left mousebutton doubleclick WM_RBUTTONDOWN = 0x204, //Right mousebutt..
C# WinAPI - SendMessage MouseClick using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern int SendMessage(IntPtr hwnd, uint wMsg, int wParam, IntPtr lParam); private void SendClick(IntPtr handle, int X, int Y) { SendMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 1, new IntPtr(Y * 0x10000 + X)); SendMessage(handle, (uint)WMessages.WM_LBUTTONUP, 0, new IntPtr(Y * 0x10000 + X)); }
C# WinAPI - PostMessage MouseClick using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam); private void MouseClick(IntPtr handle, int X, int Y) { PostMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 1, new IntPtr(Y * 0x10000 + X)); PostMessage(handle, (uint)WMessages.WM_LBUTTONUP, 0, new IntPtr(Y * 0x10000 + X)); }
C# WinAPI - FindWindowEx using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] private static extern IntPtr FindWindowEx(IntPtr hWnd1, IntPtr hWnd2, string lpsz1, string lpsz2); private IntPtr FindHandleEx(String winName) { IntPtr handle1 = FindWindow(null, winName); IntPtr handle2 = FindWindowEx(handle1..