; 仅快速实现功能,不完善很正常,30分钟写代码,30小时才可能完善细节。 ; 已知bug:对于父子窗口,当主窗口隐藏,子窗口从微缩中返回正常大小后,窗口会被隐藏,无法再次打开,需要重启窗口对应软件 ; by 空 #NoEnv SetBatchLines -1 CoordMode, Mouse, Screen SysGet, SM_CXSIZEFRAME, 32 SysGet, SM_CYSIZEFRAME, 33 SM_CXSIZEFRAME:=SM_CXSIZEFRAME="" ? 0 : SM_CXSIZEFRAME SM_CYSIZEFRAME:=SM_CYSIZEFRAME="" ? 0 : SM_CYSIZEFRAME GuiLable:=0, Windows:={} OnExit, ExitShrink SetTimer, Repaint, 100 ; 定时刷新微缩显示 ; 中键双击时触发 ~MButton:: t:=-oldt+(oldt:=A_TickCount) if (t<100 || t>400) Return else oldt:=0 MouseGetPos, x, y, Win if (Windows.HasKey("h" Win)) RestoreShrink("h" Win) else { zoom:=0.2 ; 缩放大小 WinSet, ExStyle, +0x00000080, ahk_id %Win% WinSet, Transparent, 0, ahk_id %Win% WinGetPos, , , sw, sh, ahk_id %Win% ratio:=a_ sw/sh, dw:=sw*zoom, dh:=dw/ratio, GuiLable+=1 Gui, %GuiLable%:+ToolWindow -Caption +AlwaysOnTop +Border +HwndShrinkID -DPIScale Gui, %GuiLable%:Show, x%x% y%y% w%dw% h%dh%, 微缩窗口 dest_hdc := DllCall("GetDC", "UInt", ShrinkID) source_hdc := DllCall("GetWindowDC", "UInt", Win) DllCall("gdi32\SetStretchBltMode", "UPtr", dest_hdc, "Int", 4) Windows["h" ShrinkID, "GuiLable"] := GuiLable , Windows["h" ShrinkID, "hwnd"] := Win , Windows["h" ShrinkID, "source_hdc"] := source_hdc , Windows["h" ShrinkID, "dest_hdc"] := dest_hdc , Windows["h" ShrinkID, "sw"] := sw , Windows["h" ShrinkID, "sh"] := sh , Windows["h" ShrinkID, "dw"] := dw , Windows["h" ShrinkID, "dh"] := dh } return Repaint: for k, v in Windows DllCall("gdi32.dll\StretchBlt", "UInt", v.dest_hdc, "Int", 0, "Int", 0, "Int", v.dw, "Int", v.dh, "UInt", v.source_hdc, "UInt", SM_CXSIZEFRAME, "UInt", 0, "Int", v.sw-2*SM_CXSIZEFRAME, "Int", v.sh-SM_CYSIZEFRAME, "UInt", 0xCC0020) return ExitShrink: SetTimer, Repaint, Off for k, v in Windows.Clone() RestoreShrink(k) ExitApp return RestoreShrink(Win) { global Windows o:=Windows[Win], GuiLable:=o.GuiLable WinSet, ExStyle, -0x00000080, % "ahk_id " o.hwnd WinSet, Transparent, 255, % "ahk_id " o.hwnd WinSet, Redraw, , % "ahk_id " o.hwnd WinActivate, % "ahk_id " o.hwnd DllCall("gdi32.dll\DeleteDC", "UInt", o.dest_hdc) DllCall("gdi32.dll\DeleteDC", "UInt", o.source_hdc) Gui, %GuiLable%:Destroy Windows.Delete(Win) } WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { static init := OnMessage(0x0201, "WM_LButtonDOWN") PostMessage, 0xA1, 2,,, A }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)