Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

paste screen shots into MS Paint

I have made a program and i want to add the ability in it to set a hotkey to take a screen shot, paste the screen shot into MS Paint, then save the screen shot in incremental order. ie ss1, ss2, ss3, etc...

thanks in advance, and i'm sorry if this topic has been covered already i couldn't find anything on it.
[329 byte] By [Ryu] at [2007-11-11 9:56:53]
# 1 Re: paste screen shots into MS Paint
do u want those three steps ?
If u want finally save the screen capture then do the foloowing :

SendKeys "{PRTSC}", True
SavePicture Clipboard.GetData(), "some_path\ss1.bmp"

better version using API :

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C

and it will be :

keybd_event VK_SNAPSHOT, 1, 0, 0
SavePicture Clipboard.GetData(), "some_path\ss1.bmp"
Amahdy at 2007-11-11 17:23:27 >
# 2 Re: paste screen shots into MS Paint
for order :

I have an opened thread to asking about better method to know if the directory contains a specific file and picture or not but I hadn't any advanced methods ;

so use this as well as u can find better method :

Dim i As Integer
i = 0
Do Until 0 = 7 'infinit loop
If Dir("some_path\ss" & i & ".bmp") <> "" Then
SavePicture Clipboard.GetData(), "some_path\ss" & i & ".bmp"
Exit Do
Else
i = i + 1
End If
Loop
Amahdy at 2007-11-11 17:24:29 >
# 3 Re: paste screen shots into MS Paint
Thank you Amahdy, That was exactly what i was needing. :)
Ryu at 2007-11-11 17:25:28 >
# 4 Re: paste screen shots into MS Paint
Dim I As Long
I = 0
While Dir("some_path\ss" & I & ".bmp") <> ""
I = I + 1
Wend
SavePicture Clipboard.GetData(), "some_path\ss" & I & ".bmp"
Ron Weller at 2007-11-11 17:26:33 >
# 5 Re: paste screen shots into MS Paint
Thanks Ron and Amahdy, that works perfectly, I have no idea why i was trying to make it more complicated than it really was. I guess i forgot to K.I.S.S.
Ryu at 2007-11-11 17:27:32 >
# 6 Re: paste screen shots into MS Paint
:o Oops i spoke too soon :o

I' forgot i was manually loading a screenshot into the clipboard to print from and i can't get my program to take a screen shot on it's own.

Just to recap, I want my program to be able to...
1. Take a screen shot (not working)then
2. save that screen shot. (this part is working)

with just one button click.
Ryu at 2007-11-11 17:28:31 >
# 7 Re: paste screen shots into MS Paint
The API doesn't work too ?

It's true u can have a problem with sendkeys method , but the API must work .
Amahdy at 2007-11-11 17:29:31 >
# 8 Re: paste screen shots into MS Paint
Try These Links:
http://www.freevbcode.com/ShowCode.Asp?ID=866
http://www.freevbcode.com/ShowCode.Asp?ID=3473
http://www.freevbcode.com/ShowCode.Asp?ID=1049
Ron Weller at 2007-11-11 17:30:34 >