
-----------------------------------
HazySmoke)345
Tue Mar 07, 2006 4:33 pm

How do you find the keycode for the key Print Screen?
-----------------------------------
Yes... I did tried to make a short program in order to find the keycode, it goes something like this:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Print "Keycode = " & KeyCode
End Sub

It works with any keys on the keyboard besides Print Screen... Nothing happens when I press that particular key. I wonder why. Anyone know the number for that?

-----------------------------------
[Gandalf]
Tue Mar 07, 2006 4:39 pm


-----------------------------------
For simple things like this, and for something as... popular...  as VB, you should use google.

Answer: vbKeyPrint (0x2A)

-----------------------------------
HazySmoke)345
Wed Mar 08, 2006 6:02 pm


-----------------------------------
Thanks for helping... that  was kind of simple. Now here's the second part.

Now I want the computer to capture a screenshot. I entered this in the form:
Private Declare Sub keybd_event Lib "user32.dll" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2

Private Sub Form_Load()
    keybd_event 42, 0 Or KEYEVENTF_KEYUP, 0, 0
End Sub

Somehow, the computer did not hit that key. Is there a way to make the script work, or, even better, an alternative of capturing a screenshot besides forcing Windows to press the PrintScreen key??

-----------------------------------
Shaun Dreclin
Fri Mar 10, 2006 2:42 am


-----------------------------------
Well if your doing this just for a functioning screen capture program, Download Printkey 2000

If your doing it to make the program yourself, I cant help ya :P

-----------------------------------
GlobeTrotter
Fri Mar 10, 2006 10:31 pm


-----------------------------------
If you only want to capture an image of the form, that is not too difficult.  If you need the rest of the computer screen to be captured, I can't help you.

-----------------------------------
HazySmoke)345
Fri Mar 10, 2006 10:37 pm


-----------------------------------
Well, the thing is that I do need the whole computer screen.  :?

-----------------------------------
Brightguy
Wed Mar 15, 2006 12:22 am

Re: Screen capture
-----------------------------------
This just blits the desktop onto the Form background.  As usual, turn on AutoRedraw to make sure it isn't erased.
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Sub Form_Load()
    Dim hDCDesktop As Long
    hDCDesktop = GetDC(GetDesktopWindow)
    BitBlt Me.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, hDCDesktop, 0, 0, vbSrcCopy
    DeleteDC hDCDesktop
End Sub

-----------------------------------
HazySmoke)345
Wed Mar 15, 2006 12:34 pm


-----------------------------------
Cool, thanks!

+25 bits :)
