下面的ahk脚本提供了windows下alt dragging的能力:

; Easy Window Dragging -- KDE style (requires XP/2k/NT) -- by Jonny
; http://www.autohotkey.com
; This script makes it much easier to move or resize a window: 1) Hold down
; the ALT key and LEFT-click anywhere inside a window to drag it to a new
; location; 2) Hold down ALT and RIGHT-click-drag anywhere inside a window
; to easily resize it; 3) Press ALT twice, but before releasing it the second
; time, left-click to minimize the window under the mouse cursor, right-click
; to maximize it, or middle-click to close it.

; This script was inspired by and built on many like it
; in the forum. Thanks go out to ck, thinkstorm, Chris,
; and aurelian for a job well done.

; Change history:
; November 07, 2006: Optimized resizing code in !RButton, courtesy of bluedawn.
; February 05, 2006: Fixed double-alt (the ~Alt hotkey) to work with latest versions of AHK.

; The Double-Alt modifier is activated by pressing
; Alt twice, much like a double-click. Hold the second
; press down until you click.
;
; The shortcuts:
; Alt + Left Button : Drag to move a window.
; Alt + Right Button : Drag to resize a window.
; Double-Alt + Left Button : Minimize a window.
; Double-Alt + Right Button : Maximize/Restore a window.
; Double-Alt + Middle Button : Close a window.
;
; You can optionally release Alt after the first
; click rather than holding it down the whole time.

If (A_AhkVersion < "1.0.39.00")
{
MsgBox,20,,This script may not work properly with your version of AutoHotkey. Continue?
IfMsgBox,No
ExitApp
}

; This is the setting that runs smoothest on my
; system. Depending on your video card and cpu
; power, you may want to raise or lower this value.
SetWinDelay,2

CoordMode,Mouse
return

!LButton::
If DoubleAlt
{
MouseGetPos,,,KDE_id
; This message is mostly equivalent to WinMinimize,
; but it avoids a bug with PSPad.
PostMessage,0x112,0xf020,,,ahk_id %KDE_id%
DoubleAlt := false
return
}
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
return
; Get the initial window position.
WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
Loop
{
GetKeyState,KDE_Button,LButton,P ; Break if button has been released.
If KDE_Button = U
break
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
KDE_Y2 -= KDE_Y1
KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position.
KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
}
return

!RButton::
If DoubleAlt
{
MouseGetPos,,,KDE_id
; Toggle between maximized and restored state.
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
WinRestore,ahk_id %KDE_id%
Else
WinMaximize,ahk_id %KDE_id%
DoubleAlt := false
return
}
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
return
; Get the initial window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
; Define the window region the mouse is currently in.
; The four regions are Up and Left, Up and Right, Down and Left, Down and Right.
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
KDE_WinLeft := 1
Else
KDE_WinLeft := -1
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
KDE_WinUp := 1
Else
KDE_WinUp := -1
Loop
{
GetKeyState,KDE_Button,RButton,P ; Break if button has been released.
If KDE_Button = U
break
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
; Get the current window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
KDE_Y2 -= KDE_Y1
; Then, act according to the defined region.
WinMove,ahk_id %KDE_id%,, KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2 ; X of resized window
, KDE_WinY1 + (KDE_WinUp+1)/2*KDE_Y2 ; Y of resized window
, KDE_WinW - KDE_WinLeft *KDE_X2 ; W of resized window
, KDE_WinH - KDE_WinUp *KDE_Y2 ; H of resized window
KDE_X1 := (KDE_X2 + KDE_X1) ; Reset the initial position for the next iteration.
KDE_Y1 := (KDE_Y2 + KDE_Y1)
}
return

; "Alt + MButton" may be simpler, but I
; like an extra measure of security for
; an operation like this.
!MButton::
If DoubleAlt
{
MouseGetPos,,,KDE_id
WinClose,ahk_id %KDE_id%
DoubleAlt := false
return
}
return

; This detects "double-clicks" of the alt key.
~Alt::
DoubleAlt := A_PriorHotkey = "~Alt" AND A_TimeSincePriorHotkey < 400
Sleep 0
KeyWait Alt ; This prevents the keyboard's auto-repeat feature from interfering.
return

 
============================================
我最终修改并使用的:
 
增加了中间键resize的功能,使用LControl替代Alt键:
 

