用鼠标一次将Windows 4捕捉到一个屏幕上 [英] Snapping Windows 4 to a screen with the mouse, one at a time
问题描述
我想通过右键单击将窗口捕捉到屏幕的一角(四分之一),然后放开鼠标移动的窗口.我目前正在努力使活动窗口移动.对于左屏幕,我可以使记事本移动到左上角,但是当释放鼠标按钮时,它会恢复到以前的位置;而且我必须按名称来调用它-我希望它可以与任何活动窗口一起使用.有想法吗?
I want to snap windows to a corner (quarter) of a screen by right clicking before letting go of the window being moved by the mouse. I'm currently struggling with getting the active window to move. For the LEFT screen, top left position I can get Notepad to move, but it snaps back to its previous position when the mouse button is released; and I have to call it out by name--I want it to work with any active window. Thoughts?
〜Lbutton& 〜Rbutton ::
~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
}
返回
推荐答案
您需要添加
Send, {LButton Up}
在您的代码中.这样可以防止在完成热键操作后,按住 LButton 来接管窗口.
in your code. This prevents the LButton being held from taking over the window when the hotkey's actions are complete.
为了将WinMove
与ahk_id
一起使用,必须将其放在WinMove
命令中.见下文.
In order to use WinMove
with the ahk_id
you must put this in the WinMove
command. See below.
~LButton & ~RButton::
CoordMode,Mouse,Screen
MouseGetPos,Xpos,Ypos
WinGet, active_id, ID, A ; use active_id in WinMove
Send, {LButton Up} ; Prevents window from snapping back
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,ahk_id %active_id%,,%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
}
Return
这篇关于用鼠标一次将Windows 4捕捉到一个屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!