Skip to content

Commit a7f26ab

Browse files
committed
feat: turn off shortcuts if no configuration is found
1 parent 2ac775b commit a7f26ab

File tree

2 files changed

+70
-59
lines changed

2 files changed

+70
-59
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [v0.7.0](https://github.com/thesobercoder/polygon/compare/v0.6.0...v0.7.0) (2024-08-01)
2+
3+
### Features
4+
5+
- Adds ability to turn off shortcuts by removing the config from the ini file
6+
17
## [v0.6.0](https://github.com/thesobercoder/polygon/compare/v0.5.0...v0.6.0) (2024-05-06)
28

39
### Features

polygon.ahk

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
;-- Ahk2Exe properties
77
;@Ahk2Exe-SetName Polygon
8-
;@Ahk2Exe-SetVersion 0.6.0
8+
;@Ahk2Exe-SetVersion 0.7.0
99
;@Ahk2Exe-SetCompanyName Soham Dasgupta
1010
;@Ahk2Exe-SetDescription A window manager for Windows 10/11 powered by AutoHotkey
1111

1212
;-- Globals
13-
global APP_VERSION := "0.6.0"
13+
global APP_VERSION := "0.7.0"
1414
global APP_VERSION_NAME := "v" . APP_VERSION
1515
global APP_NAME := "Polygon"
1616
global APP_REPO_OWNER := "thesobercoder"
@@ -21,34 +21,34 @@ global APP_UPDATE_URL := APP_URL . "/releases/latest"
2121
global APP_INI_FILE := "polygon.ini"
2222
global APP_INI_SECTION_SHORTCUT := "Shortcut"
2323
global APP_INI_SECTION_TOAST := "Toast"
24-
global APP_SETTING_ISTOASTENABLED := IniRead(APP_INI_FILE, APP_INI_SECTION_TOAST, "Show", "1") == "1" ? true : false
25-
global APP_SHORTCUT_CENTER := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "Center", "^#c")
26-
global APP_SHORTCUT_CENTERHD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterHD", "^#/")
27-
global APP_SHORTCUT_CENTERHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterHalf", "^#w")
28-
global APP_SHORTCUT_CENTERTWOTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterTwoThird", "^#r")
29-
global APP_SHORTCUT_FIRSTTWOTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "FirstTwoThird", "^#a")
30-
global APP_SHORTCUT_LASTTWOTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LastTwoThird", "^#h")
31-
global APP_SHORTCUT_FIRSTTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "FirstThird", "^#d")
32-
global APP_SHORTCUT_CENTERTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterThird", "^#f")
33-
global APP_SHORTCUT_LASTTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LastThird", "^#g")
34-
global APP_SHORTCUT_TOPLEFTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopLeftSixth", "^#z")
35-
global APP_SHORTCUT_BOTTOMLEFTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomLeftSixth", "^#x")
36-
global APP_SHORTCUT_TOPRIGHTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopRightSixth", "^#v")
37-
global APP_SHORTCUT_BOTTOMRIGHTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomRightSixth", "^#b")
38-
global APP_SHORTCUT_TOPCENTERSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopCenterSixth", "^#n")
39-
global APP_SHORTCUT_BOTTOMCENTERSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomCenterSixth", "^#m")
40-
global APP_SHORTCUT_LEFTHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LeftHalf", "^#[")
41-
global APP_SHORTCUT_RIGHTHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "RightHalf", "^#]")
42-
global APP_SHORTCUT_TOPLEFT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopLeft", "^#u")
43-
global APP_SHORTCUT_TOPRIGHT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopRight", "^#i")
44-
global APP_SHORTCUT_BOTTOMLEFT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomLeft", "^#j")
45-
global APP_SHORTCUT_BOTTOMRIGHT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomRight", "^#k")
46-
global APP_SHORTCUT_TOPHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopHalf", "^#-")
47-
global APP_SHORTCUT_BOTTOMHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomHalf", "^#=")
48-
global APP_SHORTCUT_FIRSTFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "FirstFourth", "^#;")
49-
global APP_SHORTCUT_SECONDFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "SecondFourth", "^#'")
50-
global APP_SHORTCUT_THIRDFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "ThirdFourth", "^#,")
51-
global APP_SHORTCUT_LASTFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LastFourth", "^#.")
24+
global APP_SETTING_ISTOASTENABLED := IniRead(APP_INI_FILE, APP_INI_SECTION_TOAST, "Show", "0") == "1" ? true : false
25+
global APP_SHORTCUT_CENTER := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "Center", "")
26+
global APP_SHORTCUT_CENTERHD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterHD", "")
27+
global APP_SHORTCUT_CENTERHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterHalf", "")
28+
global APP_SHORTCUT_CENTERTWOTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterTwoThird", "")
29+
global APP_SHORTCUT_FIRSTTWOTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "FirstTwoThird", "")
30+
global APP_SHORTCUT_LASTTWOTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LastTwoThird", "")
31+
global APP_SHORTCUT_FIRSTTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "FirstThird", "")
32+
global APP_SHORTCUT_CENTERTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "CenterThird", "")
33+
global APP_SHORTCUT_LASTTHIRD := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LastThird", "")
34+
global APP_SHORTCUT_TOPLEFTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopLeftSixth", "")
35+
global APP_SHORTCUT_BOTTOMLEFTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomLeftSixth", "")
36+
global APP_SHORTCUT_TOPRIGHTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopRightSixth", "")
37+
global APP_SHORTCUT_BOTTOMRIGHTSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomRightSixth", "")
38+
global APP_SHORTCUT_TOPCENTERSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopCenterSixth", "")
39+
global APP_SHORTCUT_BOTTOMCENTERSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomCenterSixth", "")
40+
global APP_SHORTCUT_LEFTHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LeftHalf", "")
41+
global APP_SHORTCUT_RIGHTHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "RightHalf", "")
42+
global APP_SHORTCUT_TOPLEFT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopLeft", "")
43+
global APP_SHORTCUT_TOPRIGHT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopRight", "")
44+
global APP_SHORTCUT_BOTTOMLEFT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomLeft", "")
45+
global APP_SHORTCUT_BOTTOMRIGHT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomRight", "")
46+
global APP_SHORTCUT_TOPHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopHalf", "")
47+
global APP_SHORTCUT_BOTTOMHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomHalf", "")
48+
global APP_SHORTCUT_FIRSTFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "FirstFourth", "")
49+
global APP_SHORTCUT_SECONDFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "SecondFourth", "")
50+
global APP_SHORTCUT_THIRDFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "ThirdFourth", "")
51+
global APP_SHORTCUT_LASTFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LastFourth", "")
5252
;--Tooltip
5353
A_IconTip := APP_NAME
5454
;-- Register global error logging
@@ -199,34 +199,39 @@ Terminate(*) {
199199
ShowVersion(*) {
200200
MsgBox("Version " . APP_VERSION, APP_NAME, "Iconi")
201201
}
202-
;-- Map Hotkeys
203-
Hotkey(APP_SHORTCUT_CENTER, Center)
204-
Hotkey(APP_SHORTCUT_CENTERHD, CenterHD)
205-
Hotkey(APP_SHORTCUT_CENTERHALF, CenterHalf)
206-
Hotkey(APP_SHORTCUT_CENTERTWOTHIRD, CenterTwoThird)
207-
Hotkey(APP_SHORTCUT_FIRSTTHIRD, FirstThird)
208-
Hotkey(APP_SHORTCUT_CENTERTHIRD, CenterThird)
209-
Hotkey(APP_SHORTCUT_FIRSTTWOTHIRD, FirstTwoThird)
210-
Hotkey(APP_SHORTCUT_LASTTWOTHIRD, LastTwoThird)
211-
Hotkey(APP_SHORTCUT_LASTTHIRD, LastThird)
212-
Hotkey(APP_SHORTCUT_TOPLEFTSIXTH, TopLeftSixth)
213-
Hotkey(APP_SHORTCUT_BOTTOMLEFTSIXTH, BottomLeftSixth)
214-
Hotkey(APP_SHORTCUT_TOPRIGHTSIXTH, TopRightSixth)
215-
Hotkey(APP_SHORTCUT_BOTTOMRIGHTSIXTH, BottomRightSixth)
216-
Hotkey(APP_SHORTCUT_TOPCENTERSIXTH, TopCenterSixth)
217-
Hotkey(APP_SHORTCUT_BOTTOMCENTERSIXTH, BottomCenterSixth)
218-
Hotkey(APP_SHORTCUT_LEFTHALF, LeftHalf)
219-
Hotkey(APP_SHORTCUT_RIGHTHALF, RightHalf)
220-
Hotkey(APP_SHORTCUT_TOPLEFT, TopLeft)
221-
Hotkey(APP_SHORTCUT_TOPRIGHT, TopRight)
222-
Hotkey(APP_SHORTCUT_BOTTOMLEFT, BottomLeft)
223-
Hotkey(APP_SHORTCUT_BOTTOMRIGHT, BottomRight)
224-
Hotkey(APP_SHORTCUT_TOPHALF, TopHalf)
225-
Hotkey(APP_SHORTCUT_BOTTOMHALF, BottomHalf)
226-
Hotkey(APP_SHORTCUT_FIRSTFOURTH, FirstFourth)
227-
Hotkey(APP_SHORTCUT_SECONDFOURTH, SecondFourth)
228-
Hotkey(APP_SHORTCUT_THIRDFOURTH, ThirdFourth)
229-
Hotkey(APP_SHORTCUT_LASTFOURTH, LastFourth)
202+
SetConditionalHotkey(shortcut, func) {
203+
if (shortcut && shortcut != "") {
204+
Hotkey(shortcut, func)
205+
}
206+
}
207+
;-- Map Hotkeys using SetConditionalHotkey function
208+
SetConditionalHotkey(APP_SHORTCUT_CENTER, Center)
209+
SetConditionalHotkey(APP_SHORTCUT_CENTERHD, CenterHD)
210+
SetConditionalHotkey(APP_SHORTCUT_CENTERHALF, CenterHalf)
211+
SetConditionalHotkey(APP_SHORTCUT_CENTERTWOTHIRD, CenterTwoThird)
212+
SetConditionalHotkey(APP_SHORTCUT_FIRSTTHIRD, FirstThird)
213+
SetConditionalHotkey(APP_SHORTCUT_CENTERTHIRD, CenterThird)
214+
SetConditionalHotkey(APP_SHORTCUT_FIRSTTWOTHIRD, FirstTwoThird)
215+
SetConditionalHotkey(APP_SHORTCUT_LASTTWOTHIRD, LastTwoThird)
216+
SetConditionalHotkey(APP_SHORTCUT_LASTTHIRD, LastThird)
217+
SetConditionalHotkey(APP_SHORTCUT_TOPLEFTSIXTH, TopLeftSixth)
218+
SetConditionalHotkey(APP_SHORTCUT_BOTTOMLEFTSIXTH, BottomLeftSixth)
219+
SetConditionalHotkey(APP_SHORTCUT_TOPRIGHTSIXTH, TopRightSixth)
220+
SetConditionalHotkey(APP_SHORTCUT_BOTTOMRIGHTSIXTH, BottomRightSixth)
221+
SetConditionalHotkey(APP_SHORTCUT_TOPCENTERSIXTH, TopCenterSixth)
222+
SetConditionalHotkey(APP_SHORTCUT_BOTTOMCENTERSIXTH, BottomCenterSixth)
223+
SetConditionalHotkey(APP_SHORTCUT_LEFTHALF, LeftHalf)
224+
SetConditionalHotkey(APP_SHORTCUT_RIGHTHALF, RightHalf)
225+
SetConditionalHotkey(APP_SHORTCUT_TOPLEFT, TopLeft)
226+
SetConditionalHotkey(APP_SHORTCUT_TOPRIGHT, TopRight)
227+
SetConditionalHotkey(APP_SHORTCUT_BOTTOMLEFT, BottomLeft)
228+
SetConditionalHotkey(APP_SHORTCUT_BOTTOMRIGHT, BottomRight)
229+
SetConditionalHotkey(APP_SHORTCUT_TOPHALF, TopHalf)
230+
SetConditionalHotkey(APP_SHORTCUT_BOTTOMHALF, BottomHalf)
231+
SetConditionalHotkey(APP_SHORTCUT_FIRSTFOURTH, FirstFourth)
232+
SetConditionalHotkey(APP_SHORTCUT_SECONDFOURTH, SecondFourth)
233+
SetConditionalHotkey(APP_SHORTCUT_THIRDFOURTH, ThirdFourth)
234+
SetConditionalHotkey(APP_SHORTCUT_LASTFOURTH, LastFourth)
230235
;-- Layout Functions
231236
Center(*) {
232237
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
@@ -635,4 +640,4 @@ WinGetPosEx(hWindow, &winX := 0, &winY := 0, &winW := 0, &winH := 0, &winOffsetL
635640
NumPut("Int", winOffsetRight := GWR_Right - Right, RECTPlus, 24)
636641
NumPut("Int", winOffsetBottom := GWR_Bottom - Bottom, RECTPlus, 28)
637642
Return &RECTPlus
638-
}
643+
}

0 commit comments

Comments
 (0)