如果你想在某些特殊的情况下,不想让别人看清楚你的屏幕内容,但是又不想关闭屏幕或者锁定屏幕,也不想最小化所有桌面,那么可以考虑下面的AHK代码,它会抓取当前桌面,然后使用马赛克特效处理,然后用处理后的图片遮盖整个屏幕。该脚本可以支持多个显示器。
#include gdip.ahk
HBitmapFromScreen(X, Y, W, H) {
HDC := DllCall("GetDC", "Ptr", 0, "UPtr")
HBM := DllCall("CreateCompatibleBitmap", "Ptr", HDC, "Int", W, "Int", H, "UPtr")
PDC := DllCall("CreateCompatibleDC", "Ptr", HDC, "UPtr")
DllCall("SelectObject", "Ptr", PDC, "Ptr", HBM)
DllCall("BitBlt", "Ptr", PDC, "Int", 0, "Int", 0, "Int", W, "Int", H
, "Ptr", HDC, "Int", X, "Int", Y, "UInt", 0x00CC0020)
DllCall("DeleteDC", "Ptr", PDC)
DllCall("ReleaseDC", "Ptr", 0, "Ptr", HDC)
Return HBM
}
#!b::
SysGet, xPrimary, 76
SysGet, yPrimary, 77
SysGet, wScreen, 78
SysGet, hScreen, 79
pToken := Gdip_Startup()
mskSize = 20
hBitmap := HBitmapFromScreen(xPrimary, yPrimary, wScreen, hScreen)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
pBitmapOut := Gdip_CreateBitmap(wScreen, hScreen)
Gdip_PixelateBitmap(pBitmap, pBitmapOut, mskSize)
Gui, Msk:New, +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui, Msk:Show, x0 y0 w%wScreen% h%hScreen%, 马赛克
hWnd := WinExist()
hdc := GetDC(hWnd)
graphics := Gdip_GraphicsFromHDC(hdc)
Gdip_DrawImage(graphics, pBitmapOut, 0, 0, wScreen, hScreen)
return
#IfWinActive, 马赛克 ahk_class AutoHotkeyGUI
WheelUp::
mskSize := (mskSize - 5 < 5) ? 5 : mskSize - 5
Gdip_PixelateBitmap(pBitmap, pBitmapOut, mskSize)
Gdip_DrawImage(graphics, pBitmapOut, 0, 0, wScreen, hScreen)
return
WheelDown::
mskSize := mskSize + 5 > 50 ? 50 : mskSize + 5
Gdip_PixelateBitmap(pBitmap, pBitmapOut, mskSize)
Gdip_DrawImage(graphics, pBitmapOut, 0, 0, wScreen, hScreen)
return
#If
MskGuiEscape:
MskGuiClose:
MskGuiCancel:
Gdip_DeleteGraphics(graphics)
Gdip_DisposeImage(pBitmapOut)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
DeleteObject(hBitmap)
Gui, Destroy
return