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 

Screen Capture with Transparent Windows and Mouse Cursor
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
svi



Joined: 09 Oct 2006
Posts: 215
Location: Finland

PostPosted: Wed Mar 18, 2009 7:54 pm    Post subject: Reply with quote

It's only a function, so you have to call it.
Add this line
Code:
CaptureScreen(0, 1)
at the beginning of ScreenCapture.ahk script to test it.
It saves entire desktop as screen.bmp in the script folder.
_________________
Pekka Vartto
Back to top
View user's profile Send private message
OrlandoRd



Joined: 03 May 2009
Posts: 7

PostPosted: Sun May 03, 2009 6:46 pm    Post subject: Reply with quote

This looks sweet, but it looks too complicated.
I'd like for it to run on the tray, and by pressing a desired hotkey.. or even replacing the current [Print Screen] it would save on that specified folder in this case,the script folder, but the problem is.. why does it replace the current screen.bmp?if executed twice? why doesn't it make another screen#2.bmp file? has anybody got a code to work with this?, the codes listed on page 3,5 are not working.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Mon May 04, 2009 1:39 am    Post subject: Reply with quote

OrlandoRd wrote:
why doesn't it make another screen#2.bmp file?
That has little to do with the purpose of the script, is a do-it-yourself kind of job. Judging from your number of posts, I reckon you're new to AHK. Then, I think it's a good exercise to start to learn AHK.
Back to top
View user's profile Send private message
breakawayt



Joined: 10 May 2009
Posts: 1

PostPosted: Sun May 10, 2009 9:11 am    Post subject: Reply with quote

ABCza wrote:
Calling the following function before "CaptureScreen" the script checks if a file with the same name is present in the destination directory and in that case, renames it adding a _#x (where x is a progressive number).

Code:

ChecksFile(ByRef sFile = "")
{
   If sFile != 0
   {
      If   sFile =
         sFile := A_ScriptDir . "\AHK_Screen.bmp"
      old_sFile := sFile
      Loop
      {
         IfExist, %sFile%
         {
            sFile := old_sFile
            SplitPath, sFile, , sFilePath, sFileExt, sFileName
            sFile := sFilePath . "\" sFileName . "_#" . A_Index . "." . sFileExt
         }
         Else
            Break
      }
   }
   Return
}


Hi ABCza,

Mind showing how do you use the script (ChecksFile.ahk) exactly? Been playing around with it, cant get it to work with my simple brain.

Thanks.
Back to top
View user's profile Send private message
ABCza



Joined: 03 Jun 2008
Posts: 26
Location: Italy

PostPosted: Tue May 12, 2009 4:56 pm    Post subject: Reply with quote

breakawayt wrote:

Hi ABCza,

Mind showing how do you use the script (ChecksFile.ahk) exactly? Been playing around with it, cant get it to work with my simple brain.

Thanks.


No, as a pointed in pvt, you have to add that function in Sean's script and call it before CaptureScreen. I use a hotkey like this:

Code:

