generated from Nigh/ahk-autoupdate-template
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
ahko.ahk
122 lines (112 loc) · 2.61 KB
/
ahko.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#SingleInstance Ignore
SetWorkingDir A_ScriptDir
Persistent
path:=IniRead("setting.ini", "dir", "path", "")
hotkeys:=IniRead("setting.ini", "hotkey", "key", "!q")
fullscreen_enable:=IniRead("setting.ini", "hotkey", "fullscreen", "0")
uiType_list:="1|2|3"
uiType:=IniRead("setting.ini", "ui", "type", "1")
if not RegExMatch(uiType, uiType_list)
{
uiType := "1"
}
; 0 = primary monitor
; 1~9 = specific monitor
; 10 = monitor the mouse at
; 11 = monitor the activate window at
showat_list:="0|1|2|3|4|5|6|7|8|9|10|11"
showat:=IniRead("setting.ini", "settings", "showat", "10")
if not RegExMatch(showat, showat_list)
{
showat := "10"
}
#include isFullScreen.ahk
#include ahko_setup_gui.ahk
customTrayMenu:={valid:true}
customTrayMenu.menu:=[]
customTrayMenu.menu.push({name:"Setup",func:ahko_setup_show})
setupWatchFolder(*)
{
newpath:=RegExReplace(DirSelect(,0), "\\$")
if(newpath!="") {
IniWrite("path=" newpath,"setting.ini", "dir")
Reload
}
}
if(!DirExist(path)) {
ahko_setup_show()
Return
}
TrayTip "ahko start at " path, "ahko", 0x14
ahko := []
ahko_init(&ahko, path)
{
Loop files path "\*", "FD"
{
ahko.Push({name:filenameWithoutExt(A_LoopFileName),attrib:A_LoopFileAttrib,path:A_LoopFileFullPath,sub:[],icon:""})
if(InStr(A_LoopFileAttrib,"D")){
local icon_map:=Map()
local target_count:=0
Loop files A_LoopFileFullPath "\*", "FD"
{
if(A_LoopFileName == "_icon.png") {
ahko[-1].icon := A_LoopFileFullPath
Continue
}
if(RegExMatch(A_LoopFileName,"(.+)\.png$",&iconFileName)) {
icon_map.set(iconFileName[1], A_LoopFileFullPath)
Continue
}
if(target_count >= 16){
Continue
}
ahko[-1].sub.Push({name:filenameWithoutExt(A_LoopFileName),attrib:A_LoopFileAttrib,path:A_LoopFileFullPath,icon:""})
target_count+=1
}
for k,v in ahko[-1].sub
{
if(icon_map.Has(v.name)){
v.icon := icon_map.Get(v.name)
}
}
}
if(A_Index >= 16){
Break
}
}
}
ahko_init(&ahko, path)
filenameWithoutExt(name)
{
SplitPath(name,,,,&outname)
Return outname
}
fileGethIcon(file)
{
fileinfo := Buffer(fisize := A_PtrSize + 688)
; Get the file's icon.
if DllCall("shell32\SHGetFileInfoW", "WStr", file
, "UInt", 0, "Ptr", fileinfo, "UInt", fisize, "UInt", 0x100)
{
hicon := NumGet(fileinfo, 0, "Ptr")
Return "HICON:" hicon
}
Return
}
isNotFullScreen(*)
{
Return not isFullScreen()
}
#Include ahko_ui.ahk
ahko_ui_init()
; TODO: if hotkey invalid, then reset the hotkey to default
if(fullscreen_enable)
{
Hotkey hotkeys, ahko_show, "On"
} else {
Hotif isNotFullScreen
Hotkey hotkeys, ahko_show, "On"
Hotif
}
; ahko_show()
; ahko_setup_show()