此代码捕获活动窗口,并通过调用要粘贴的多个屏幕截图将其粘贴到 power point 幻灯片中sub PrintScreen
,之后需要 5 秒来捕获活动窗口的屏幕。虽然我希望每当我按下“F7 或 F3 等”等特定键时,它应该打印屏幕而不是等待 5 秒。我只想按下该键,它会调用 sub,我在其中指定打印和粘贴以及其他功能。
Sub Screen_Capture_VBA()
Dim Sec4 As Date
MsgBox "Note: Three seconds after you click OK " & _
"the active window will be copied to the clipboard."
Sec4 = DateAdd("s", 4, Now)
myValue = InputBox("Give me no of screen shots you want to capture")
For I = 1 To myValue
PrintScreen
Next I
End Sub
这是我的打印屏幕子。
Sub PrintScreen()
Sleep 5000
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
ActivePresentation.Slides.Add 1, ppLayoutBlank
ActivePresentation.Slides(1).Shapes.Paste
End Sub