; hotkey CTRL+PRINT
^PrintScreen::
   ; aRect >> captures screen/active_win/client_area_of_active_win if 0/1/2
   aRect := 0
   ; bCursor >> captures cursor if True or not if False
   bCursor := True
   ; sFile >> sends image to clipboard if 0, to file if "" or to specified file if a name file is given
   sFile := "C:\Users\Cyrus\Desktop\AHK_Screen.jpg"
   ; nQuality >> sets the JPG (only) quality in a range between 0(min) - 100(max)
   nQuality := 95
   ; starts capture process
   SC_ChecksFile(sFile)
   SC_CaptureScreen(aRect, bCursor, sFile, nQuality)
   ; shows success and return
   TrayTip, ScreenCapture, Screenshot taken as`n%sFile%, 10, 17
   Return

_________________
ABCza
Back to top
View user's profile Send private message MSN Messenger
JL
Guest





PostPosted: Mon Jul 06, 2009 1:47 pm    Post subject: Re: Screen Capture with Transparent Windows and Mouse Cursor Reply with quote

HELP! THIS SCREENCAPTURE.ZIP UNZIPS TO A 3KB FILE! AUTOKEY.EXE DOESN'T OPEN IT TO COMPILE?

[quote="Sean"]I know that there already exist script(s) of the kind. Then, why another one?
It'll also capture the transparent windows and/or the mouse cursor, according to the options.
Please read the comments in the script for the details.

PS. It REQUIREs GdiPlus.dll.

[b]DOWNLOAD[/b] [url=http://www.autohotkey.net/~Sean/Scripts/ScreenCapture.zip]ScreenCapture.ahk[/url].[/quote]
Back to top
Joy2DWorld



Joined: 04 Dec 2006
Posts: 537
Location: Galil, Israel

PostPosted: Mon Jul 06, 2009 2:58 pm    Post subject: Re: Screen Capture with Transparent Windows and Mouse Cursor Reply with quote

JL wrote:
HELP! THIS SCREENCAPTURE.ZIP UNZIPS TO A 3KB FILE! AUTOKEY.EXE DOESN'T OPEN IT TO COMPILE?


welcome.

there is a help file with autohotkey.

even if you only understand some parts, will likely be interesting reading for you.


if you've installed autohotkey, then .ahk files should run when double clicked. (AHK is a scripting language, it does not compile).



hope helpful
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Vasu
Guest





PostPosted: Tue Jul 28, 2009 9:36 am    Post subject: Reply with quote

does it work in Windows 7 ? I am having trouble getting it to work
Back to top
gwarble



Joined: 23 May 2009
Posts: 127
Location: north bay, california

PostPosted: Thu Aug 06, 2009 9:36 am    Post subject: CaptureScreen() simple improvement Reply with quote

Hey

Thanks for a great script, i made two quick changes for added functionality:

Start by adding two more parameters to the CaptureScreen() definition like so:

Code:
CaptureScreen(aRect = 0, bCursor = False, sFile = "", nQuality = "", znW = 0, znH = 0)


and in the function, directly below this (unchanged) code:
Code:
   If   znW && znH
      hBM := Zoomer(hBM, nW, nH, znW, znH)

add this:
Code:
 Else If znW
  hBM := Zoomer(hBM, nW, nH, znW, znW/nW*nH)
 Else If znH
  hBM := Zoomer(hBM, nW, nH, znH/nH*nW, znH)



what it does
should be self explanatory, and it shouldnt break any current functionality, but it does two things;
- allows resizing by using aRect as 0/1/2/3 instead of "left, top, width, height, zoomW, zoomH" by calling as such:
Code:
CaptureScreen(2,"","test.jpg",90,640,480)

and allows porportional resizing by leaving either of the new parameters as 0 (or ignoring the last param of course) as so:
Code:
CaptureScreen(2,"","test.jpg",90,640)
or
CaptureScreen(2,"","test.jpg",90,0,480)

the first call will resize to width of 640 and proportional height depending on the original resolution, the second call vice versa

hope this helps someone
- Joel - gwarble
www.arcadefanatic.com

New CaptureScreen():
Code:
CaptureScreen(aRect = 0, bCursor = False, sFile = "", nQuality = "", znW = 0, znH = 0)
{
   If   !aRect
   {
      SysGet, nL, 76
      SysGet, nT, 77
      SysGet, nW, 78
      SysGet, nH, 79
   }
   Else If   aRect = 1
      WinGetPos, nL, nT, nW, nH, A
   Else If   aRect = 2
   {
      WinGet, hWnd, ID, A
      VarSetCapacity(rt, 16, 0)
      DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt)
      DllCall("ClientToScreen", "Uint", hWnd, "Uint", &rt)
      nL := NumGet(rt, 0, "int")
      nT := NumGet(rt, 4, "int")
      nW := NumGet(rt, 8)
      nH := NumGet(rt,12)
   }
   Else If   aRect = 3
   {
      VarSetCapacity(mi, 40, 0)
      DllCall("GetCursorPos", "int64P", pt)
      DllCall("GetMonitorInfo", "Uint", DllCall("MonitorFromPoint", "int64", pt, "Uint", 2), "Uint", NumPut(40,mi)-4)
      nL := NumGet(mi, 4, "int")
      nT := NumGet(mi, 8, "int")
      nW := NumGet(mi,12, "int") - nL
      nH := NumGet(mi,16, "int") - nT
   }
   Else
   {
      StringSplit, rt, aRect, `,, %A_Space%%A_Tab%
      nL := rt1
      nT := rt2
      nW := rt3 - rt1
      nH := rt4 - rt2
      znW := rt5
      znH := rt6
   }

   mDC := DllCall("CreateCompatibleDC", "Uint", 0)
   hBM := CreateDIBSection(mDC, nW, nH)
   oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
   hDC := DllCall("GetDC", "Uint", 0)
   DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
   DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
   DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
   DllCall("DeleteDC", "Uint", mDC)
   If   znW && znH
      hBM := Zoomer(hBM, nW, nH, znW, znH)
   Else If   znW
      hBM := Zoomer(hBM, nW, nH, znW, znW/nW*nH)
   Else If   znH
      hBM := Zoomer(hBM, nW, nH, znH/nH*nW, znH)
   If   sFile = 0
      SetClipboardData(hBM)
   Else   Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "Uint", hBM)
}
Back to top
View user's profile Send private message
someguyaskingaquestion
Guest





