I want to get the whole screen in image control and then save it to my folder.
Every thing is working fine except the image saved in the folder. Is there any problem in the following code? I also want that the image saved should be overwritten.
vb Code:
Private Sub Command1_Click()
Timer1.Enabled = True
Me.WindowState = vbMinimized
End Sub
Private Sub Timer1_Timer()
On Error GoTo errhandler
Label1.Caption = Val(Label1.Caption) + 1
For i = 1 To 10
Clipboard.Clear
keybd_event vbKeySnapshot, 0, 0, 0
DoEvents
Set Image1.Picture = Clipboard.GetData(vbCFBitmap)
SavePicture Image1.Picture, "C:\Documents and Settings\Vivek\My Documents\screenshots\image" & i & ".bmp"
Next i
errhandler:
MsgBox " completed"
Timer1.Enabled = False
End Sub
Last edited by vivek_master146; Jun 22nd, 2007 at 06:36 AM.
Dont rely only on your luck. Work hard until You get success.
I'm not sure you can do it this way. In case it may help I have attached a screen capture project I made some time ago.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
i.e., the backslash is automatically appended by the code.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Ur project is ok. But i want a program which should save no. of images which are specfied in the textbox and should use timer to save image at particular interval and it should also overwrite it without any error.
Dont rely only on your luck. Work hard until You get success.
It shoudn't be to difficult to modify the project so as to have the program minimize the window state and, using a timer, set the code to capture the screen as many times as needed. To be sure, it's going to require a bit of work, of course.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Ya. Because i will have to go through the whole code and i have just few months exp. in vb its bit diff. for me. can u modify my above code so that i can save it to a folder with interval and the files should also be overwritten
Dont rely only on your luck. Work hard until You get success.
Sorry, don't have much time now, but I can have a go at it maybe tomorrow in case no one provides any more suitable code. But I don't think you have to understand much of the code, just place the "shooting" code in the timer event to start with. See what's going on in the "Crop/Capture" button's click event handler. Thereafter modify as necessary, i.e., try to deal with all the errors that will pop up.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
If Dir("C:\Documents and Settings\Vivek\My Documents\screenshots\image" & i & ".bmp") > vbNullString Then Kill "C:\Documents and Settings\Vivek\My Documents\screenshots\image" & i & ".bmp"
SavePicture Image1.Picture, "C:\Documents and Settings\Vivek\My Documents\screenshots\image" & i & ".bmp"
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Ok. I have got the code.its working fine except it generates error sometimes.The error is "Can't open clipboard" in the line "Set Image1.Picture = Clipboard.GetData(vbCFBitmap)". The code is:
vb Code:
Private Sub Timer1_Timer()
i = i + 1
Label1.Caption = Val(Label1.Caption) + 1
Clipboard.Clear
keybd_event vbKeySnapshot, 0, 0, 0
DoEvents
Set Image1.Picture = Clipboard.GetData(vbCFBitmap)
SavePicture Image1.Picture, "C:\Documents and Settings\Vivek\My Documents\screenshots\image" & i & ".bmp"
Image1.Picture = Nothing
If i = 10 Then
Timer1.Enabled = False
End If
End Sub
Dont rely only on your luck. Work hard until You get success.
When am i clicking on another window then the error is displaying otherwise when i am just kepping my pc idle then no error is dispalyed. Should i use api function other than timer?
Dont rely only on your luck. Work hard until You get success.
I think it's better to use more advanced API that gives you the ability to capture window. and to get such a code just search the forum for a Capture word .
or get this direct link to ready project made by Moeur member http://www.vbforums.com/attachment.p...8&d=1123272285
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
Hey! I want to capture images at intervals and save them in a folder. i have done it..
Does that mean it actually worked in some cases?
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
it's an API function to send buttons press event for keyboard
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
it's an API function to send buttons press event for keyboard
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
i.e., without the "Set" command. I wonder if that could make a difference such as to cause the error. On the other hand, the code on that site is using a picturebox. I wonder if Image1 in Vivek_Master146's code is an Image control or a Picturebox.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
vivek_master, i don't want to have you change your whole way of thinking, but the only useful function i can think of for this is you have two computers any you are monitoring the snapshot from another computer. If this is why you are doing this, windows has built-in tools for this.
I am attaching the project. The error is not displaying if the project is in focus and when i m mizimizing the project then the error is displaying.Help!
Dont rely only on your luck. Work hard until You get success.
I just want to keep a check on the activities of the cpomputer by capturing screenshot at intervals and saving it to a folder?
Originally Posted by Lord Orwell
vivek_master, i don't want to have you change your whole way of thinking, but the only useful function i can think of for this is you have two computers any you are monitoring the snapshot from another computer. If this is why you are doing this, windows has built-in tools for this.
Dont rely only on your luck. Work hard until You get success.
Try to add this without any modification :and let me know :
Private Sub Timer1_Timer()
keybd_event vbKeySnapshot, 0, 0, 0
Set Image1.Picture = Clipboard.GetData(vbCFBitmap)
SavePicture Image1.Picture, "C:\image1.bmp"
End Sub
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
Try to add this without any modification :and let me know :
Private Sub Timer1_Timer()
keybd_event vbKeySnapshot, 0, 0, 0
Set Image1.Picture = Clipboard.GetData(vbCFBitmap)
SavePicture Image1.Picture, "C:\image1.bmp"
End Sub
Ur code will generate error as the name image1.bmp is same. and if u write a code to overwrite it then also it will save 1 image i.e.image1. i want to save multiple images.
Dont rely only on your luck. Work hard until You get success.
Take an advice from a friend : No need to do jop with hard way , while you have to do it with easy way . there's too ways to do this jop ,nice and easy without dealing with keyboard event or clipboard data ,and both of them not truly under control from you.
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
ok , plz tell me the truly aim of your program to tell you the best way - from my point of view - to do it.cause there's too many different solution at my mind , but I need to decide the best for the your situation.
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
and just for your knowledge , it'll not give you an erro if you saved the picture over old captured picture , unless you set the attribute of the picture file to readonly.
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
ok , I can't help you any more about this task while you working in keybd_event function - It's not at my own library , but with your code and with my little help of explaning about error at saving picture , I'm sure you can deal with this.
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
ok ..you can use the increment I + 1 to save your ten captured pictures
but I can't give you a promise that Clipboard.GetData will not raise an error ,
cause I told you , you dealing with somthing not stable (Clipboard) which many programs dealing with it , at the same time your program does. I hope that I made the proplem of your code more clear.
Some times when you make a step forward ...You can't get back. Be sure where you make your steps.
Set Image1.Picture = Clipboard.GetData(vbCFBitmap)
I just ran your code, with
Code:
Image1.Picture = Clipboard.GetData(vbCFBitmap)
for 25 pictures, with the form being minimized in the 3rd one, and it didn't throw an error.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Set Image1.Picture = Clipboard.GetData(vbCFBitmap)
I just ran your code, with
Code:
Image1.Picture = Clipboard.GetData(vbCFBitmap)
for 25 pictures, with the form being minimized in the 3rd one, and it didn't throw an error.
That's what I pointed out in post #21.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
I tried both the method set and without set. then also it is displaying error?It will give error when i minizmize the project and click on another window.
Dont rely only on your luck. Work hard until You get success.