easy dragging script
下面的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
easy dragging script的更多相关文章
- Git详解之四:服务器上的Git
服务器上的 Git 到目前为止,你应该已经学会了使用 Git 来完成日常工作.然而,如果想与他人合作,还需要一个远程的 Git 仓库.尽管技术上可以从个人的仓库里推送和拉取修改内容,但我们不鼓励这样做 ...
- hybrid app开发中用到的html5新特性localStorage、sessionStorage和websql database
近期在项目中进行hybrid app开发,项目中有大量的js代码执行在android设备上. 使用到了非常多HTML5的新特性,之前没有遇到过,不了解.这里记录下添加点前端的知识.混合式app开发中. ...
- Git详解之四 服务器上的Git
以下内容转载自:http://www.open-open.com/lib/view/open1328069988843.html 服务器上的 Git 到目前为止,你应该已经学会了使用 Git 来完成日 ...
- [转]Git详解之四 服务器上的Git
服务器上的 Git 到目前为止,你应该已经学会了使用 Git 来完成日常工作.然而,如果想与他人合作,还需要一个远程的 Git 仓库.尽管技术上可以从个人的仓库里推送和拉取修改内容,但我们不鼓励这样做 ...
- 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 ...
- Java Script 编码规范【转】
Java Script 编码规范 以下文档大多来自: Google JavaScript 编码规范指南 Idiomatic 风格 参考规范 ECMAScript 5.1 注解版 EcmaScript ...
- Struts2 easy UI插件
一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...
- Easy UI常用插件使用
一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...
- Using Script and Style Bundles【翻译】
遇到个MVC4中的bundles的问题,问了别人,由于不熟悉MVC4,始终问不到点子上,所以自己就翻译了下资料,搞明白了这个VS显示正常IIS显示异常的小问题,申明我翻译的很烂,不过共享出来或许会帮到 ...
随机推荐
- PHP的八种数据类型
PHP 支持8种基本的数据类型. 四种标量类型: boolean (布尔型) integer (整型) float (浮点型, 也称作 double) string (字符串) 两种复合类型: arr ...
- 【C/C++】内存对齐规则和实战
内存对齐规则和实战 这篇文章是我的平时的一个笔记修改后来的.这里主要介绍一下内存对齐的规则,以及提供一些实战一下.几篇我觉得比较好的详细的介绍内存对齐的作用什么的博文会在文末附上. 规则 在开始实战前 ...
- 9.1.远程过程调用协议_RPC
6. RPC 6.1.什么是 RPC RPC(Remote Procedure Call Protocol)远程过程调用协议 通俗的描述是:客户端在不知道调用细节的情况下,调用存在于远程计算机上的某个 ...
- 8.7.ZooKeeper Watcher监听
1.ZooKeeper Watcher ZooKeeper 提供了分布式数据发布/订阅功能,一个典型的发布/订阅模型系统定义了一种一对多的订阅关系,能让多个订阅者同时监听某一个主题对象, 当这个主题对 ...
- linux获取某一个网卡的ipv4地址
ip a show ens33 | grep inet | grep -v inet6 | awk '{print $2}' | awk -F '/' '{print $1}'
- zencart设置产品始终免运费sql
zencart网站后台-Tools(工具)-Install SQL Patches(安装SQL脚本): 运行以下相应sql语句,即可实现产品始终免运费. zencart设置所有产品始终免运费: '; ...
- web页面ios浏览器img图片的坑
大家都知道ios浏览器有个默认的内置事件,就是长按屏幕,会放大预览你点击的内容. 不同浏览器效果各异,有的浏览器弹出提示框,预览图片或保存图片.主要呈下面2中形式.体验最差的就是后者,会直接将页面中的 ...
- BZOJ1491 [NOI2007]社交网络[最短路计数]
$n$非常的小,结合题目计算式可以想到$O(n^3)$暴枚$s,t,v$,看$v$在不在$s\to t$最短路上($dis_{s,v}+dis_{v,t}=dis_{s,v}$是$v$在两点最短路上的 ...
- kudu安装
安装前提和准备: 硬件: 一台或者多台机器跑kudu-master.建议跑一个master(无容错机制).三个master(允许一个节点运行出错)或者五个master(允许两个节点出错). 一台或者多 ...
- 闭包-IIFE
1)嵌套函数,内部函数访问了外部函数的局部变量,通过返回内部函数,在函数外部调用内部函数,从而更新外部函数的局部变量的过程: 2)代码执行完成之后离开作用域依旧存在 3)有可能发生内存泄露,若对象的引 ...