Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Screen Capture with Transparent Windows and Mouse Cursor


  • Please log in to reply
245 replies to this topic
tic
  • Members
  • 1934 posts
  • Last active: May 30 2018 08:13 PM
  • Joined: 22 Apr 2007

Is it possible with that script to have a snapshoot and rescale/downsize it to a variable/preset ratio of eg 33/100% before saving? That to create thumbnail images from screenshoots 'on-the-fly'.

Feedback much appreciated.
8)


I would use the gdi+ library for this

Icarus
  • Members
  • 851 posts
  • Last active: Jan 02 2012 11:17 AM
  • Joined: 24 Nov 2005

Is it possible with that script to have a snapshoot and rescale/downsize it to a variable/preset ratio of eg 33/100% before saving? That to create thumbnail images from screenshoots 'on-the-fly'.

Feedback much appreciated.
8)


I am assuming you want something simple and easy enough to implement - so you should download the ScreenCapture.ahk at the top of this thread and read the comments inside.
It has a simple function that gets coordinates and a zoom factor, and it captures and saves PNGs or BMPs or JPGs (I think).
Really easy and useful - I use it to do timed scaled down captures of the screen.
Sector-Seven - Freeware tools built with AutoHotkey

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Is it possible with that script to have a snapshoot and rescale/downsize it to a variable/preset ratio of eg 33/100% before saving? That to create thumbnail images from screenshoots 'on-the-fly'.

There are a variety of ways to do it. GDI+ even has a thumbnail specific function, GdipGetImageThumbnail. Anyway, ScreenCapture.ahk already has this functionality:

It has a simple function that gets coordinates and a zoom factor, and it captures and saves PNGs or BMPs or JPGs (I think). Really easy and useful - I use it to do timed scaled down captures of the screen.

For example,
CaptureScreen("100, 100, 500, 500, [color=red]128[/color], [color=red]128[/color]")
This will capture the region (100,100) ~ (500,500) and save to 128x128 image.

BoBo²
  • Guests
  • Last active:
  • Joined: --
Thx tic/icarus/Sean. 8)
I've oviously missed that specific information within the scripts documentation. :oops:

ScottMattes
  • Members
  • 195 posts
  • Last active: Feb 16 2015 01:43 AM
  • Joined: 21 May 2007
Do a search, someone just asked/answered this (I think that the answer was yes and had to do with GDI)

enmane
  • Guests
  • Last active:
  • Joined: --
I'm currently trying to use this function as a call from another program but it isn't working correctly. I keep getting a screen.bmp file when I desire a JPG. Here's how I'm currently implementing it...

AutoHotkey.ahk has some commands in a loop that call
CaptureScreen(1, False, A_ScriptDir . "\screen.jpg", nQuality:=85)

and I'm using the default settings for CaptureScreen.ahk

1) there are comments commands before
; CaptureScreen() and ;Return
2) the next line is
CaptureScreen(aRect = 0, bCursor = False, sFile= "", nQuality = "") which are the defaults.

Yes, I'm new to scripting but not to programming (but it has been a while).
I've gotten most of my code to work correctly except this part. I know that gdiPlus is working as I tried out Holomind's code and it captured PNGs just fine.

Any ideas??? Sorry if it is obvious. Can I ask someone to give a detailed response?

enmane
  • Guests
  • Last active:
  • Joined: --
I'm currently trying to use this function as a call from another program but it isn't working correctly. I keep getting a screen.bmp file when I desire a JPG. Here's how I'm currently implementing it...

AutoHotkey.ahk has some commands in a loop that call
CaptureScreen(1, False, A_ScriptDir . "\screen.jpg", nQuality:=85)

and I'm using the default settings for CaptureScreen.ahk

1) there are comments commands before
; CaptureScreen() and ;Return
2) the next line is
CaptureScreen(aRect = 0, bCursor = False, sFile= "", nQuality = "") which are the defaults.

Yes, I'm new to scripting but not to programming (but it has been a while).
I've gotten most of my code to work correctly except this part. I know that gdiPlus is working as I tried out Holomind's code and it captured PNGs just fine.

Any ideas??? Sorry if it is obvious. Can I ask someone to give a detailed response?

enmane
  • Guests
  • Last active:
  • Joined: --
Ok, well - the following is working at creating a screen.jpg file

CaptureScreen(1, False, "screen.JPG", 85)

but now I need to change the names automatically and I looked at the code in Holomind's script and put the following before the call to CaptureScreen

FormatTime, myTime, , yyyyMMdd_hhmmss
fileNameDestP = screens_%myTime%_%LoopCount%.JPG
CaptureScreen(1, False, %fileNameDestP%, 85)

so that it automatically changes the filename but I get an error with the variable %fileNameDestP% when it gets passed to CaptureScreen....

Error: The following variable name contains an illegal character : "screens_20080918_114420_1.JPG"


Any ideas and TIA...

enmane
  • Guests
  • Last active:
  • Joined: --
I thought I already tried passing it by reference and not by value but it's working now just by removing % signs and passing the variable...


CaptureScreen(1, False, %fileNameDestP%, 85)

CaptureScreen(1, False, fileNameDestP, 85)

works good now

BioBrain
  • Members
  • 17 posts
  • Last active: Nov 21 2014 10:23 PM
  • Joined: 13 Feb 2008

I've been thinking, do U thing it's possible to search is image in clipboard is the same with image I want 2 search. kinda like ImageSearch but not on screen, but search in the Clipboard.

Sure it's possible. You can obtain, using GetClipboardData(), hbitmap (:DDB) or DIB. All necessary ones are ready by now. The remaining question is what procedure you're gonna use for the search, GetPixel through memory dc, where hbitmap is useful but maybe the slowest, or compare raw pixel, where DIB is handy, one by one, or may use hashes of the data.


GetClipboardData(), hbitmap (:DDB) or DIB ?

Any posted topic or tutorials about it? because I can't find it at AutoHotkey help.

Tx. :D

adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
Can someone help me adjust this to capture the entire desktop (multiple monitors) instead of just the primary monitor?

adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006

Can someone help me adjust this to capture the entire desktop (multiple monitors) instead of just the primary monitor?


I've got this fixed, atleast for dual monitors by adjusting the if !aRect in CaptureScreen() function to this:

If	!aRect
	{
		SysGet, Mon, Monitor, 1
		nL := MonLeft
		nT := MonTop
		nW := MonRight - MonLeft
		nH := MonBottom - MonTop
	
		SysGet, Mon, Monitor, 2
		nL2 := MonLeft
		nT2 := MonTop
		nW2 := MonRight - MonLeft
		nH2 := MonBottom - MonTop
			
		nL := nL + nL2
		nT := nT + nT2
		nW := nW + nW2
		if nH2 >= nH
			nH := nH2
	}


Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Can someone help me adjust this to capture the entire desktop (multiple monitors) instead of just the primary monitor?

You can use
If	!aRect
{
	SysGet, nL, 76
	SysGet, nT, 77
	SysGet, nW, 78
	SysGet, nH, 79
}


adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006

Can someone help me adjust this to capture the entire desktop (multiple monitors) instead of just the primary monitor?

You can use
If	!aRect
{
	SysGet, nL, 76
	SysGet, nT, 77
	SysGet, nW, 78
	SysGet, nH, 79
}


I see, thanks :)

adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
Irfanview offers an option to capture just the active screen. I wanted to do it with this, since it offers the option to not capture the mouse cursor.

What do you think about adding the following (or something similar) to your code, Sean?

Else If aRect = 3
	{
		MouseGetPos,mPx,mPy
		SysGet,mC,MonitorCount
		Loop % mC
			{
				SysGet, Mon, Monitor, %A_Index%
				nL := MonLeft
				nT := MonTop
				nW := MonRight - MonLeft
				nH := MonBottom - MonTop
				If ((mPx >= nL) AND (mPx <= nW)) AND ((mPy >= nT) AND (mPy <= nH))
					Break
			}
	}

Then option 3 would be to capture just the active screen, ie the monitor where your mouse is currently. Such as:

CaptureScreen(3,false,"c:\active_screen.bmp")