如何关闭Chrome页面?

时间:2014-10-24 23:36:27

标签: c# google-chrome c#-4.0 sendkeys

我想使用此代码关闭Chrome页面。

  textPrint("^W");//Have to close 1 page from chrome

  [DllImport("user32.dll")]
  public static extern int SetForegroundWindow(IntPtr hWnd);
  private void textPrint(String text)
  {
    SendKeys.SendWait(text);
  }

但是当我使用此代码时,Chrome会关闭所有页面。如何解决这个问题,我想只关闭打开的页面?

编辑: 我试过Control + w。这是工作。 W不需要做爱人

2 个答案:

答案 0 :(得分:0)

你试过控制+ f4吗?

textPrint("^{f4}");

答案 1 :(得分:0)

你可能应该发送“^ w”。 Ctrl + Shift + W关闭所有标签