 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Murp|e
Joined: 12 Jan 2007 Posts: 531 Location: Norway
|
Posted: Sat Feb 17, 2007 11:39 am Post subject: |
|
|
| Philho, there's a lot to do on this little project, but I will definitely try out these two solutions -thanks again! |
|
| Back to top |
|
 |
Cyclotron2k Guest
|
Posted: Wed Apr 11, 2007 5:30 pm Post subject: Save as BMP? |
|
|
| Could someone please let me know how I might modify this script to save straight to BMP instead of converting to PNG? |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Sat Aug 11, 2007 3:36 am Post subject: |
|
|
I spotted a small error in the script (I assume the script in the first post is the last version?)
| Code: | WinGet, hw_frame, id, "Program Manager" ; Desktop ?
hdc_frame := DllCall( "GetDC", "uint", hw_frame ) |
Because the quote marks (") are interpreted literally for commands, hw_frame is always set to zero (0). It just happens to work because: | MSDN wrote: | | If this value is NULL, GetDC retrieves the DC for the entire screen. | So you may as well do: | Code: | | hdc_frame := DllCall( "GetDC", "uint", 0 ) |
|
|
| Back to top |
|
 |
chrpen
Joined: 06 Nov 2007 Posts: 1
|
Posted: Tue Nov 06, 2007 7:58 am Post subject: window capture |
|
|
Hi,
your script is very useful, i'm new to autohotkey, and i want to specifically capture a window, not the wholescreen.
thanks |
|
| Back to top |
|
 |
you will never guess Guest
|
Posted: Sat Dec 01, 2007 4:24 pm Post subject: |
|
|
| could you make it so the GDIPlusHelper file is included into the main file? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Sat Dec 01, 2007 6:04 pm Post subject: |
|
|
no, thats impossible  _________________
 |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Tue Dec 11, 2007 2:11 am Post subject: |
|
|
I would love to see a function created using the code/concepts in this script that takes a screen shot of x size (or fullscreen), so that this can be used in scripts in a more generic fashion.
Something like:
GDIplus_Capture(pFile,pW="",pH="")
I'm trying to figure out all the DllCalls right now and if I can get it working, I'll create a function like this. Just wondering if anyone might have something similar, or be able to easily create it.
Thanks for this very useful code holomind! _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 561 Location: Galil, Israel
|
Posted: Tue Dec 11, 2007 12:36 pm Post subject: |
|
|
think there are a few.
one nice one is SEAN's script ... pretty much complete solution... [search and you'll find it] _________________ Joyce Jamce |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Tue Dec 11, 2007 3:28 pm Post subject: |
|
|
You're right, I didn't notice this before. Now it's linked to this topic in case someone else makes the same mistake  _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
Esteefiu
Joined: 29 Dec 2007 Posts: 1
|
Posted: Fri Jan 04, 2008 11:31 pm Post subject: |
|
|
hi,
Using this script to save numerous screenshots, i encountred the following problem:
After about 74 screenshots i get this mesage : "Error in GdipSaveImageToFile (2: Invalid Parameter) 0" .
After that i can't take screenshot anymore without killing and reloading the script... it's very boring and despite of my invetigations, i can't resolve that problem by myself, in code. Buffer is too small? Is it possible to enlarge it?... If some of you have an idea.. Thanks a lot! |
|
| Back to top |
|
 |
