Win+滚轮 控制 Windows 窗口大小 (ahk)

算是半个自制吧
参考了一些网站上提供的之前的老旧代码
但是也加了一些自己改的东西

  1. #WheelUp::#WheelDown::
  • 功能:使用 Win + 鼠标滚轮向上/向下 组合键,可以等比例地增加或减少当前活动窗口的宽度和高度。
  1. #+WheelUp::#+WheelDown::
  • 功能:使用 Win + Shift + 鼠标滚轮向上/向下 组合键,控制高度
  1. #!WheelUp::#!WheelDown::
  • 功能:使用 Win + Alt + 鼠标滚轮向上/向下 组合键,控制宽度
; 今天修复了这个版本。 增加了一些单独控制宽和长的功能
#WheelUp::
#+WheelUp::
#!WheelUp::
#WheelDown::
#+WheelDown::
#!WheelDown::
    GetKeyState, SIZ_AltState, Alt, P
    If ( NWD_Dragging or NWD_ImmediateDown )
        Return
    SetWinDelay, -1
    CoordMode, Mouse, Screen
    IfWinActive, A
    {
        WinGet, SIZ_WinID, ID
        If ( !SIZ_WinID )
            Return
        WinGetClass, SIZ_WinClass, ahk_id %SIZ_WinID%
        If ( SIZ_WinClass = "Progman" )
            Return
        GetKeyState, SIZ_CtrlState, Ctrl, P
        WinGet, SIZ_WinMinMax, MinMax, ahk_id %SIZ_WinID%
        WinGet, SIZ_WinStyle, Style, ahk_id %SIZ_WinID%
        If ( (SIZ_CtrlState = "D") or ((SIZ_WinMinMax != 1) and (SIZ_WinStyle & 0x40000)) )
        {
            WinGetPos, SIZ_WinX, SIZ_WinY, SIZ_WinW, SIZ_WinH, ahk_id %SIZ_WinID%
            If ( SIZ_WinW and SIZ_WinH )
            {
                SIZ_AspectRatio := SIZ_WinW / SIZ_WinH
                IfInString, A_ThisHotkey, WheelDown
                    SIZ_Direction = 1
                Else
                    SIZ_Direction = -1
                SIZ_Factor1=1
                SIZ_Factor2=1
                IfInString, A_ThisHotkey, +
                    SIZ_Factor1 = 0 ; shift010203
                IfInString, A_ThisHotkey, !
                    SIZ_Factor2 = 0 ; shift010203
                SIZ_WinNewW := SIZ_WinW + SIZ_Direction *100 *SIZ_Factor1 ;* SIZ_WinW 
                SIZ_WinNewH := SIZ_WinH + SIZ_Direction *100 *SIZ_Factor2 ;* SIZ_WinH 
                If ( SIZ_WinNewW > A_ScreenWidth )
                {
                    SIZ_WinNewW := A_ScreenWidth
                    SIZ_WinNewH := SIZ_WinNewW / SIZ_AspectRatio
                }
                If ( SIZ_WinNewH > A_ScreenHeight )
                {
                    SIZ_WinNewH := A_ScreenHeight
                    SIZ_WinNewW := SIZ_WinNewH * SIZ_AspectRatio
                }
                SIZ_WinNewX := SIZ_WinX ;+ (SIZ_WinW - SIZ_WinNewW) / 2
                SIZ_WinNewY := SIZ_WinY ;+ (SIZ_WinH - SIZ_WinNewH) / 2
                Transform, SIZ_WinNewX, Round, %SIZ_WinNewX%
                Transform, SIZ_WinNewY, Round, %SIZ_WinNewY%
                Transform, SIZ_WinNewW, Round, %SIZ_WinNewW%
                Transform, SIZ_WinNewH, Round, %SIZ_WinNewH%
                WinMove, ahk_id %SIZ_WinID%, , SIZ_WinNewX, SIZ_WinNewY, SIZ_WinNewW, SIZ_WinNewH
            }
        }
    }
2 Likes

楼主有没有用过altdrag?感觉还是类似alt drag的交互直观一些,左右键分别控制移动和缩放,就不用离开鼠标了

网上有个对应的ahk脚本,不过对多显示器间拖拽的兼容不是很好

altdrag我用过exe版本的 , 会影响鼠标中健点击,所以我不用了。
鼠标中健用的还是很多的,可以关闭标签页。

这是 v1 还是 v2

脚本用的是ahk v1

青小蛙 通过 小众软件官方论坛 <[email protected]>于2025年1月10日 周五11:07写道:

我这脚本就不影响中键点击,顶多与一些程序里面需要用到 Alt 加左键拖动操作时会冲突。

1 Like