AutoHotkey Community

It is currently May 26th, 2012, 7:40 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 181 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10 ... 13  Next
Author Message
 Post subject:
PostPosted: March 18th, 2009, 7:54 pm 
Offline

Joined: October 9th, 2006, 8:19 pm
Posts: 236
Location: Finland
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2009, 6:46 pm 
Offline

Joined: May 3rd, 2009, 6:37 pm
Posts: 67
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2009, 1:39 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 9:11 am 
Offline

Joined: May 10th, 2009, 9:09 am
Posts: 1
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2009, 4:56 pm 
Offline

Joined: June 3rd, 2008, 7:34 pm
Posts: 86
Location: Italy
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

_________________
All my scripts/snippets are released under the WTFPL: http://sam.zoy.org/wtfpl/COPYING


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 6th, 2009, 1:47 pm 
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]


Report this post
Top
  
Reply with quote  
PostPosted: July 6th, 2009, 2:58 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2009, 9:36 am 
does it work in Windows 7 ? I am having trouble getting it to work


Report this post
Top
  
Reply with quote  
PostPosted: August 6th, 2009, 9:36 am 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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)
}


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 12th, 2009, 6:57 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 8:45 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Code:
CaptureScreen(x1 "," y1 "," x2 "," y2, false, "myfile.bmp")


Report this post
Top
 Profile  
Reply with quote  
 Post subject: tyvm!
PostPosted: September 13th, 2009, 12:23 am 
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")


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 6:37 am 
Offline

Joined: May 23rd, 2009, 4:48 am
Posts: 361
Location: north bay, california
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 1:19 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2009, 7:51 am 
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



Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 181 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10 ... 13  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Xx7 and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group