commit 4683de4c6ee114250d790d0ea20a7aabdb869929 Author: jolheiser Date: Thu Apr 21 15:53:19 2022 -0500 Initial commit Signed-off-by: jolheiser diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..2898abc --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,30 @@ +pipeline: + compile-main: + image: jolheiser/woodpecker-ahk:latest + settings: + script: src/WindowUtils.ahk + icon: icon.ico + out: src/WindowUtils.exe + when: + event: push + branch: main + compile-installer: + image: jolheiser/woodpecker-ahk:latest + settings: + script: src/WindowUtils-Install.ahk + icon: icon.ico + out: src/WindowUtils-Install.exe + when: + event: push + branch: main + release-main: + image: jolheiser/drone-gitea-main:latest + settings: + base: https://git.jojodev.com + token: + from_secret: gitea_token + files: + - "src/WindowUtils-Install.exe" + when: + event: push + branch: main \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ec2045e --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2022 John Olheiser + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a9eee93 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# WindowUtils + +![icon](icon.ico) + +An AHK script that enhances the mouse side buttons for dragging windows around. + +## License + +[MIT](LICENSE) \ No newline at end of file diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000..969786a Binary files /dev/null and b/icon.ico differ diff --git a/src/WindowUtils-Install.ahk b/src/WindowUtils-Install.ahk new file mode 100644 index 0000000..84fca33 --- /dev/null +++ b/src/WindowUtils-Install.ahk @@ -0,0 +1,16 @@ +#Include options.ahk + +GoSub, CheckInstall + +return + +CheckInstall: + FileCreateDir, %k_base% + FileInstall, config.ini, %k_config%, 0 + FileInstall, WindowUtils.exe, %k_base%\WindowUtils.exe, 1 + MsgBox, 36, WindowUtils, Installed successfully!`nWould you like to start WindowUtils? + IfMsgBox, Yes + { + Run, %k_base%\WindowUtils.exe + } +return \ No newline at end of file diff --git a/src/WindowUtils.ahk b/src/WindowUtils.ahk new file mode 100644 index 0000000..1a99269 --- /dev/null +++ b/src/WindowUtils.ahk @@ -0,0 +1,103 @@ +#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 \ No newline at end of file diff --git a/src/config.ini b/src/config.ini new file mode 100644 index 0000000..a8d960b --- /dev/null +++ b/src/config.ini @@ -0,0 +1,2 @@ +[Settings] +inverted=false \ No newline at end of file diff --git a/src/options.ahk b/src/options.ahk new file mode 100644 index 0000000..1af3624 --- /dev/null +++ b/src/options.ahk @@ -0,0 +1,2 @@ +k_base=C:\Applications\WindowUtils +k_config=%k_base%\config.ini \ No newline at end of file