关机对话框【屏幕变暗】.ahk
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=81268 ; 屏幕变暗有效,但是弹不出关机对话框【或者说关机对话框没置顶】 #NoEnv #SingleInstance, Force F1::ShutdownDialog("Restart") ShutdownDialog(ChooseString:="") { Local hBM := FsGrayscale(X,Y,,,W,H) hFG := DllCall("CreateBitmap", "Int",1, "Int",1, "Int",1, "Int",32, "PtrP",0x79000000, "Ptr") Gui, New, +AlwaysOnTop +ToolWindow -Caption +E0x8000000 hwndhGui +LastFound Gui, Margin, 0, 0 Gui, Add, Picture,, HBITMAP:%hBM% Gui, Add, Picture,xp yp wp hp BackgroundTrans, HBITMAP:%hFG% Gui, Show, x%X% y%Y% w%W% h%H% Hide DllCall("AnimateWindow", "Ptr", hGui, "Int", 500, "Int", 0xA0000) ; ComObjCreate("Shell.Application").ShutdownWindows() ; WinWait, Shut Down Windows ; Control, ChooseString, %ChooseString%, ComboBox1 ; WinSet, AlwaysOnTop, 1 ; WinWaitClose Gui, %hGui%:Destroy } ; 以下函数将整个屏幕捕获为灰度gdi位图。 FsGrayscale(ByRef X1:=0, ByRef Y1:=0, ByRef X2:=0, ByRef Y2:=0, ByRef W:=0, ByRef H:=0) { Local ; Fullscreen grayscale capture. Original: ToGrayscale() @ tiny.cc/tograyscale VarSetCapacity(WININFO,62), NumPut(62,WININFO,"Int"), PW:=&WININFO DllCall("GetWindowInfo", "Ptr",hWnd:=DllCall("GetDesktopWindow", "Ptr"), "Ptr",&WININFO) Loop, Parse, % "X1.Y1.X2.Y2.W.H",. %A_LoopField% := (A_Index<5 ? NumGet(PW+0,A_Index*4,"Int") : A_Index=5 ? X2-X1 : Y2-Y1) tBM := DllCall( "CopyImage", "Ptr" , DllCall( "CreateBitmap", "Int",1, "Int",1, "Int",0x1, "Int",8, "Ptr",0, "Ptr") , "Int",0, "Int",W, "Int",H, "Int",0x2008, "Ptr") tDC := DllCall("CreateCompatibleDC", "Ptr",0, "Ptr") DllCall("DeleteObject", "Ptr",DllCall("SelectObject", "Ptr",tDC, "Ptr",tBM, "Ptr")) Loop % (255, n:=0x000000, VarSetCapacity(RGBQUAD256,256*4,0)) Numput(n+=0x010101, RGBQUAD256, A_Index*4, "Int") DllCall("SetDIBColorTable", "Ptr",tDC, "Int",0, "Int",256, "Ptr",&RGBQUAD256) sDC := DllCall("GetDC", "Ptr",hWnd, "Ptr") DllCall("BitBlt", "Ptr",tDC, "Int",0, "Int",0, "Int",W, "Int",H , "Ptr",sDC, "Int",X1, "Int",Y1, "Int",0x00CC0020) Return (tBM, DllCall("ReleaseDC", "Ptr",hWnd, "Ptr",sDC), DllCall("DeleteDC", "Ptr",tDC)) }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)