1

我很接近,但我无法让我的触发器工作。我希望能够在拖动时通过右键单击将当前正在拖动(活动)的窗口捕捉到屏幕的四分之一。它应该捕捉到我的鼠标当前所在屏幕的四分之一。触发器是我觉得我缺少的东西:当我释放鼠标右键时,将活动窗口移动到相对于鼠标所在位置的尺寸。建议?

~Lbutton & ~Rbutton::

    CoordMode,Mouse,Screen  ;mouse position relative to the screen
    MouseGetPos,Xpos,Ypos   ;get mouse position coordinates
    ;WinGet, active_id, ID, A
    ;msgbox %Xpos%,%Ypos%   ;show the saved mouse coordinates 

    RIGHT_height=537
    RIGHT_width=848
    RIGHT_leftpos=1680
    RIGHT_rightpos=2523
    RIGHT_toppos=-70
    RIGHT_vp=460    

    LEFT_height=518
    LEFT_width=847
    LEFT_leftpos=-8
    LEFT_rightpos=834
    LEFT_toppos=-10
    LEFT_vp=503

    ;LEFT SCREEN
    if (Xpos < LEFT_rightpos and ypos < LEFT_vp) {  ;LEFT top left
        WinMove,Untitled - Notepad,,%LEFT_leftpos%,%LEFT_toppos%,%LEFT_width%,%LEFT_height%

    }

    if (Xpos > LEFT_rightpos and Xpos < 1680 and ypos < LEFT_vp) {  ;LEFT top right
        MsgBox LEFT top right
    }

    if (Xpos < LEFT_rightpos and Xpos < 1680 and ypos > LEFT_vp) {  ;LEFT top right
    msgbox LEFT Bottom Left
    }

    if (Xpos > LEFT_rightpos and Xpos < 1680 and ypos > LEFT_vp) {  ;LEFT top right
    msgbox LEFT Bottom Right
    }

    ;RIGHT SCREEN
    if (Xpos < RIGHT_rightpos and Xpos >= 1680 and ypos < RIGHT_vp) {   ;RIGHT top left
    msgbox RIGHT Top Left
    }

    if (Xpos > RIGHT_rightpos and Xpos >= 1680 and ypos < RIGHT_vp) {   ;RIGHT top right
    msgbox RIGHT Top Right
    }

    if (Xpos < RIGHT_rightpos and Xpos >= 1680 and ypos > RIGHT_vp) {   ;RIGHT top right
    msgbox RIGHT Bottom Left
    }

    if (Xpos > RIGHT_rightpos and Xpos >= 1680 and ypos > RIGHT_vp) {   ;RIGHT top right
    msgbox RIGHT Bottom Right
    }


return
4

1 回答 1

0

像这样的东西也许

#SingleInstance force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
CoordMode, Mouse, Screen
hx := A_ScreenWidth/2, hy := A_ScreenHeight/2
return

#if GetKeyState("LButton", "P")
RButton up::
Send {LButton up}
WinGet, aWin, ID, A

MouseGetPos, oX, oY, oWin, oControl
if (oX<hx) and (oY<hy)
    WinMove, AHk_id %aWin%,, 0,0, %hx%, %hy%
else if (oX>hx) and (oY>hy)
    WinMove, AHk_id %aWin%,, %hx%,%hy%, %hx%, %hy%
else if (oX>hx) and (oY<hy)
    WinMove, AHk_id %aWin%,, %hx%,0, %hx%, %hy%
else if (oX<hx) and (oY>hy)
    WinMove, AHk_id %aWin%,, 0,%hy%, %hx%, %hy%
return

可能对您有用,但仅适用于单屏设置

于 2013-09-18T12:52:16.963 回答