AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

More dll help--setclipboarddata

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
philz



Joined: 05 Jun 2007
Posts: 78
Location: USA

PostPosted: Wed Apr 23, 2008 2:49 pm    Post subject: More dll help--setclipboarddata Reply with quote

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)
}

Back to top
View user's profile Send private message Send e-mail
Superfraggle



Joined: 02 Nov 2004
Posts: 774
Location: London, UK

PostPosted: Wed Apr 23, 2008 3:33 pm    Post subject: Reply with quote

This post http://www.autohotkey.com/forum/viewtopic.php?t=18146&highlight=screen+capture demonstates how to capture a rectangle and place it either in the clipboard or save it.

I am using a highly modified version myself.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group