Skip to content

Commit b754acb

Browse files
authored
Update HyperSearch.ahk
- added ability to set custom font size - optimized reading registry key for default browser
1 parent 555deaa commit b754acb

1 file changed

Lines changed: 56 additions & 11 deletions

File tree

HyperSearch.ahk

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; JSSatchell 2023
1+
; JSSatchell 2026
22
; https://github.com/JSSatchell/HyperSearch
33

44
#Requires AutoHotkey v2.0
@@ -20,7 +20,17 @@ version:="0.3.2"
2020
;;;;;;;;;;;;;;;;;;;;;;;;;
2121

2222
; Use default browser
23-
ProgID := RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", "Progid")
23+
24+
try {
25+
ProgID := RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoiceLatest", "Progid")
26+
} catch {
27+
ProgID := RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoiceLatest\ProgId", "Progid")
28+
} catch {
29+
ProgID := RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", "Progid")
30+
} catch {
31+
ProgID := RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice\ProgId", "Progid")
32+
}
33+
2434
Browser := "msedge.exe"
2535
if (ProgID = "ChromeHTML")
2636
Browser := "chrome.exe"
@@ -63,6 +73,7 @@ urlDisplay := modeTxt
6373
minMode := IniRead("HS_Settings.ini", "Settings", "MinMode")
6474
currentGui := minMode = 1 ? "LiteGui" : "MainGui"
6575

76+
6677
; Check for repo file
6778
if !FileExist(repo) {
6879
if (sMode = "web")
@@ -627,7 +638,15 @@ ActivateLinks(*)
627638
if (linkArray[linksListbox.value][2] == "*") {
628639
linkLabel:=linkArray[linksListbox.value][1]
629640
RegExMatch(linkLabel, "<(.*?)>", &match)
630-
ControlChooseString match[1], catListbox
641+
;ControlChooseString match[1], catListbox
642+
try {
643+
ControlChooseString match[1], catListbox
644+
;editBar.value:=""
645+
return
646+
} catch {
647+
MsgBox 'Category "' match[1] '" not found.'
648+
return
649+
}
631650
} else {
632651
goSearch(linkArray[linksListbox.value][2],0)
633652
}
@@ -1502,6 +1521,22 @@ EditSettings(*)
15021521
MsgBox "Value should be a number."
15031522
return
15041523
}
1524+
} else if (search[2] ~= "i)t.{0,1}xt") {
1525+
newTxtPt := search[3]
1526+
try
1527+
{
1528+
newTxtPt := Integer(newTxtPt)
1529+
IniWrite "1", "HS_Settings.ini", "Settings", "CustomTxtSize"
1530+
IniWrite newTxtPt, "HS_Settings.ini", "Settings", "TxtSize"
1531+
} catch TypeError {
1532+
if (newTxtPt ~= "i)def.{0,4}")
1533+
IniWrite "0", "HS_Settings.ini", "Settings", "CustomTxtSize"
1534+
else if (newTxtPt ~= "i)cust.{0,2}")
1535+
IniWrite "1", "HS_Settings.ini", "Settings", "CustomTxtSize"
1536+
else
1537+
MsgBox "Value should be a number."
1538+
return
1539+
}
15051540
} else {
15061541
MsgBox "Invalid settings option."
15071542
}
@@ -1511,6 +1546,10 @@ SetTheme(*)
15111546
{
15121547
themeSel := IniRead("HS_Settings.ini", "Settings", "DkMd")
15131548
opSel := IniRead("HS_Settings.ini", "Settings", "Opacity")
1549+
txtPt := IniRead("HS_Settings.ini", "Settings", "TxtSize")
1550+
txtCust := IniRead("HS_Settings.ini", "Settings", "CustomTxtSize")
1551+
if (txtCust == 1)
1552+
%currentGui%.setFont("s" txtPt)
15141553
if (themeSel == 1) {
15151554
global guiFont := "cWhite"
15161555
%currentGui%.BackColor := ("c404040")
@@ -1628,8 +1667,12 @@ CheckSettings(*)
16281667

16291668
prevVer := IniRead("HS_Settings.ini", "Version", "CurrentVersion")
16301669

1631-
if (prevVer == "0.2.2") {
1632-
FileAppend("`nDirRepo=HFR_Master.csv`nSearchMode=web","HS_Settings.ini")
1670+
switch lastSettingArray[1]
1671+
{
1672+
case "Opacity":
1673+
FileAppend("`nDirRepo=HFR_Master.csv`nSearchMode=web`nCustomTxtSize=0`nTxtSize=9","HS_Settings.ini")
1674+
case "SearchMode":
1675+
FileAppend("`nCustomTxtSize=0`nTxtSize=9","HS_Settings.ini")
16331676
}
16341677

16351678
IniWrite(version, "HS_Settings.ini","Version","CurrentVersion")
@@ -1680,6 +1723,8 @@ Jump=1
16801723
Repository=HSR_Master.csv
16811724
DirRepo=HFR_Master.csv
16821725
SearchMode=web
1726+
CustomTxtSize=0
1727+
TxtSize=9
16831728
)", "HS_Settings.ini"
16841729
}
16851730

@@ -1797,14 +1842,14 @@ SetMonitorBounds(guiH, guiW)
17971842
MonitorGetWorkArea ActiveMon, &mwaLeft, &mwaTop, &mwaRight, &mwaBottom
17981843

17991844
; add multiplication factor to adjust for monitor resolution
1800-
adj := A_ScreenDPI/96
1801-
xAdj:=(guiW/2)*adj
1802-
yAdj:=(guiH/2)*adj
1845+
global DPIadj := A_ScreenDPI/96
1846+
xAdj:=(guiW/2)*DPIadj
1847+
yAdj:=(guiH/2)*DPIadj
18031848
xPos:=mouseX - xAdj
18041849
yPos:=mouseY - yAdj
1805-
buff := 15*adj
1806-
Final_x := jump==1 ? max(mwaLeft, min(xPos, mwaRight-(guiW*adj))) : ((((mwaRight - mwaLeft) / 2) + mwaLeft)-xAdj)
1807-
Final_y := jump==1 ? max(mwaTop, min(yPos, mwaBottom-buff-(guiH*adj))) : ((((mwaBottom - mwaTop) / 2) + mwaTop)-yAdj)
1850+
buff := 15*DPIadj
1851+
Final_x := jump==1 ? max(mwaLeft, min(xPos, mwaRight-(guiW*DPIadj))) : ((((mwaRight - mwaLeft) / 2) + mwaLeft)-xAdj)
1852+
Final_y := jump==1 ? max(mwaTop, min(yPos, mwaBottom-buff-(guiH*DPIadj))) : ((((mwaBottom - mwaTop) / 2) + mwaTop)-yAdj)
18081853
return [Final_x, Final_y]
18091854
}
18101855

0 commit comments

Comments
 (0)