Capture screenshot of active window?

前端 未结 11 2227
春和景丽
春和景丽 2020-11-21 23:34

I am making a screen capturing application and everything is going fine. All I need to do is capture the active window and take a screenshot of this active window. Does an

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 00:25

    If you want to use managed code: This will capture any window via the ProcessId.

    I used the following to make the window active.

    Microsoft.VisualBasic.Interaction.AppActivate(ProcessId);
    Threading.Thread.Sleep(20);
    

    I used the print screen to capture a window.

    SendKeys.SendWait("%{PRTSC}");
    Threading.Thread.Sleep(40);
    IDataObject objData = Clipboard.GetDataObject();
    

提交回复
热议问题