DeathByNukes
Joined: 25 Mar 2007 Posts: 43 Location: Earth-Moon L2
|
Posted: Fri Jan 04, 2008 11:58 pm Post subject: |
|
|
I've been trying to use PrintWindow or WM_PRINT to capture a specific window like in LiveWindows but I can't seem to get it right.
| Code: | #Include %A_ScriptDir%\Common\GDIPlusHelper.ahk
WinWait, AutoHotkey Help
ShotWindow := WinExist()
WinGetPos,,, ShotWindowW, ShotWindowH, ahk_id %ShotWindow%
hdc_frame := DllCall( "GetDC", "uint", ShotWindow )
hdc_buffer := DllCall( "gdi32.dll\CreateCompatibleDC", "uint", hdc_frame )
hbm_buffer := DllCall( "gdi32.dll\CreateCompatibleBitmap", "uint", hdc_frame, "int", ShotWindowW, "int", ShotWindowH )
DllCall( "gdi32.dll\SelectObject", "uint", hdc_buffer, "uint", hbm_buffer )
; Both PrintWindow and WM_PRINT have the same result.
DllCall( "PrintWindow", UInt, ShotWindow, UInt, hdc_buffer, UInt, 0 )
;SendMessage, 0x317, hdc_buffer, 0,, ahk_id %ShotWindow% ; WM_PRINT
/* WM_PRINT flags
PRF_CHECKVISIBLE 0x00000001
PRF_NONCLIENT 0x00000002
PRF_CLIENT 0x00000004
PRF_ERASEBKGND 0x00000008
PRF_CHILDREN 0x00000010
PRF_OWNED 0x00000020
*/
; Nothing changes if I use PRF_NONCLIENT or PRF_CLIENT.
If (GDIplus_Start() != 0)
Goto GDIplusError
; Copy BMP from DC
DllCall( "gdi32.dll\BitBlt"
, "uint", hdc_buffer, "int", 0, "int", 0, "int", ShotWindowW, "int", ShotWindowH
, "uint", hdc_frame, "int", 0, "int", 0, "uint", 0x00CC0020 )
DllCall( "GDIplus\GdipCreateBitmapFromHBITMAP", uint, hbm_buffer, uint, 0, uintp, bitmap )
; Save to PNG
If (GDIplus_GetEncoderCLSID(pngEncoder, #GDIplus_mimeType_png) != 0)
Goto GDIplusError
noParams = NONE
If ( GDIplus_SaveImage(bitmap, "shot_" . A_Now . A_MSec . ".png", pngEncoder, noParams) != 0 )
Goto GDIplusError
Gosub GDIplusStop
exitapp ; ----------------------------
GDIplusError:
GDIplusStop:
If (#GDIplus_lastError != "")
MsgBox 16, GDIplus Test, Error in %#GDIplus_lastError%
GDIplus_Stop()
Return
Cleanup:
DllCall( "gdi32.dll\DeleteObject", "uint", hbm_buffer )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_frame )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_buffer )
GameCleanup()
ExitApp |
I get this output:
 - It starts at the client area, which was not specified in the options.
- It captures screen outside of the window and the window covering it.
I've checked the MSDN documentation on each function but found nothing to suggest this behavior.
It must be some stupid mistake on my part but I'm rather lost in all this.  |
|
| Back to top |
|
 |
DeathByNukes
Joined: 25 Mar 2007 Posts: 43 Location: Earth-Moon L2
|
Posted: Sat Feb 09, 2008 3:29 pm Post subject: |
|
|
Disregard that, I figured it out. I had to delete the BitBlt line.
Thanks for the help though.  |
|
| Back to top |
|
 |
RandomRange
Joined: 11 Jul 2008 Posts: 1
|
Posted: Fri Jul 11, 2008 1:01 pm Post subject: |
|
|
Hi all!
I modified this to just take the shot from the window that is under mouse cursor when you press mouse middle key. I use this while playing online poker to take screenshots of game situations for later analysing.
I had to change the raster operation code of BitBlt call to 0x40CC0020 to capture also the player stats from PokerAce HUD that I'm using.
Thanks for holomind for the original code, this has been really valuable for me!
| Code: | #Include GDIPlusHelper.ahk
; see: http://www.autohotkey.com/forum/viewtopic.php?t=12012 for orignal
main:
FileCreateDir, screens
counter_f:=0
return
MButton::
SaveImage_Full:
MouseGetPos, ,, winID
WinGetPos, winX, winY, winWidth, winHeight, ahk_id %winID%
hdc_frame := DllCall( "GetDC", "uint", NULL )
hdc_buffer := DllCall( "gdi32.dll\CreateCompatibleDC" , "uint", hdc_frame )
hbm_buffer := DllCall( "gdi32.dll\CreateCompatibleBitmap" , "uint", hdc_frame, "int", winWidth, "int", winHeight )
r := DllCall( "gdi32.dll\SelectObject" , "uint", hdc_buffer, "uint", hbm_buffer )
counter_f := counter_f +1
FormatTime, myTime, , yyyyMMdd_hhmmss
fileNameDestP = screens\S_%myTime%_%counter_f%.png
If (GDIplus_Start() != 0)
Goto GDIplusError
; Copy BMP from DC
DllCall( "gdi32.dll\BitBlt"
, "uint", hdc_buffer, "int", 0, "int", 0, "int", winWidth, "int", winHeight
, "uint", hdc_frame, "int", winX, "int", winY, "uint", 0x40CC0020 )
DllCall( "GDIplus\GdipCreateBitmapFromHBITMAP", uint, hbm_buffer, uint, 0, uintp, bitmap )
; Save to PNG
If (GDIplus_GetEncoderCLSID(pngEncoder, #GDIplus_mimeType_png) != 0)
Goto GDIplusError
noParams = NONE
If (GDIplus_SaveImage(bitmap, fileNameDestP, pngEncoder, noParams) != 0)
Goto GDIplusError
DllCall( "gdi32.dll\DeleteObject", "uint", hbm_buffer )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_frame )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_buffer )
Return
GDIplusError:
If (#GDIplus_lastError != "")
MsgBox 16, GDIplus Test, Error in %#GDIplus_lastError%
GDIplus_Stop()
Return |
|
|
| Back to top |
|
 |
jfty.009260
Joined: 18 Mar 2008 Posts: 8
|
Posted: Thu Jul 31, 2008 1:51 pm Post subject: |
|
|
Excellent script...I can't believe that what I've been looking for would be contained in a simple AHK script! It can handle even shots from DirectX programs, which is a very big plus. The only thing that should be added would probably be the ability to capture individual windows (Alt+PrntScr) as well as an option to show the pointer or not.
Overall, an amazing job. |
|
| Back to top |
|
 |
Drugwash
Joined: 07 Sep 2008 Posts: 921 Location: Ploiesti, RO
|
Posted: Wed Feb 04, 2009 2:24 pm Post subject: |
|
|
Thank you, holomind!
This script proved to work fine on my Win98SE system. It misses however a small detail: cannot handle multiple monitors. It always captures the primary monitor, regardless of screen configuration, active window, etc.
It would be wonderful if it would capture the whole desktop (in my case dual-view 1024x768 + 1024x768 = 2048x768) or allow monitor selection.
Active window selection would also be a plus, as requested previously.
Sean's script mentioned somewhere in this thread does capture the whole 2048x768 desktop area but it only saves a black .bmp.  _________________ AHK tools by Drugwash |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|