AutoHotkey代碼

#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.

; 更新歷史:

; 2006.11.07: 優(yōu)化了 !RButton 中的大小調(diào)整代碼, courtesy of bluedawn.

; 2006.02.05: 修復(fù) double-aalt (~Alt 熱鍵) 以使它工作于最近的 AHK 版本.

; 雙 Alt 修飾鍵是通過按下

; Alt 兩次來激活的, 很像雙擊. 第二次時保持按住,

; 一直到您點(diǎn)擊.

;

; 快捷鍵:

;? Alt + Left Button? : 拖動來移動窗口.

;? Alt + Right Button : 拖動來調(diào)整窗口大小.

;? Double-Alt + Left Button? : 最小化窗口.

;? Double-Alt + Right Button? : 最大化/還原窗口.

;? Double-Alt + Middle Button : 關(guān)閉窗口.

;

; 您可以在首次點(diǎn)擊 Alt 后

; 松開它而不用在整個過程中都按住.

; 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

;連按兩次ESC關(guān)閉窗口

~Esc::

Keywait, Escape, , t0.5

if errorlevel = 1

return

else

Keywait, Escape, d, t0.1

if errorlevel = 0

{

WinGetActiveTitle, Title

WinClose, %Title%

return

}

return

;復(fù)制鼠標(biāo)中間鍵诺舔,粘貼F12以舒,F(xiàn)11輸入renzhongyi F10輸入renzhongyi1

MButton::send ^c

F12::send ^v

F11::send renzhongyi

F10::send brysjhhrhl1

;win+空格打開2345首頁乍恐,活動窗口輸入密碼Ctrl Alt+S

#space::Run www.2345.com/?chrome

^!s::

Send brysjhhrhl{Enter}

return

;win+z循環(huán)切換當(dāng)前窗口大小

SetTitleMatchMode, 3

event_index:=-1

#z::

WinGetTitle, current_win, A

if (current_win!=old_win)

event_index=-1

if(event_index=-1)

