103 lines
3.0 KiB
Plaintext
103 lines
3.0 KiB
Plaintext
#SingleInstance FORCE
|
|
#Include options.ahk
|
|
|
|
Menu, TRAY, Tip, WindowUtils
|
|
Menu, TRAY, NoStandard
|
|
Menu, TRAY, add, About, About
|
|
Menu, TRAY, add, Invert Keys, Invert
|
|
Menu, TRAY, add
|
|
Menu, TRAY, add, Close WindowUtils, Close
|
|
|
|
SetWinDelay,2
|
|
|
|
CoordMode,Mouse
|
|
|
|
k_inverted=
|
|
|
|
GoSub, hotkeys
|
|
|
|
return
|
|
|
|
hotkeys:
|
|
IniRead, k_inverted, %k_config%, Settings, Inverted
|
|
if k_inverted
|
|
{
|
|
Menu, TRAY, check, Invert Keys
|
|
k_key1=XButton2
|
|
k_key2=XButton1
|
|
} else {
|
|
Menu, TRAY, uncheck, Invert Keys
|
|
k_key1=XButton1
|
|
k_key2=XButton2
|
|
}
|
|
HotKey, %k_key1%, key1
|
|
HotKey, %k_key2%, key2
|
|
return
|
|
|
|
Invert:
|
|
if k_inverted
|
|
{
|
|
k_inverted := false
|
|
} else {
|
|
k_inverted := true
|
|
}
|
|
IniWrite, %k_inverted%, %k_config%, Settings, Inverted
|
|
GoSub, hotkeys
|
|
return
|
|
|
|
key1:
|
|
; 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 (A_ThisHotkey = A_PriorHotkey && A_TimeSincePriorHotkey < 300)
|
|
WinMinimize, ahk_id %KDE_id%
|
|
else if (A_ThisHotkey = A_PriorHotkey && A_TimeSincePriorHotkey < 1000)
|
|
WinRestore, ahk_id %KDE_id%
|
|
return
|
|
|
|
key2:
|
|
|
|
; 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%
|
|
; Get the initial window position.
|
|
WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
|
|
WinActivate, ahk_id %KDE_id%
|
|
WinRestore, ahk_id %KDE_id%
|
|
if (A_ThisHotkey = A_PriorHotkey && A_TimeSincePriorHotkey < 500)
|
|
{
|
|
WinMaximize, ahk_id %KDE_id%
|
|
return
|
|
}
|
|
Loop
|
|
{
|
|
GetKeyState,KDE_Button,%k_key2%,P ; Break if button has been released.
|
|
If KDE_Button = U
|
|
{
|
|
If KDE_Win
|
|
{
|
|
WinMaximize, ahk_id %KDE_id%
|
|
}
|
|
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
|
|
|
|
|
|
Close:
|
|
MsgBox, 52, WindowUtils, Are you sure you want to close WindowUtils?
|
|
IfMsgBox, YES
|
|
ExitApp
|
|
return
|
|
|
|
About:
|
|
MsgBox,, WindowUtils, WindowUtils is designed to make moving windows easier.`nNOTE: WindowUtils will change the window to a box for easier moving, but will remember if it was full-screen to start with and restore it after.`n`nButtons Used -`nFirst extra mouse button (generally a shortcut for 'back')`nSecond extra mouse button (generally a shortcut for 'forward')`n`nFunction 1: By holding the first extra button on your mouse, you can move a window from anywhere inside its' border.`n`nFunction 2: By double-clicking the first extra mouse button, you can maximize a window.`n`nFunction 3: By slowly double clicking the second extra button on your mouse, you can 'box' a window.`n`nFunction 4: By quickly double clicking the second extra button on your mouse, you can minimize a window.`n`n`nGive it a try with this window!
|
|
return |