Ahk v1 Using CaptureScreen by Linear Spoon

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Ahk v1 Using CaptureScreen by Linear Spoon

17 Jan 2023, 21:47

I'm having trouble using this code by Linear Spoon to capture an active Window on my second monitor. I believe that the following should capture the active window to a file:

Code: Select all

CaptureScreen(1,0,"D:\test.png")
The problem is if the target window is full-sized and on my second monitor the bottom of the image is truncated - as if the taskbar were present when it is not. Does anyone know how to get a screen shot of a maximized window on a second monitor or is there a limitation? Thanks
User avatar
andymbody
Posts: 957
Joined: 02 Jul 2017, 23:47

Re: Ahk v1 Using CaptureScreen by Linear Spoon

17 Jan 2023, 22:31

I'm not familiar with the CaptureScreen() function, and I know nothing about multiple displays, but... Just a thought... could it be a ppi (resolution) issue?
Last edited by andymbody on 17 Jan 2023, 22:33, edited 1 time in total.
User avatar
flyingDman
Posts: 2840
Joined: 29 Sep 2013, 19:01

Re: Ahk v1 Using CaptureScreen by Linear Spoon

17 Jan 2023, 22:32

If that window is maximized, you can try:

Code: Select all

CaptureScreen("-1920, 0, 0, 1080", 0, A_ScriptDir "\test987.png")

This works on my 1920x1080 second monitor to the left on my 1st monitor.
You can also use WinGetPos and adjust for dpi setting and borders.
14.3 & 1.3.7
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Ahk v1 Using CaptureScreen by Linear Spoon

17 Jan 2023, 23:05

Thanks for the replies, I'm not using any scaling on this machine. The code:

Code: Select all

CaptureScreen("-1920, 0, 0, 1080", 0, A_ScriptDir "\test987.png")
Gave me a black screenshot. I tried:

Code: Select all

CaptureScreen("1920, 0, 0, 1080", 0, A_ScriptDir "\test987.png")
without the " - " but failed to save the file. I've tried using WinGetPos and adjusting for W10's borders but CaptureScreen always ends up cropping the bottom off the image unless I take screenshot of the entire desktop which I don't want.
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: Ahk v1 Using CaptureScreen by Linear Spoon

18 Jan 2023, 12:25

well, not using CaputreScreen but this worked for me

Code: Select all

WinGetActiveStats, OutTitle, OutW, OutH, OutX, OutY
fileName := A_Desktop "\test.png"
if !pToken:= Gdip_Startup()
{
	MsgBox, 131088, , Gdip not loaded
	ExitApp
}
pBitmap := Gdip_BitmapFromScreen(OutX "|" OutY "|" OutW "|" OutH)
Gdip_SaveBitmapToFile(pBitmap, fileName)
Gdip_Shutdown(pToken)
Run, % fileName
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], MSN [Bot], scriptor2016 and 183 guests