# \[Windows\]在主副屏间快速移动鼠标和窗口

**URL:** <https://meta.appinn.net/t/topic/24949>\
**Category:** 发现频道\
**Created:** [2021 年7 月 30 日 06:32 UTC](https://meta.appinn.net/t/topic/24949 "2021-07-30T06:32:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anc](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/anc/32/17680_2.png) [@Anc](https://meta.appinn.net/u/Anc)\
**Post date:** [2021 年7 月 30 日 06:32 UTC](https://meta.appinn.net/t/topic/24949/1 "2021-07-30T06:32:47Z")

</div>

## 安装

安装 [ahk](https://www.autohotkey.com/) 新建一个名为 `mouse_right.ahk` 的文件；如果主屏幕在左边的，文件名改为`mouse_left.ahk` 。 _(其实只有主屏幕是在左边副屏是在右边的，这个文件名才是 **必须的** )_

~~由于蓝奏云需要手机号注册，因此暂时不提供`exe`下载链接。~~

下载链接：[https://transfer.sh/1dCdWse/mouse.exe](https://transfer.sh/1dCdWse/mouse.exe) _（如果主屏幕是在左边，将其命名为`mouse_left.exe`）_

快捷键是`ALT+Q`和`ALT+W`，有鼠标侧键的可以修改为侧键。

移动鼠标是经过屏幕分辨率计算的，移动窗口是利用的WIN\_10快捷键，因此如果系统是WIN\_7或者WIN\_XP可以解开下面的`if (A_OSVersion in WIN_7,WIN_XP){`注释试试 _（未经过测试）_

```auto
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

CoordMode, Mouse,Screen
SysGet, Mon1, Monitor, 1
SysGet, Mon2, Monitor, 2

isLeft := StrSplit(A_ScriptName, ".")[1] == "mouse_left" ? 1 : 0

!q::
WinMove, X, Y
;if (A_OSVersion in WIN_7,WIN_XP){
; if (isLeft = 0){
; if (xpos < 0){
; WinMove, Mon2Left, Mon2Top ;TODO
; }
; else{
; WinMove, 0, 0
; }
; }
; else{
; if (xpos > Mon1Right){
; WinMove, 0, 0
; }
; else{
; WinMove, Mon2Left, Mon2Top
; }
; }
;} else{
  Send #+{Left}
  Send !w
;}
return

!w::
  MouseGetPos, xpos, ypos 
  if (isLeft = 0){
    if (xpos < 0){
      MouseMove Mon1Right/2, Mon1Bottom/2
    }
    else{
      MouseMove Mon2Left/2, (Mon2Bottom+Mon2Top)/2
    }
  }
  else{
    if (xpos > Mon1Right){
      MouseMove Mon1Right/2, Mon1Bottom/2
    }
    else{
      MouseMove (Mon2Right+Mon1Right)/2, (Mon2Bottom+Mon2Top)/2
    }
  }
return

```
