-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathHelperFunctions.ahk
138 lines (124 loc) · 3.52 KB
/
HelperFunctions.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
; ==============================================================================
; ==============================================================================
; HotKeyFormat(input)
; Formats readable hotkeystring to AHK Send format
; ==============================================================================
; ==============================================================================
HotKeyFormat(input)
{
StringLower, tempstr, input
shift:=False
control:=False
alt:=False
ifinstring, tempstr, shift-
{
shift:=True
StringReplace, tempstr, tempstr, shift-, , All
}
ifinstring, tempstr, ctrl-
{
control:=True
StringReplace, tempstr, tempstr, ctrl-, , All
}
ifinstring, tempstr, alt-
{
alt:=True
StringReplace, tempstr, tempstr, alt-, , All
}
ifinstring, tempstr, win-
{
lwin:=True
StringReplace, tempstr, tempstr, win-, , All
}
output:= Trim(tempstr)
if shift
{
output:="+" output
}
if Control
{
output:="^" output
}
if Alt
{
output:="!" output
}
if lWin
{
output:="#" output
}
output:= Trim(output)
return output
}
; ==============================================================================
; ==============================================================================
; IsInsideVisibleArea(x,y,w,h)
; Checks if the coordinates are inside the visible area
; ==============================================================================
; ==============================================================================
IsInsideVisibleArea(x,y,w,h)
{
isVis:=0
SysGet, MonitorCount, MonitorCount
Loop, %MonitorCount%
{
SysGet, Monitor%A_Index%, MonitorWorkArea, %A_Index%
if (x+w-10>Monitor%A_Index%Left) and (x+10<Monitor%A_Index%Right) and (y+20>Monitor%A_Index%Top) and (y+20<Monitor%A_Index%Bottom)
isVis:=1
}
return, IsVis
}
; ==============================================================================
; ==============================================================================
; LogLine(TxtLn,LogFile="Default")
; makes buffered write of TxtLn to LogFile
;
; LogWrite()
; writes log-buffer to disk; called via timer by LogLine or manually to flush
; buffer
; ==============================================================================
; ==============================================================================
LogLine(TxtLn,LogFile="Default")
{
global LogWriteBuffer
FormatTime, TimeStr,, HH:mm:ss
LogWriteBuffer[LogFile].= TimeStr "::" A_MSec ": " TxtLn "`n"
If !LogWriteBuffer["Timer"]
{
LogWriteBuffer["Timer"]:=1
SetTimer, LogWrite, -3000
}
}
LogWrite()
{
global LogWriteBuffer
for LogFile, LogStr in LogWriteBuffer
{
If (LogFile="Default")
{
FileAppend, %LogStr%, % LogWriteBuffer["DefaultLogFile"]
LogWriteBuffer["Default"]:=""
}
else
If (LogFile="Timer")
{
}
else
If (LogFile<>"DefaultLogFile" and LogStr<>"")
{
FileAppend, %LogStr%, %LogFile%
LogWriteBuffer[LogFile]:=""
}
}
LogWriteBuffer["Timer"]:=0
}
; ==============================================================================
; ==============================================================================
; MsgBox(Text,Title="",Options=0,Timeout=0)
; Wrapper for msgbox command
; ==============================================================================
; ==============================================================================
MsgBox(Text,Title="",Options=0,Timeout=0)
{
MsgBox, % Options, %Title%, %Text%, %Timeout%
}