If (A_AhkVersion < "1.0.39.00")
{
MsgBox,20,,This script may not work properly with your version of AutoHotkey. Continue?
IfMsgBox,No
ExitApp
}
; This is the setting that runs smoothest on my
; system. Depending on your video card and cpu
; power, you may want to raise or lower this value.
CoordMode,Mouse
return
; MOVE WINDOW
~^LButton::
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
return
; Get the initial window position.
WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
Loop
{
GetKeyState,KDE_Button,LButton,P ; Break if button has been released.
If KDE_Button = U
break
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
KDE_Y2 -= KDE_Y1
KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position.
KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
}
return
; RESIZE WINDOW
~^RButton::
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
return
; Get the initial window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
; Define the window region the mouse is currently in.
; The four regions are Up and Left, Up and Right, Down and Left, Down and Right.
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
Else
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
Else
Loop
{
GetKeyState,KDE_Button,RButton,P ; Break if button has been released.
If KDE_Button = U
break
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
; Get the current window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
KDE_Y2 -= KDE_Y1
; Then, act according to the defined region.
WinMove,ahk_id %KDE_id%,, KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2 ; X of resized window
, KDE_WinY1 + (KDE_WinUp+1)/2*KDE_Y2 ; Y of resized window
, KDE_WinW - KDE_WinLeft *KDE_X2 ; W of resized window
, KDE_WinH - KDE_WinUp *KDE_Y2 ; H of resized window
KDE_X1 := (KDE_X2 + KDE_X1) ; Reset the initial position for the next iteration.
KDE_Y1 := (KDE_Y2 + KDE_Y1)
}
return
; NO ~ PREFIX MEANS DISABLE NATIVE EVENT (DISABLE MButton EVENT)
; MAX/MIN WINDOW
MButton::
MouseGetPos,,,KDE_id
; Toggle between maximized and restored state.
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
WinRestore,ahk_id %KDE_id%
Else
WinMaximize,ahk_id %KDE_id%
DoubleMButton := false
return
return
; CTRL + MButton TO MINIMIZE WINDOW
~^MButton::
MouseGetPos,,,KDE_id
; This message is mostly equivalent to WinMinimize,
; but it avoids a bug with PSPad.
PostMessage,0x112,0xf020,,,ahk_id %KDE_id%
return

easy dragging script的更多相关文章

  1. Git详解之四:服务器上的Git

    服务器上的 Git 到目前为止,你应该已经学会了使用 Git 来完成日常工作.然而,如果想与他人合作,还需要一个远程的 Git 仓库.尽管技术上可以从个人的仓库里推送和拉取修改内容,但我们不鼓励这样做 ...

  2. hybrid app开发中用到的html5新特性localStorage、sessionStorage和websql database

    近期在项目中进行hybrid app开发,项目中有大量的js代码执行在android设备上. 使用到了非常多HTML5的新特性,之前没有遇到过,不了解.这里记录下添加点前端的知识.混合式app开发中. ...

  3. Git详解之四 服务器上的Git

    以下内容转载自:http://www.open-open.com/lib/view/open1328069988843.html 服务器上的 Git 到目前为止,你应该已经学会了使用 Git 来完成日 ...

  4. [转]Git详解之四 服务器上的Git

    服务器上的 Git 到目前为止,你应该已经学会了使用 Git 来完成日常工作.然而,如果想与他人合作,还需要一个远程的 Git 仓库.尽管技术上可以从个人的仓库里推送和拉取修改内容,但我们不鼓励这样做 ...

  5. SoapUI Pro Project Solution Collection –Easy develop Groovy Script to improve SoapUI ability

    As you know the groovy script and java script language is the soapui supported .but unfortunately So ...

  6. Java Script 编码规范【转】

    Java Script 编码规范 以下文档大多来自: Google JavaScript 编码规范指南 Idiomatic 风格 参考规范 ECMAScript 5.1 注解版 EcmaScript ...

  7. Struts2 easy UI插件

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  8. Easy UI常用插件使用

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  9. Using Script and Style Bundles【翻译】

    遇到个MVC4中的bundles的问题,问了别人,由于不熟悉MVC4,始终问不到点子上,所以自己就翻译了下资料,搞明白了这个VS显示正常IIS显示异常的小问题,申明我翻译的很烂,不过共享出来或许会帮到 ...

随机推荐

  1. 前端获取http和完整项目名

    <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...

  2. C++ 新特性 笔记

    摘录 constexptr C++14尝鲜:constexpr函数(编译期函数) 总结来说,就是在c++11之前,要实现编译期数值计算需要繁琐的模板元编程.在c++11 中,可以是函数,在一句rutu ...

  3. Ubuntu18.04安装 NVIDIA驱动

    Ubuntu18.04安装 NVIDIA驱动 参考自博客:https://blog.csdn.net/jsjason1/article/details/88086904 我确定这篇文章是否很有必要,我 ...

  4. html标签被div嵌套页面字体变大的解决办法

    html标签被div嵌套页面字体变大的解决办法 <div> <html> <head> <title></title> </head& ...

  5. Linux用户账号文件——passwd

    /etc/passwd文件是UNIX安全的关键文件之一.该文件用于用户登录时校验用户的登录名.加密的口令数据项.用户ID(UID).默认的用户组ID(GID).用户信息.用户主目录以及登录后使用的sh ...

  6. 第七章 路由 75 路由传参-使用query方式传递参数

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  7. impdp导入报错39002

    原文:https://www.cnblogs.com/huacw/p/3888807.html 1 create directory data_pump_dir as '\exphd\datapump ...

  8. linux内核 进程调度

    概念: 进程调度决定那个进程投入运行,运行多长时间. 进程调度没有太复杂的原理,最大限度的利用处理器时间的原则是:只要有可执行的程序,那么总会有进程在执行,如果可运行的进程比处理器数目要多,那么注定要 ...

  9. Mybatis映射文件中数据库表列名称和POJO成员域的联系

    下面是Mybatis的SQL映射文件. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ma ...

  10. strace分析启动流程

    strace -ttt /usr/local/mysql/bin/mysqld 2>&1 |tee 1.log vi 1.log 1 1530183737.761709 execve(& ...