【问题标题】:Click right mouse button to snap window being dragged to screen quarter单击鼠标右键捕捉被拖动到屏幕四分之一的窗口
【发布时间】:2013-09-22 13:09:56
【问题描述】:

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

~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

【问题讨论】:

  • 我没有完全理解你的问题,你能详细说明一下吗?它目前表现如何,您希望它表现如何?
  • 您之前好像问过这个问题,并且有答案。 Link here.

标签: autohotkey


【解决方案1】:

可能是这样的

#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

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

【讨论】:

  • MCL,你是对的,它在另一个帖子上得到了回答。抱歉重复发帖;我花了一段时间才弄清楚这个网站。
猜你喜欢
  • 2018-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多