philz
Joined: 05 Jun 2007 Posts: 78 Location: USA
|
Posted: Wed Apr 23, 2008 2:49 pm Post subject: More dll help--setclipboarddata |
|
|
This is closely related to the last question I had. I am looking to create an application for taking screenshots of a rectangle that is directly integrated with the clipboard. The GDI+ wrapper library by PhiLho (it is such an awesome script) is what I am using to save images to a file. I already have another script where I click a hotkey and it opens a save dialogue so I can save alt-printscreens and printscreens to a file.
Now to have screen rectangles sent to the clipboard. I always liked it working with the clipboard because I can easily past in ms office. I created the save to file dialogue with gdi+ for putting screenshots in emails. The email client's ive used don't seem to allow me to copy pics right from clipboard.
Also If anyone has any suggestions to make the rectangle redraw but not be so flickery that would be cool too. I have it redraw so i don't get legacy rectangles.
anyway here is the code:
| Code: | coordmode, mouse, screen
If (GDIplus_Start() != 0)
{
msgbox, An error occured while opening GDIplus.`nNow closing.
exitapp
}
hotkey,lbutton, selectbox, on
settimer, rectangle, 100
settimer, rectangle, off
return
selectbox:
mousetog:= mousetog=1 ? 0 : 1
if % mousetog
{
mousegetpos,x1,y1
settimer, rectangle, on
}
else {
settimer, rectangle, off
xst:= x1 < x2 ? x1, x2
yst:= y1 < y2 ? y1, y2
gdiplus_capturescreenrectangle(bitmap,xst,yst,abs(x2-x1),abs(y2-y1))
dllcall("openclipboard","uint", win) ;THIS IS THE PROBLEM LINE
tooltip, %errorlevel%,0,0
DllCall("setClipboardData","Uint", 2, "Str",bitmap) ;THIS IS THE PROBLEM LINE
msgbox, %errorlevel%
}
DllCall("RedrawWindow", "Uint", win, "Uint", 0, "Uint", 0, "Uint", 0x81)
return
rectangle:
mousegetpos,x2,y2,win
DllCall("RedrawWindow", "Uint", win, "Uint", 0, "Uint", 0, "Uint", 0x81)
drawrect(x1,y1,x2,y2)
return
escape::
exitapp
return
drawrect(x1,y1,x2,y2,color=0x0000ff)
{
guiID := WinExist()
hdc := DllCall("GetDC", "UInt", guiID, "UInt")
ps_Dash:=1
hPen := DllCall("CreatePen", "Int",PS_DASH, "Int", 1, "Int", color, "UInt")
objB := DllCall("SelectObject", "UInt", hdc, "UInt", brush, "UInt")
objP := DllCall("SelectObject", "UInt", hdc, "UInt", hPen, "UInt")
DllCall("Rectangle", "UInt", hdc, "Int", x1, "Int", y1, "Int", x2, "Int", y2)
}
|
|
|