Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do you find the keycode for the key Print Screen?
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HazySmoke)345




PostPosted: Tue Mar 07, 2006 4:33 pm   Post subject: 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:

VisualBASIC:
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?
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Tue Mar 07, 2006 4:39 pm   Post subject: (No subject)

For simple things like this, and for something as... popular... as VB, you should use google.

Answer: vbKeyPrint (0x2A)
HazySmoke)345




PostPosted: Wed Mar 08, 2006 6:02 pm   Post subject: (No subject)

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:
VisualBASIC:
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




PostPosted: Fri Mar 10, 2006 2:42 am   Post subject: (No subject)

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 Razz
GlobeTrotter




PostPosted: Fri Mar 10, 2006 10:31 pm   Post subject: (No subject)

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




PostPosted: Fri Mar 10, 2006 10:37 pm   Post subject: (No subject)

Well, the thing is that I do need the whole computer screen. Confused
Brightguy




PostPosted: Wed Mar 15, 2006 12:22 am   Post subject: Re: Screen capture

This just blits the desktop onto the Form background. As usual, turn on AutoRedraw to make sure it isn't erased.
VisualBASIC:
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




PostPosted: Wed Mar 15, 2006 12:34 pm   Post subject: (No subject)

Cool, thanks!

+25 bits Smile
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: