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 doesshould 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.comNew 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)
}