Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Public Const KEYEVENTF_KEYUP = &H2 Public Function ImmagineSchermo(Optional ActiveWindow As Boolean) As Picture Dim Picture As StdPicture Set Picture = Clipboard.GetData(vbCFBitmap) If ActiveWindow Then keybd_event vbKeyMenu, 0, 0, 0 End If keybd_event vbKeySnapshot, 0, 0, 0 DoEvents keybd_event vbKeySnapshot, 0, KEYEVENTF_KEYUP, 0 If ActiveWindow Then keybd_event vbKeyMenu, 0, KEYEVENTF_KEYUP, 0 End If Set ImmagineSchermo = Clipboard.GetData(vbCFBitmap) Clipboard.SetData Picture, vbCFBitmap End Function
Poi create una picture e inserite questo per visualizzare lo schermo nella picture
Set Picture1.Picture = ImmagineSchermo()
Invece per visualizzare l'immagine della finestra attiva(form)
Set Picture1.Picture = ImmagineSchermo(True)
Ciao by gius
Aggiungi un commento