Code: Select all
F3:: ;Hold F3 to make a selection, then release
{
CoordMode,mouse
max_size:=200
MouseGetPos, x1, y1
SoundBeep, 1500, 20
KeyWait, %A_ThisHotkey%
SoundBeep, 1000, 20
MouseGetPos, x2, y2
width := x2 - x1, height := y2 - y1
If (width < 4 && height < 4)
Return
pToken := Gdip_Startup(), snap := Gdip_BitmapFromScreen(x1 "|" y1 "|" width "|" height)
Gdip_SetBitmapToClipboard(Gdip_ResizeBitmap(snap, max_size))
Gdip_DisposeImage(snap), Gdip_Shutdown(pToken)
}
Return
Gdip_ResizeBitmap(pBitmap, max_size) {
Gdip_GetImageDimensions(pBitmap, origW, origH)
if (origw>origh)
{
newW:=max_size
newH:=origH*(max_size/origW)
}
if (origw<origh)
{
newW:=origw*(max_size/origH)
newH:=max_size
}
pBitmap2 := Gdip_CreateBitmap(newW, newH)
G2 := Gdip_GraphicsFromImage(pBitmap2), Gdip_SetSmoothingMode(G2, 4), Gdip_SetInterpolationMode(G2, 7)
Gdip_DrawImage(G2, pBitmap, 0, 0, NewW, NewH)
Gdip_DeleteGraphics(G2)
return pBitmap2
}