`

AutoHotkey:使用快捷键,在双显示器间,移动最大化的窗口

 
阅读更多

无意间看了我以前写的一篇博客:VC++: 在双显示器间,移动最大化的窗口

当时我想解决的问题是这样的:

无需通过多步鼠标操作, 使用快捷键, 直接将我想移动的窗口, 移动到我希望的显示器上(我期望的位置.)

包括移动最大化窗口(xp中,最大化窗口是需要先还原才能再移动的)

 

当时的解决办法是写了一个c++程序(命令行程序,无窗口), 负责在多显示器之间移动窗口.

然后在用AutoHotkey为这个命令行程序配一个快捷键.

 

时隔多年回头一看, 发现我已经对这个问题有了新的认识.

随着对AutoHotkey的认识的加深,

如果现在让我做这个问题, 我已经不再会写一个C++程序.

而会直接用AutoHotkey实现全部的功能.

 

方式可以详参下面这几个连接, 他们使用的都是AutoHotkey:

Keyboard shortcut for moving a window to another screen@superuser

WindowPad - window-moving tool@AutoHotkey Community

WindowPadX@github

 

第一个连接上面有下面两份代码可供参考.

 

#q::
WinGetPos, winx, winy,,, A
WinGet, mm, MinMax, A
WinRestore, A
If (winx > 1270)
{
    newx := winx-1270
    OutputDebug, Moving left from %winx% to %newx%
}
else
{
    newx := winx+1270
    OutputDebug, Moving right from %winx% to %newx%
}

WinMove, A,, newx, winy

if mm=1
    WinMaximize, A
Return

 

 

#z:: ;Move the active window to the other monitor.
WinGetPos, winx, winy,,, A
WinGet, oldWin,ID,A
WinActivate, A
WinGet, mm, MinMax, A
WinRestore, A
If winx+5 >= 0 then
    mult=1
else
    mult=-1
WinMove,A,, winx-(1680*mult), winy
if mm=1
    WinMaximize, A
Return
 

第二个连接WindowPad ,关于移动窗口, 提供了更多的功能,

有脚本,也有编译好的exe,下载下来直接运行使用,很方便,

我们想要的功能(跨显示器移动窗口)对应的快捷键是: Win+小键盘上面的回车

他的功能包括:

写道
■Move windows within the current monitor or between monitors (in multi-monitor setups).
■Customize hotkeys via WindowPad.ini with AutoHotkey-like command syntax.
■Define custom commands as labels or functions in WindowPad.ahk.
■Execute WindowPad commands specified on the command-line.
 

第三个连接WindowPadX 是第二个连接(WindowPad )的一个增强.

他们都有Source, 可以随时参考.

 

 

最后, 这个功能已经内置在Windows 7之中.

所以, win7用户有了福, 如果你是win7用户, 直接按下下面这两组快捷键吧:

写道
Win+Shift+left: Move focussed window one monitor to the left
Win+Shift+right: Move focussed window one monitor to the right
  

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics