0
我正在製作一個應用程序,我希望用戶能夠點擊一個按鈕,捕捉Word或其他程序佔用屏幕70%,並且我的應用程序佔用餘下的30個%。快照應用程序和文字
這可能嗎?
有沒有一種原生的方式來做到這一點?
是否有第三方的方式來做到這一點?
在此先感謝您的幫助!
我正在製作一個應用程序,我希望用戶能夠點擊一個按鈕,捕捉Word或其他程序佔用屏幕70%,並且我的應用程序佔用餘下的30個%。快照應用程序和文字
這可能嗎?
有沒有一種原生的方式來做到這一點?
是否有第三方的方式來做到這一點?
在此先感謝您的幫助!
這的確是可能的,試試這個功能:
[DllImport("user32.dll")]
private static extern bool GetWindowRect(IntPtr hwnd, ref Rectangle rectangle);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool PostMessage(IntPtr hWnd, uint msg, int WPARAM, int LPARAM);
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[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);
public const uint WM_SYSCOMMAND = 0x0112;
public const int SC_NEXTWINDOW = 0xF040;
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
public static readonly IntPtr HWND_TOP = new IntPtr(0);
public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
public const UInt32 TOPMOST_FLAGS = 0x0002 | 0x0001;
Public void resisezeWindow(String procesname, int Width, int Height, Boolean bringtofront)
{
foreach (Process proc in Process.GetProcesses())
{
IntPtr id = proc.MainWindowHandle;
Rectangle rect = new Rectangle();
GetWindowRect(id, ref rect);
if (proc.MainWindowTitle.Contains(procesname))
{
PostMessage(proc.Handle, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
MoveWindow(id, 0, 0, Width, Height, true);
if(bringtofront) SetWindowPos(id, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
proc.Refresh();
}
}
}
的點擊here看到原來的問題。