使用autohotkeyV2.0版本语法的窗口截图。调用系统gdiplus.dll。
#SingleInstance Force
;#####################################################################################
; Function DeleteObject
; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
; After the object is deleted, the specified handle is no longer valid
;
; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
;
; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
DeleteObject(hObject) {
return DllCall("DeleteObject", "UPtr", hObject)
}
Gdip_CreateBitmapFromHBITMAP(hBitmap, hPalette:=0) {
; Creates a Bitmap GDI+ object from a GDI bitmap handle.
; hPalette - Handle to a GDI palette used to define the bitmap colors
; if the hBitmap is a device-dependent bitmap [DDB].
Ptr := "UPtr"
pBitmap := 0
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, hPalette, "UPtr*", &pBitmap)
return pBitmap
}
;#####################################################################################
; Function PrintWindow
; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
;
; hwnd A handle to the window that will be copied
; hdc A handle to the device context
; Flags Drawing options
;
; return If the function succeeds, it returns a nonzero value
;
; PW_CLIENTONLY = 1
PrintWindow(hwnd, hdc, Flags:=2) {
; set Flags to 2, to capture hardware accelerated windows
; this only applies on Windows 8.1 and later versions.
Ptr := "UPtr"
return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
}
SelectObject(hdc, hgdiobj) {
Ptr := "UPtr"
return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
}
;#####################################################################################
; Function CreateCompatibleDC
; Description This function creates a memory device context (DC) compatible with the specified device
;
; hdc Handle to an existing device context
;
; return returns the handle to a device context or 0 on failure
;
; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
CreateCompatibleDC(hdc:=0) {
return DllCall("CreateCompatibleDC", "UPtr", hdc)
}
;#####################################################################################
; Function GetDC
; Description This function retrieves a