单击鼠标右键将捕捉窗口拖动到屏幕四分之一处

时间:2013-09-17 22:32:58

标签: autohotkey

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

~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

1 个答案:

答案 0 :(得分: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

可能适用于您,但仅限于一个屏幕设置