[DllImport(“user32.dll”)]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
[DllImport(“user32.dll”)]
static extern byte MapVirtualKey(byte wCode, int wMap);
[DllImport(“user32.dll”)]
static extern IntPtr FindWindow(string strClass, string strWindow);
[DllImport(“user32.dll”)]
private static extern IntPtr GetForegroundWindow();
[DllImport(“user32.dll”, EntryPoint = “SetForegroundWindow”, SetLastError = true)]
private static extern void SetForegroundWindow(IntPtr hwnd);
[DllImport(“user32.dll”, CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
private void ShowVideo()
{
//keybd_event(18, MapVirtualKey(18, 0), 0, 0); //按下CTRL鍵。
while (true)
{
Thread.Sleep(100);
//获取目标窗口句柄
//可以通过工具中Spy++获得