I am trying to execute a screen capture. My problem is the first time I click the command button it shows the last picture. I have to click it twice to get a new picture here is my code.
*Credits to Matthew Gates for some of the code.
Public Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As _
Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo _
As Long)
Public Const VK_SNAPSHOT = &H2C
Public Const KEYEVENTF_EXTENDEDKEY = &H1
Public Const KEYEVENTF_KEYUP = &H2
Private Sub cmdScreen_Click()
Me.WindowState = vbMinimized
DoEvents
keybd_event vbKeySnapshot, 1, 0, 0
keybd_event vbKeySnapshot, 0, KEYEVENTF_KEYUP, 0
Form2.Picture = Clipboard.GetData(vbCFBitmap)
Form2.Show
End Sub