{

old_win:=current_win

WinGetPos, X, Y, current_Width, current_Height, %current_win%? ;這里A應(yīng)該改成目標(biāo)窗口,只獲取一次某窗口的大小

;quarter := new quarter(current_Width,current_Height)

;one_third:= new one_third(current_Width,current_Height)

;two_third:= new two_third(current_Width,current_Height)

;若針對窗體而不是屏幕則解除上面注釋 并給窗體值

;用SysGet, MonitorWorkArea锯仪,而未用A_ScreenWidth A_ScreenHeight 避免任務(wù)條的影響

SysGet, MonitorWorkArea, MonitorWorkArea,1

;MsgBox, Monitor:`t`nLeft:`t%MonitorLeft% (%MonitorWorkAreaLeft% work)`nTop:`t%MonitorTop% (%MonitorWorkAreaTop% work)`nRight:`t%MonitorRight% (%MonitorWorkAreaRight% work)`nBottom:`t%MonitorBottom% (%MonitorWorkAreaBottom% work)

quarter := new quarter(MonitorWorkAreaRight ,MonitorWorkAreaBottom)

one_third:= new one_third(MonitorWorkAreaRight ,MonitorWorkAreaBottom)

two_third:= new two_third(MonitorWorkAreaRight ,MonitorWorkAreaBottom)

}

event_index+=1

event_index:=Mod(event_index, 3)? ;3個狀態(tài)循環(huán),模3沸移,模運(yùn)算得出 0财喳,1,2

commandArray := ["quarter", "one_third", "two_third"]

runner:=commandArray[event_index+1] ;因?yàn)閍hk的數(shù)組是從1開始的立砸,對于索引為0時是空值掖疮,加一避免此問題

%runner%.zoom()

;TrayTip, %current_win%縮放%runner%,% "w=" %runner%.getNewWidth()? ",h="? %runner%.getNewHeight() , 10,

NewWidth:=%runner%.getNewWidth()

NewHeight:=%runner%.getNewHeight()

WinMove, %current_win%,,MonitorWorkAreaRight-NewWidth,MonitorWorkAreaBottom-NewHeight,NewWidth,NewHeight

Return

class WinSize

{

Width :=0

Height := 0

NewWidth:=0

NewHeight:=0

;SetWidth(val){

;? Width := val ; Can set the color using a function of the class

;}

;SetHeight(val){

;? Height := val ; Can set the color using a function of the class

;}

GetWidth(){

Return this.Width ;需要增加this

}

GetHeight(){

Return this.Height? ;需要增加this

}

GetNewWidth(){

Return this.NewWidth ;需要增加this

}

GetNewHeight(){

Return this.NewHeight? ;需要增加this

}

__New(w="",h=""){

if (w="")

this.Width :=A_ScreenWidth

Else

this.Width :=w

if (h="")

this.Height:=A_ScreenHeight

Else

this.Height := h

}

}

Class half extends WinSize{

zoom()

{

this.NewWidth:=? this.Width//2? ;向下舍除 (//)

this.NewHeight:=? this.Height

}

}

Class quarter extends WinSize{

zoom()

{

this.NewWidth:=? this.Width//2

this.NewHeight:=? this.Height//2

}

}

Class one_third extends WinSize{

zoom()

{

this.NewWidth:= this.Width//3

this.NewHeight:= this.Height

}

}

Class two_third extends WinSize{

zoom()

{

this.NewWidth:= this.Width*2//3

this.NewHeight:= this.Height

}

}

;Ctrl + Alt + Shift + Win + Q? 快捷鍵啟動QQ

^!+#q::run C:\ruanjian\Tencent\QQ\QQProtect\Bin\QQProtect.exe

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市颗祝,隨后出現(xiàn)的幾起案子浊闪,更是在濱河造成了極大的恐慌,老刑警劉巖螺戳,帶你破解...
    沈念sama閱讀 222,000評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件搁宾,死亡現(xiàn)場離奇詭異,居然都是意外死亡倔幼,警方通過查閱死者的電腦和手機(jī)盖腿,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,745評論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來凤藏,“玉大人,你說我怎么就攤上這事堕伪∫咀” “怎么了?”我有些...
    開封第一講書人閱讀 168,561評論 0 360
  • 文/不壞的土叔 我叫張陵欠雌,是天一觀的道長蹄梢。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么禁炒? 我笑而不...
    開封第一講書人閱讀 59,782評論 1 298
  • 正文 為了忘掉前任而咆,我火速辦了婚禮,結(jié)果婚禮上幕袱,老公的妹妹穿的比我還像新娘暴备。我一直安慰自己,他們只是感情好们豌,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,798評論 6 397
  • 文/花漫 我一把揭開白布涯捻。 她就那樣靜靜地躺著,像睡著了一般望迎。 火紅的嫁衣襯著肌膚如雪障癌。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,394評論 1 310
  • 那天辩尊,我揣著相機(jī)與錄音涛浙,去河邊找鬼。 笑死摄欲,一個胖子當(dāng)著我的面吹牛轿亮,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播蒿涎,決...
    沈念sama閱讀 40,952評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼哀托,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了劳秋?” 一聲冷哼從身側(cè)響起仓手,我...
    開封第一講書人閱讀 39,852評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎玻淑,沒想到半個月后嗽冒,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,409評論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡补履,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,483評論 3 341
  • 正文 我和宋清朗相戀三年添坊,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片箫锤。...
    茶點(diǎn)故事閱讀 40,615評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡贬蛙,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出谚攒,到底是詐尸還是另有隱情阳准,我是刑警寧澤,帶...
    沈念sama閱讀 36,303評論 5 350
  • 正文 年R本政府宣布馏臭,位于F島的核電站野蝇,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜绕沈,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,979評論 3 334
  • 文/蒙蒙 一锐想、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧乍狐,春花似錦赠摇、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,470評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至掘鄙,卻和暖如春耘戚,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背操漠。 一陣腳步聲響...
    開封第一講書人閱讀 33,571評論 1 272
  • 我被黑心中介騙來泰國打工收津, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人浊伙。 一個月前我還...
    沈念sama閱讀 49,041評論 3 377
  • 正文 我出身青樓撞秋,卻偏偏與公主長得像,于是被迫代替她去往敵國和親嚣鄙。 傳聞我的和親對象是個殘疾皇子吻贿,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,630評論 2 359

推薦閱讀更多精彩內(nèi)容