Results 1 to 2 of 2

Thread: copy screen

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Netherlands
    Posts
    115

    copy screen

    if I use the keyb_event to send a printscreen command, I just get a picture from the application. nothing else. how can I copy the screen completely.

    VIP

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
    2. ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    3.  
    4. Private Const VK_SNAPSHOT = &H2C
    5.  
    6. 'Author: Dalin Nie (Edited by Matthew Gates)
    7. 'Origin: [url]http://www.vbcode.com[/url]
    8. 'Purpose: This function capture the screen or the active window of your computer. Programmatically and save it to a .bmp file.
    9. 'VB version: VB 6,VB 5,VB 4/32
    10. 'Save Screen As Bitmap
    11. Private Function SaveScreen(ByVal theFile As String) As Boolean
    12. On Error Resume Next
    13.  
    14. 'To get the Entire Screen
    15. Call keybd_event(vbKeySnapshot, 1, 0, 0)
    16.  
    17. 'To get the Active Window
    18. 'Call keybd_event(vbKeySnapshot, 0, 0, 0)
    19.  
    20. SavePicture Clipboard.GetData(vbCFBitmap), theFile
    21.  
    22. SaveScreen = True
    23. Exit Function
    24. End Function
    VB Code:
    1. ' Prntform sample from BlackBeltVB.com
    2. ' [url]http://blackbeltvb.com[/url]
    3. '
    4. ' Written by Matt Hart
    5. ' Copyright 1999 by Matt Hart
    6. '
    7. ' This software is FREEWARE. You may use it as you see fit for
    8. ' your own projects but you may not re-sell the original or the
    9. ' source code. Do not copy this sample to a collection, such as
    10. ' a CD-ROM archive. You may link directly to the original sample
    11. ' using "http://blackbeltvb.com/prntform.htm"
    12. '
    13. ' No warranty express or implied, is given as to the use of this
    14. ' program. Use at your own risk.
    15. '
    16. ' This sample utilizes a better method than "PrintForm" to print the contents of
    17. ' a Form. PrintForm sometimes excludes grid and other controls. This method simulates
    18. ' pressing the PrintScrn key, which copies the image of either the form or screen to
    19. ' the clipboard. Note that I call the .Clear method of the Clipboard first - that's because
    20. ' it might already have text or something on it.
    21. '
    22. ' When printing, note that I scale the picture's height to proportionally fit the
    23. ' printer's resolution. The procedure would need to be adjusted if the Height of the
    24. ' Form/Screen was greater than Printer.ScaleHeight, or if the Height was greater than
    25. ' the Width and the Width was greater than Printer.ScaleWidth.
    26. '
    27. ' Updated with VK_MENU keypresses - note that NT needs these.
    28.  
    29. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    30. Private Const VK_MENU As Byte = &H12
    31. Private Const VK_SNAPSHOT As Byte = &H2C
    32. Private Const KEYEVENTF_KEYUP = &H2
    33.  
    34.  
    35. Dim lHeight As Long
    36.     Clipboard.Clear
    37.     Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
    38.     DoEvents
    39.     Call keybd_event(VK_SNAPSHOT, 1, KEYEVENTF_KEYUP, 0)
    40.     Printer.Print
    41.     lHeight = (Printer.ScaleWidth / Screen.Width) * Screen.Height
    42.     Printer.PaintPicture Clipboard.GetData, 0, 0, Printer.ScaleWidth, lHeight
    43.     Printer.EndDoc
    Take your pick!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width