检查指针是否位于窗口的恢复按钮上 - autohotkey

检查指针是否位于窗口的恢复按钮上 - autohotkey

我想知道一段代码,当鼠标指针位于恢复“❐”按钮上时允许该代码。

我希望按下恢复按钮并将其滑动到一侧以拆分当前窗口,就像“Win + ←/→”快捷键一样。这是我在 Preme for Windows 中看到的一项功能,我只想要该功能。

提前致谢!

答案1

尝试此 MouseGestures 脚本

#NoEnv
#SingleInstance Force


~LButton::      ; gesture hotkey
CoordMode, Mouse, Screen
MouseGetPos, mX, mY, WindowUnderMouse
WinGetPos, wX, wY, wW, wH, ahk_id %WindowUnderMouse%
If (mY > wY and mY < wY+50 and (mX > wX + (wW-150) and mX < wX+wW)) ; mouse is over one of the buttons minimize,restore or close
{
    KeyWait, %A_ThisHotkey%, T0.1   ;to identify if hotkey was pressed or held...
    If ErrorLevel{
        ;hotkey is being held down so treat it as a gesture...
        GetMouseGesture(True)
        While GetKeyState(LTrim(A_ThisHotkey,"~"), "P"){
            ToolTip % MG := GetMouseGesture()
            Sleep 150
        }
        IsFunc(MG) ? %MG%() : ""    ;example allows creation of gestures by defining functions that comprise U,D,R,L as function name,with no upper limit on the extent of the gesture,i.e UDUDUDUDL for ex.
        ToolTip
        GetMouseGesture(True)
    }Else
        Send  {%A_ThisHotkey%}  ;if ordinary press, just let the press,passthrough...
}
Return

; gesture Left
L(){
    SendInput, #{Left}
}

; gesture Right
R(){
    SendInput, #{Right}
}

GetMouseGesture(reset := false){
    Static
    mousegetpos,xpos2, ypos2
    dx:=xpos2-xpos1,dy:=ypos1-ypos2
    ,( abs(dy) >= abs(dx) ? (dy > 0 ? (track:="u") : (track:="d")) : (dx > 0 ? (track:="r") : (track:="l")) )   ;track is up or down, left or right
    ,abs(dy)<4 and abs(dx)<4 ? (track := "") : ""   ;not tracking at all if no significant change in x or y
    ,xpos1:=xpos2,ypos1:=ypos2
    ,track<>SubStr(gesture, 0, 1) ? (gesture := gesture . track) : ""   ;ignore track if not changing since previous track
    ,gesture := reset ? "" : gesture
    Return gesture
}

相关内容