-
Notifications
You must be signed in to change notification settings - Fork 71
/
ReplaceSystemVariables.ahk
180 lines (176 loc) · 13.5 KB
/
ReplaceSystemVariables.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
ReplaceSystemVariables(ByRef fnText)
{
; replace an occurence of a system variable read from a .ini file with the contents of the variable
; MsgBox fnText: %fnText%
Global USERPROFILE
fnText := StrReplace(fnText,"%A_AhkPath%" ,A_AhkPath )
fnText := StrReplace(fnText,"%A_AhkVersion%" ,A_AhkVersion )
fnText := StrReplace(fnText,"%A_AppData%" ,A_AppData )
fnText := StrReplace(fnText,"%A_AppDataCommon%" ,A_AppDataCommon )
fnText := StrReplace(fnText,"%A_AutoTrim%" ,A_AutoTrim )
fnText := StrReplace(fnText,"%A_BatchLines%" ,A_BatchLines )
fnText := StrReplace(fnText,"%A_CaretX%" ,A_CaretX )
fnText := StrReplace(fnText,"%A_CaretY%" ,A_CaretY )
fnText := StrReplace(fnText,"%A_ComputerName%" ,A_ComputerName )
fnText := StrReplace(fnText,"%A_ControlDelay%" ,A_ControlDelay )
fnText := StrReplace(fnText,"%A_CoordModeCaret%" ,A_CoordModeCaret )
fnText := StrReplace(fnText,"%A_CoordModeMenu%" ,A_CoordModeMenu )
fnText := StrReplace(fnText,"%A_CoordModeMouse%" ,A_CoordModeMouse )
fnText := StrReplace(fnText,"%A_CoordModePixel%" ,A_CoordModePixel )
fnText := StrReplace(fnText,"%A_CoordModeToolTip%" ,A_CoordModeToolTip )
fnText := StrReplace(fnText,"%A_Cursor%" ,A_Cursor )
fnText := StrReplace(fnText,"%A_DD%" ,A_DD )
fnText := StrReplace(fnText,"%A_DDD%" ,A_DDD )
fnText := StrReplace(fnText,"%A_DDDD%" ,A_DDDD )
fnText := StrReplace(fnText,"%A_DefaultGui%" ,A_DefaultGui )
fnText := StrReplace(fnText,"%A_DefaultListView%" ,A_DefaultListView )
fnText := StrReplace(fnText,"%A_DefaultMouseSpeed%" ,A_DefaultMouseSpeed )
fnText := StrReplace(fnText,"%A_DefaultTreeView%" ,A_DefaultTreeView )
fnText := StrReplace(fnText,"%A_Desktop%" ,A_Desktop )
fnText := StrReplace(fnText,"%A_DesktopCommon%" ,A_DesktopCommon )
fnText := StrReplace(fnText,"%A_DetectHiddenText%" ,A_DetectHiddenText )
fnText := StrReplace(fnText,"%A_DetectHiddenWindows%" ,A_DetectHiddenWindows )
fnText := StrReplace(fnText,"%A_EndChar%" ,A_EndChar )
fnText := StrReplace(fnText,"%A_EventInfo%" ,A_EventInfo )
fnText := StrReplace(fnText,"%A_ExitReason%" ,A_ExitReason )
fnText := StrReplace(fnText,"%A_FileEncoding%" ,A_FileEncoding )
fnText := StrReplace(fnText,"%A_FormatFloat%" ,A_FormatFloat )
fnText := StrReplace(fnText,"%A_FormatInteger%" ,A_FormatInteger )
fnText := StrReplace(fnText,"%A_Gui%" ,A_Gui )
fnText := StrReplace(fnText,"%A_GuiControl%" ,A_GuiControl )
fnText := StrReplace(fnText,"%A_GuiEvent%" ,A_GuiEvent )
fnText := StrReplace(fnText,"%A_GuiHeight%" ,A_GuiHeight )
fnText := StrReplace(fnText,"%A_GuiWidth%" ,A_GuiWidth )
fnText := StrReplace(fnText,"%A_GuiX%" ,A_GuiX )
fnText := StrReplace(fnText,"%A_GuiY%" ,A_GuiY )
fnText := StrReplace(fnText,"%A_Hour%" ,A_Hour )
fnText := StrReplace(fnText,"%A_IconFile%" ,A_IconFile )
fnText := StrReplace(fnText,"%A_IconHidden%" ,A_IconHidden )
fnText := StrReplace(fnText,"%A_IconNumber%" ,A_IconNumber )
fnText := StrReplace(fnText,"%A_IconTip%" ,A_IconTip )
fnText := StrReplace(fnText,"%A_IPAddress1%" ,A_IPAddress1 )
fnText := StrReplace(fnText,"%A_IPAddress2%" ,A_IPAddress2 )
fnText := StrReplace(fnText,"%A_IPAddress3%" ,A_IPAddress3 )
fnText := StrReplace(fnText,"%A_IPAddress4%" ,A_IPAddress4 )
fnText := StrReplace(fnText,"%A_Is64bitOS%" ,A_Is64bitOS )
fnText := StrReplace(fnText,"%A_IsAdmin%" ,A_IsAdmin )
fnText := StrReplace(fnText,"%A_IsCompiled%" ,A_IsCompiled )
fnText := StrReplace(fnText,"%A_IsCritical%" ,A_IsCritical )
fnText := StrReplace(fnText,"%A_IsPaused%" ,A_IsPaused )
fnText := StrReplace(fnText,"%A_IsSuspended%" ,A_IsSuspended )
fnText := StrReplace(fnText,"%A_IsUnicode%" ,A_IsUnicode )
fnText := StrReplace(fnText,"%A_KeyDelay%" ,A_KeyDelay )
fnText := StrReplace(fnText,"%A_KeyDelayPlay%" ,A_KeyDelayPlay )
fnText := StrReplace(fnText,"%A_KeyDuration%" ,A_KeyDuration )
fnText := StrReplace(fnText,"%A_KeyDurationPlay%" ,A_KeyDurationPlay )
fnText := StrReplace(fnText,"%A_Language%" ,A_Language )
fnText := StrReplace(fnText,"%A_LastError%" ,A_LastError )
fnText := StrReplace(fnText,"%A_LineFile%" ,A_LineFile )
fnText := StrReplace(fnText,"%A_LineNumber%" ,A_LineNumber )
fnText := StrReplace(fnText,"%A_Min%" ,A_Min )
fnText := StrReplace(fnText,"%A_MM%" ,A_MM )
fnText := StrReplace(fnText,"%A_MMM%" ,A_MMM )
fnText := StrReplace(fnText,"%A_MMMM%" ,A_MMMM )
fnText := StrReplace(fnText,"%A_MouseDelay%" ,A_MouseDelay )
fnText := StrReplace(fnText,"%A_MouseDelayPlay%" ,A_MouseDelayPlay )
fnText := StrReplace(fnText,"%A_MSec%" ,A_MSec )
fnText := StrReplace(fnText,"%A_MyDocuments%" ,A_MyDocuments )
fnText := StrReplace(fnText,"%A_Now%" ,A_Now )
fnText := StrReplace(fnText,"%A_NowUTC%" ,A_NowUTC )
fnText := StrReplace(fnText,"%A_OSType%" ,A_OSType )
fnText := StrReplace(fnText,"%A_OSVersion%" ,A_OSVersion )
fnText := StrReplace(fnText,"%A_PriorHotkey%" ,A_PriorHotkey )
fnText := StrReplace(fnText,"%A_PriorKey%" ,A_PriorKey )
fnText := StrReplace(fnText,"%A_ProgramFiles%" ,A_ProgramFiles )
fnText := StrReplace(fnText,"%A_Programs%" ,A_Programs )
fnText := StrReplace(fnText,"%A_ProgramsCommon%" ,A_ProgramsCommon )
fnText := StrReplace(fnText,"%A_PtrSize%" ,A_PtrSize )
fnText := StrReplace(fnText,"%A_RegView%" ,A_RegView )
fnText := StrReplace(fnText,"%A_ScreenDPI%" ,A_ScreenDPI )
fnText := StrReplace(fnText,"%A_ScreenHeight%" ,A_ScreenHeight )
fnText := StrReplace(fnText,"%A_ScreenWidth%" ,A_ScreenWidth )
fnText := StrReplace(fnText,"%A_ScriptDir%" ,A_ScriptDir )
fnText := StrReplace(fnText,"%A_ScriptFullPath%" ,A_ScriptFullPath )
fnText := StrReplace(fnText,"%A_ScriptHwnd%" ,A_ScriptHwnd )
fnText := StrReplace(fnText,"%A_ScriptName%" ,A_ScriptName )
fnText := StrReplace(fnText,"%A_Sec%" ,A_Sec )
fnText := StrReplace(fnText,"%A_SendLevel%" ,A_SendLevel )
fnText := StrReplace(fnText,"%A_SendMode%" ,A_SendMode )
fnText := StrReplace(fnText,"%A_StartMenu%" ,A_StartMenu )
fnText := StrReplace(fnText,"%A_StartMenuCommon%" ,A_StartMenuCommon )
fnText := StrReplace(fnText,"%A_Startup%" ,A_Startup )
fnText := StrReplace(fnText,"%A_StartupCommon%" ,A_StartupCommon )
fnText := StrReplace(fnText,"%A_StoreCapslockMode%" ,A_StoreCapslockMode )
fnText := StrReplace(fnText,"%A_StringCaseSense%" ,A_StringCaseSense )
fnText := StrReplace(fnText,"%A_Temp%" ,A_Temp )
fnText := StrReplace(fnText,"%A_ThisFunc%" ,A_ThisFunc )
fnText := StrReplace(fnText,"%A_ThisHotkey%" ,A_ThisHotkey )
fnText := StrReplace(fnText,"%A_ThisLabel%" ,A_ThisLabel )
fnText := StrReplace(fnText,"%A_ThisMenu%" ,A_ThisMenu )
fnText := StrReplace(fnText,"%A_ThisMenuItem%" ,A_ThisMenuItem )
fnText := StrReplace(fnText,"%A_ThisMenuItemPos%" ,A_ThisMenuItemPos )
fnText := StrReplace(fnText,"%A_TickCount%" ,A_TickCount )
fnText := StrReplace(fnText,"%A_TimeIdle%" ,A_TimeIdle )
fnText := StrReplace(fnText,"%A_TimeIdlePhysical%" ,A_TimeIdlePhysical )
fnText := StrReplace(fnText,"%A_TimeSincePriorHotkey%" ,A_TimeSincePriorHotkey)
fnText := StrReplace(fnText,"%A_TimeSinceThisHotkey%" ,A_TimeSinceThisHotkey )
fnText := StrReplace(fnText,"%A_TitleMatchMode%" ,A_TitleMatchMode )
fnText := StrReplace(fnText,"%A_TitleMatchModeSpeed%" ,A_TitleMatchModeSpeed )
fnText := StrReplace(fnText,"%A_UserName%" ,A_UserName )
fnText := StrReplace(fnText,"%A_WDay%" ,A_WDay )
fnText := StrReplace(fnText,"%A_WinDelay%" ,A_WinDelay )
fnText := StrReplace(fnText,"%A_WinDir%" ,A_WinDir )
fnText := StrReplace(fnText,"%A_WorkingDir%" ,A_WorkingDir )
fnText := StrReplace(fnText,"%A_YDay%" ,A_YDay )
fnText := StrReplace(fnText,"%A_YWeek%" ,A_YWeek )
fnText := StrReplace(fnText,"%A_YYYY%" ,A_YYYY )
fnText := StrReplace(fnText,"%Clipboard%" ,Clipboard )
fnText := StrReplace(fnText,"%ClipboardAll%" ,ClipboardAll )
fnText := StrReplace(fnText,"%ALLUSERSPROFILE%" ,ALLUSERSPROFILE )
fnText := StrReplace(fnText,"%APPDATA%" ,APPDATA )
fnText := StrReplace(fnText,"%COMMONPROGRAMFILES%" ,COMMONPROGRAMFILES )
fnText := StrReplace(fnText,"%COMMONPROGRAMFILESX86%" ,COMMONPROGRAMFILESX86 )
fnText := StrReplace(fnText,"%COMMONPROGRAMW6432%" ,COMMONPROGRAMW6432 )
fnText := StrReplace(fnText,"%COMPUTERNAME%" ,COMPUTERNAME )
fnText := StrReplace(fnText,"%COMSPEC%" ,COMSPEC )
fnText := StrReplace(fnText,"%FP_NO_HOST_CHECK%" ,FP_NO_HOST_CHECK )
fnText := StrReplace(fnText,"%HOMEDRIVE%" ,HOMEDRIVE )
fnText := StrReplace(fnText,"%HOMEPATH%" ,HOMEPATH )
fnText := StrReplace(fnText,"%LOCALAPPDATA%" ,LOCALAPPDATA )
fnText := StrReplace(fnText,"%LOGONSERVER%" ,LOGONSERVER )
fnText := StrReplace(fnText,"%NUMBER_OF_PROCESSORS%" ,NUMBER_OF_PROCESSORS )
fnText := StrReplace(fnText,"%OS%" ,OS )
fnText := StrReplace(fnText,"%PATH%" ,PATH )
fnText := StrReplace(fnText,"%PATHEXT%" ,PATHEXT )
fnText := StrReplace(fnText,"%PCBRAND%" ,PCBRAND )
fnText := StrReplace(fnText,"%PLATFORM%" ,PLATFORM )
fnText := StrReplace(fnText,"%PROCESSOR_ARCHITECTURE%" ,PROCESSOR_ARCHITECTURE)
fnText := StrReplace(fnText,"%PROCESSOR_IDENTIFIER%" ,PROCESSOR_IDENTIFIER )
fnText := StrReplace(fnText,"%PROCESSOR_LEVEL%" ,PROCESSOR_LEVEL )
fnText := StrReplace(fnText,"%PROCESSOR_REVISION%" ,PROCESSOR_REVISION )
fnText := StrReplace(fnText,"%PROGRAMDATA%" ,PROGRAMDATA )
fnText := StrReplace(fnText,"%PROGRAMFILES%" ,PROGRAMFILES )
fnText := StrReplace(fnText,"%PROGRAMFILESX86%" ,PROGRAMFILESX86 )
fnText := StrReplace(fnText,"%PROGRAMW6432%" ,PROGRAMW6432 )
fnText := StrReplace(fnText,"%PROMPT%" ,PROMPT )
fnText := StrReplace(fnText,"%PSMODULEPATH%" ,PSMODULEPATH )
fnText := StrReplace(fnText,"%PUBLIC%" ,PUBLIC )
fnText := StrReplace(fnText,"%SESSIONNAME%" ,SESSIONNAME )
fnText := StrReplace(fnText,"%SYSTEMDRIVE%" ,SYSTEMDRIVE )
fnText := StrReplace(fnText,"%SYSTEMROOT%" ,SYSTEMROOT )
fnText := StrReplace(fnText,"%TEMP%" ,TEMP )
fnText := StrReplace(fnText,"%TMP%" ,TMP )
fnText := StrReplace(fnText,"%USERDOMAIN%" ,USERDOMAIN )
fnText := StrReplace(fnText,"%USERNAME%" ,USERNAME )
fnText := StrReplace(fnText,"%USERPROFILE%" ,USERPROFILE )
fnText := StrReplace(fnText,"%VS110COMNTOOLS%" ,VS110COMNTOOLS )
fnText := StrReplace(fnText,"%VS120COMNTOOLS%" ,VS120COMNTOOLS )
fnText := StrReplace(fnText,"%WINDIR%" ,WINDIR )
; MsgBox fnText:`n%fnText%
Return fnText
}
/* ; testing
SomeString := "abc %A_YYYY% def"
ReturnValue := ReplaceSystemVariables(SomeString)
MsgBox, ReplaceSystemVariables`n`nReturnValue: %ReturnValue%`n`nSomeString: %SomeString%
*/