Results 1 to 19 of 19

Thread: take screenshot of the desktop after every milisecond

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    take screenshot of the desktop after every milisecond

    I am trying to do that, but it's taking hell a lot of RAM space and slowing down my system. Is there any other faster way to do that so it does not take much RAM and does not slow down my system?
    Baaaaaaaaah

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Anything running every milisecond is going to chew up resources. What are you trying to accomplish? Perhaps there is a better way.

  3. #3
    Staifour
    Guest
    i think that every millisecond is not the hard point Hack but taking the screenshot is

  4. #4
    Fanatic Member dongaman's Avatar
    Join Date
    Aug 2001
    Location
    xi'an
    Posts
    616
    I am wonder what way do u use to snapshot the desktop.
    Do u use send PrintScreen keys
    I am just aman.

  5. #5
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    This is actually a good question. I am going to attempt to write my own remote control program which will allow me to take control of any machines on a network.
    This is the sort of thing that I would want. I don't know if ever millisecond is required. Perhaps every 250 milliseconds would be appropriate.

    Mega.
    "If at first you don't succeed, then skydiving is not for you"

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Originally posted by [B]Staifour]/B]
    i think that every millisecond is not the hard point Hack but taking the screenshot is
    Taking the screen shot is the easy part. Here are two different ways. To save the screen as a bitmap...
    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
    25. 'Usage
    26. Call SaveScreen("C:\Windows\Desktop\shot1.bmp")

    To simply send to the clipboard, see MattT's post here
    http://www.vbforums.com/showthread.p...t=print+screen

  7. #7
    Fanatic Member dongaman's Avatar
    Join Date
    Aug 2001
    Location
    xi'an
    Posts
    616
    Like my ways
    I am just aman.

  8. #8

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Right now, I am trying to write a program that will alow you to make a video of your desktop (so the frame rate does matter if you wanna get better video). This program can also be used to make a video of you playing a game but it won't work because today's games take hell a lot of RAM to work correctly, so I need some better code to make it work fast but not take more RAM.
    Baaaaaaaaah

  9. #9
    Staifour
    Guest
    first of all
    i just want you to know that there are software that does that (try to find a software in the lotus collection i think)
    secondly:
    to make a video normally you don't use a frame rate greater than 25 so what you need is a timer with an interval of 40 that will read the code of Hack i suggest:

    add a new folder to your C drive and call it TestDir
    add a timer to your form and name it TestTimer and set it's interval to 40
    add this code to the form
    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. Private Const VK_SNAPSHOT = &H2C
    4. Private Function SaveScreen(ByVal theFile As String) As Boolean
    5. On Error Resume Next
    6. Call keybd_event(vbKeySnapshot, 1, 0, 0)
    7. SavePicture Clipboard.GetData(vbCFBitmap), theFile
    8. SaveScreen = True
    9. End Function
    10.  
    11. Private Sub TestTimer_Timer
    12.    DoEvents
    13.    Static Frame
    14.    TestTimer.Interval = 40
    15.    Frame = Frame + 1
    16.    Call SaveScreen("C:\TestDir\shot" & Frame & ".bmp")
    17. End Sub
    now goto that folder and see the results

    hope it'll work (i didn't test Hack's code)
    if it doesn't wotk try to change vbKeySnapshot in the SaveScreen function to VK_SNAPSHOT

    tell me what happens

  10. #10
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    i did something like what you asked for but the funny thing is where you would put the images. It would be at leat a 1.5 second wait to transfer a 2.5 meg (1024x768) across the network. Retrieval of the image is also difficult unless you number it and it will still be slowed down (ie ur screenshot is at 2 while it has captured 5 screenshots). And just saving to 1 picture will cause 'File already open' errors. Many aspects to think about.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  11. #11

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by BuggyProgrammer
    i did something like what you asked for but the funny thing is where you would put the images. It would be at leat a 1.5 second wait to transfer a 2.5 meg (1024x768) across the network. Retrieval of the image is also difficult unless you number it and it will still be slowed down (ie ur screenshot is at 2 while it has captured 5 screenshots). And just saving to 1 picture will cause 'File already open' errors. Many aspects to think about.
    Acutally, I thought of something different for my upcoming chat program. it will just send 1 desktop picture at the start, and then it'll send a the x and y coordinates' colours that are different from the previous desktop picture, and then you send them over the network as ASCII text. I think that method will be a little faster but haven't tried the full program yet.
    Baaaaaaaaah

  12. #12
    Staifour
    Guest
    if i was the one programming that network program i would change the size of the picture (decrease it) then i will resize it after transfering it to the other computer on the same network so that it matches the screen, i know this will decrease the pictures quality but i think it is the faster way, also you can cahnge the extension of the pictures (or try to)

    for the synchronizing thing that BuggyProgrammer said, well, you can add a text file that will save the number of the last saved picture, the other computer that is trying to retrieve the pictures will read the text file and load the picture depending on it

    isn't it an idea ?? i think it is

  13. #13

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by Staifour
    first of all
    i just want you to know that there are software that does that (try to find a software in the lotus collection i think)
    secondly:
    to make a video normally you don't use a frame rate greater than 25 so what you need is a timer with an interval of 40 that will read the code of Hack i suggest:

    add a new folder to your C drive and call it TestDir
    add a timer to your form and name it TestTimer and set it's interval to 40
    add this code to the form
    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. Private Const VK_SNAPSHOT = &H2C
    4. Private Function SaveScreen(ByVal theFile As String) As Boolean
    5. On Error Resume Next
    6. Call keybd_event(vbKeySnapshot, 1, 0, 0)
    7. SavePicture Clipboard.GetData(vbCFBitmap), theFile
    8. SaveScreen = True
    9. End Function
    10.  
    11. Private Sub TestTimer_Timer
    12.    DoEvents
    13.    Static Frame
    14.    TestTimer.Interval = 40
    15.    Frame = Frame + 1
    16.    Call SaveScreen("C:\TestDir\shot" & Frame & ".bmp")
    17. End Sub
    now goto that folder and see the results

    hope it'll work (i didn't test Hack's code)
    if it doesn't wotk try to change vbKeySnapshot in the SaveScreen function to VK_SNAPSHOT

    tell me what happens
    Hmmm, this method is working hell a lot faster than the one I was using before in which you use "StretchBlt" to first copy the picture onto a picture box and then you save it as a file. I'll work on it more and then hopefully it will come out as a really fast method of creating a video.
    Last edited by abdul; Jan 27th, 2002 at 12:56 PM.
    Baaaaaaaaah

  14. #14
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    2 questions.

    1) Why do the pictures no contain the mouse? When you send a picture to the Clipboard the Cursor always disapears....and can you fix it?


    2) Is there anyway to save the files as .JPG instead of BMP? BMP's take up way too much space.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  15. #15
    Staifour
    Guest
    well
    for the cusor i know why it doesn't appear
    this code presses PrintScreen from the keyboard and PrintScreen doesn't take the cursor but i don't see the it as a problem, but if you want to knw where the cursor is you should use an API function that returns the mouse position and write a code that will draw the cursor
    i think this is the way (not sure)

  16. #16
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    i bltted a picture of the mouse to the picture then saved it so you can see the mouse.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  17. #17
    New Member
    Join Date
    Oct 2000
    Posts
    3

    saving as JPGs

    There's code at vbAccelerator.com for saving pictures as JPGs. It requires some DLL. But you can download it as a package with a demo project.

  18. #18
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    converting takes more time too
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  19. #19
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Originally posted by Spetnik
    Most remote control programs do not constantly take screenshots. After the initial screenshots, screenshots are only taken occasionally. What the program does is capture paint events on the screen and sends them over to the client, which replicates them on the original screenshot. This way, used resources and data transfer overhead are minimized.
    most people don't bump up really old posts too

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