hello,
How can I take a screenshot, and then write it to a bmp file, p.e. the program automaticly takes the shot, and then writes it to a folder.
Thanks
Printable View
hello,
How can I take a screenshot, and then write it to a bmp file, p.e. the program automaticly takes the shot, and then writes it to a folder.
Thanks
Here I posted links to find code about capturing screen.
http://www.codeguru.com/forum/showth...hlight=capture
Cesare Imperiali
Howe to take screenshots of current form every 5 minutes and save them as bmp files:
Download attached zip file. It is a working Vb example. Open it by doubleclicking on the Vbp file.
To capture entire screen, look for next reply...
Previous example captured only current form. To capture whole screen, I did it a bit different:
This third example is the same as above, but it has one extra feature: reduces size of saved Bmp to 256 (or less, if you enter code and modify passed values) colors. This is usefiul to reduce size of Bmp saved (around 1/3 lighter each).
Wraning: in this example as in the previous one, I changed the timer to trig every 3 seconds instead of every 5 minutes (to test without waiting too much)...
The module that reduces colors of Bmp is not mine: code comes from http://www.Planet-Source-Code.com/vb...36162&lngWId=1 Credits on this feature must go to that author. I modified a bit the code changing all the "if...end if" in a more structured "If...ElseIf...End If"
Fourth... as per request by one user, the same code as last one with a different filename....
I've just tried using this as an example for a program I'm working on. It seems to work.Quote:
Originally Posted by Cimperiali
I'm curious why you used the SetTimer/Killtimer, instead of the timer component in vb.
thanks
Because the originalrequest where all this started from was to take
a screenshot every 5 minutes. With Api Timer, you can set that intreval without
having to skip cycles as you have to do with a "normal" timer control.
Thanks for the explantion- but do you mean skip CPU cycles?Quote:
Originally Posted by Cimperiali
Why is that an issue based on the original 5 minute interval?
Where is it documented that the vb timer skips cycles, and the timer that you used does not?
I don't believe I have read anything about this cycle issue, in regard to the timers.
SetTimer
The SetTimer function creates a timer with the specified time-out value.
UINT SetTimer(
HWND hWnd, // handle of window for timer messages
UINT nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // address of timer procedure
);
Parameters
hWnd
Handle to the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
nIDEvent
Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored.
uElapse
Specifies the time-out value, in milliseconds.
lpTimerFunc
Pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc <timers_52xv.htm>.
If lpTimerFunc is NULL, the system posts a WM_TIMER <timers_1w6q.htm> message to the application queue. The hwnd member of the message's MSG <JavaScript:alink_1.Click()> structure contains the value of the hWnd parameter.
Return Values
If the function succeeds, the return value is an integer identifying the new timer. An application can pass this value, or the string identifier, if it exists, to the KillTimer <timers_88xe.htm> function to destroy the timer.
If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError <errors_3uwi.htm>.
Remarks
An application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER.
The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter.
Thanks- this is really getting interesting
Nah, Cimperiali is talking about the maximum interval that you can set the timers to. The native VB timer object has a maximum interval of 65,535 ms, which is just over a minute. Therefore, if the interval is set to 1 minute, 4 out of every 5 _Timer events need to be disregarded, in order to achieve the 5 minute interval requested. With the API timer, you can set an actual 5 minute interval (I presume, haven't tried) so there is no need to "skip cycles".Quote:
Originally Posted by cappy2112
Cimperiali - I hope I interpreted your post right :D
Quote:
Originally Posted by penagate
Ahh- I see. Yes, it makes total sense now.
Thanks to both of you !
Quote:
Originally Posted by penagate
Wait- now I'm confused. Both timers have a 65535 ms interval resolution- at least from my documentation.
So I don't see how you could get much over 1 minute with either timer.
The application in captureandsave256bmp.zip works fine. But I wonder why the author save the file as BMP, cant it be saved as jpg or other format which would reduce the file size?
Ahhhh!!!! Look its a necrophilliac, a necromonger, no! It's a necroposter!!! To which we all say ewwwww!!! Disgusting! :)
Okay, enough ragging on you. Please, in the future six, create a new thread and copy the url into your new thread.
Now, to answer your question...
Look up the SavePicture function to know why it is saved as a BMP...
Then use your best friends (yahoo, google, ask, answers, bing) to search for vb6 save as jpg and see the vbaccelerator example.
Then remember that the jpg/jpeg libraries were still under copy right law at the time vb6.0 came out...
Good Luck