PostPosted: Sat Sep 12, 2009 6:57 am    Post subject: passing a var or vars to CaptureScreen Reply with quote

This is a great function - it is really awesome.

I have been passing a literal string to the function

CaptureScreen("345, 280, 610, 300", false, "myfile.bmp")

and would like to be able to pass it vars but have not been able to get it to work.
Something like:
x1 := 345
y1 := 280
x2 := 610
y2 := 300

CaptureScreen("%x1% . `, . %y1% . `, . %x2% . `, . %y2%", false, "myfile.bmp")

I have tried lots of combinations and apparently I have no clue how to concatenate a string to pass. Anyone know how to do this?
Back to top
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Sat Sep 12, 2009 8:45 am    Post subject: Reply with quote

Code:
CaptureScreen(x1 "," y1 "," x2 "," y2, false, "myfile.bmp")
Back to top
View user's profile Send private message
someguyaskingaquestion
Guest





PostPosted: Sun Sep 13, 2009 12:23 am    Post subject: tyvm! Reply with quote

Thanks Sean!
the string handling in ahk is very very counter intuitive to me but I love using ahk.

Thanks again


Sean wrote:
Code:
CaptureScreen(x1 "," y1 "," x2 "," y2, false, "myfile.bmp")
Back to top
gwarble



Joined: 23 May 2009
Posts: 127
Location: north bay, california

PostPosted: Wed Sep 16, 2009 6:37 am    Post subject: Reply with quote

i finally had a reason to try the above modification without an aRect (using the coordinates string parameter), so making this small change allows porportional resizing by leaving Width_Zoomed or Height_Zoomed blank or 0, without any external change to the function:

Code:
...
If   znW && znH
 hBM := Zoomer(hBM, nW, nH, znW, znH)
Else If   (znW)
 hBM := Zoomer(hBM, nW, nH, znW,
znW/nW*nH)
Else If   (znH)
 hBM := Zoomer(hBM, nW, nH,
znH/nH*nW, znH)
...


- gwarble

shouldnt be any side effects since without it, one omitted zoom dimension would result in the other being ignored
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Wed Sep 16, 2009 1:19 pm    Post subject: Reply with quote

Actually it was reserved for a thumbnail generation, processed in Convert() with variable names mW/mH, but wasn't added as it was not that useful.
Code:
If   mW && pBitmap
{
   If Not   mH
      DllCall("gdiplus\GdipGetImageWidth", "Uint", pBitmap, "UintP", nW)
   ,   DllCall("gdiplus\GdipGetImageHeight", "Uint", pBitmap, "UintP", nH)
   ,   mH:=Round(mW*(nW>nH ? nH/nW:1)), mW:=Round(mW*(nW>nH ? 1:nW/nH))
   DllCall("gdiplus\GdipGetImageThumbnail", "Uint", pBitmap, "int", mW, "int", mH, "UintP", pThumb, "Uint", 0, "Uint", 0), DllCall("gdiplus\GdipDisposeImage", "Uint", pBitmap), pBitmap:=pThumb
}
Back to top
View user's profile Send private message
wilhberg
Guest





PostPosted: Sun Oct 11, 2009 7:51 am    Post subject: Reply with quote

In order to create a screen capture zone by dragging the mouse, this is what I implemented after following the discussion in http://www.autohotkey.com/forum/post-302384.html#302384.

Code:

#Include ScreenCapture.ahk

hotkey, LButton, DrawRectangle, Off
hotkey, LButton, On

Done_Drawing:=false
Loop,
{   If Done_Drawing
   Break
Sleep, 250
}

CaptureScreen(aRect,False,0,100) ; Captures the selected zone and place on clipboard

ExitApp

DrawRectangle:

Done_Drawing:=false
CoordMode, Mouse ,Screen
  MouseGetPos, MX, MY
  Gui, 1:Color, C0C0C1  ; Creates a grey colored drag zone
  Gui, 1:+Lastfound
  WinSet, TransColor, C0C0C0 100
  Gui, 1:-Caption +Border
  ;Gui, 1:+Resize
  Loop
    {
      If GetKeyState("LButton", "P")
        {
          MouseGetPos, MXend, MYend
          w := abs(MX - MXend)
          h := abs(MY - MYend)
          If ( MX < MXend )
              X := MX
          Else
              X := MXend
          If ( MY < MYend )
              Y := MY
          Else
              Y := MYend
          Gui, 1:Show, x%X% y%Y% w%w% h%h%
        }       
      Else
          Break
    }
  MouseGetPos, MXend, MYend
  Gui, 1:Destroy
  aRect = %MX%, %MY%, %MXend%, %MYend%
  hotkey, LButton, Off
  Done_Drawing:=true

Return

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 7 of 8

 
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