PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 1ms

/Lib/Functions.ahk

http://7plus.googlecode.com/
AutoHotKey | 262 lines | 243 code | 3 blank | 16 comment | 3 complexity | 91e93c11d987beb49dd00dad87040bdb MD5 | raw file
  1/*
  2	Title: Command Functions
  3		A wrapper set of functions for commands which have an output variable.
  4
  5
  6
  7
  8	License: http://www.autohotkey.net/~Titan/license.txt
  9*/
 10
 11Functions() {
 12	Return, true
 13}
 14
 15IfBetween(ByRef var, LowerBound, UpperBound) {
 16	If var between %LowerBound% and %UpperBound%
 17		Return, true
 18}
 19IfNotBetween(ByRef var, LowerBound, UpperBound) {
 20	If var not between %LowerBound% and %UpperBound%
 21		Return, true
 22}
 23IfIn(ByRef var, MatchList) {
 24	If var in %MatchList%
 25		Return, true
 26}
 27IfNotIn(ByRef var, MatchList) {
 28	If var not in %MatchList%
 29		Return, true
 30}
 31IfContains(ByRef var, MatchList) {
 32	If var contains %MatchList%
 33		Return, true
 34}
 35IfNotContains(ByRef var, MatchList) {
 36	If var not contains %MatchList%
 37		Return, true
 38}
 39IfIs(ByRef var, type) {
 40	If var is %type%
 41		Return, true
 42}
 43IfIsNot(ByRef var, type) {
 44	If var is not %type%
 45		Return, true
 46}
 47
 48ControlGet(Cmd, Value = "", Control = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
 49	ControlGet, v, %Cmd%, %Value%, %Control%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
 50	Return, v
 51}
 52ControlGetFocus(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
 53	ControlGetFocus, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
 54	Return, v
 55}
 56ControlGetText(Control = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
 57	ControlGetText, v, %Control%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
 58	Return, v
 59}
 60DriveGet(Cmd, Value = "") {
 61	DriveGet, v, %Cmd%, %Value%
 62	Return, v
 63}
 64DriveSpaceFree(Path) {
 65	DriveSpaceFree, v, %Path%
 66	Return, v
 67}
 68EnvGet(EnvVarName) {
 69	EnvGet, v, %EnvVarName%
 70	Return, v
 71}
 72FileGetAttrib(Filename = "") {
 73	FileGetAttrib, v, %Filename%
 74	Return, v
 75}
 76FileGetShortcut(LinkFile, ByRef OutTarget = "", ByRef OutDir = "", ByRef OutArgs = "", ByRef OutDescription = "", ByRef OutIcon = "", ByRef OutIconNum = "", ByRef OutRunState = "") {
 77	FileGetShortcut, %LinkFile%, OutTarget, OutDir, OutArgs, OutDescription, OutIcon, OutIconNum, OutRunState
 78}
 79FileGetSize(Filename = "", Units = "") {
 80	FileGetSize, v, %Filename%, %Units%
 81	Return, v
 82}
 83FileGetTime(Filename = "", WhichTime = "") {
 84	FileGetTime, v, %Filename%, %WhichTime%
 85	Return, v
 86}
 87FileGetVersion(Filename = "") {
 88	FileGetVersion, v, %Filename%
 89	Return, v
 90}
 91FileRead(Filename) {
 92	FileRead, v, %Filename%
 93	Return, v
 94}
 95FileReadLine(Filename, LineNum) {
 96	FileReadLine, v, %Filename%, %LineNum%
 97	Return, v
 98}
 99FileSelectFile(Options = "", RootDir = "", Prompt = "", Filter = "") {
100	FileSelectFile, v, %Options%, %RootDir%, %Prompt%, %Filter%
101	Return, v
102}
103FileSelectFolder(StartingFolder = "", Options = "", Prompt = "") {
104	FileSelectFolder, v, %StartingFolder%, %Options%, %Prompt%
105	Return, v
106}
107FormatTime(YYYYMMDDHH24MISS = "", Format = "") {
108	FormatTime, v, %YYYYMMDDHH24MISS%, %Format%
109	Return, v
110}
111GuiControlGet(Subcommand = "", ControlID = "", Param4 = "") {
112	GuiControlGet, v, %Subcommand%, %ControlID%, %Param4%
113	Return, v
114}
115ImageSearch(ByRef OutputVarX, ByRef OutputVarY, X1, Y1, X2, Y2, ImageFile) {
116	ImageSearch, OutputVarX, OutputVarY, %X1%, %Y1%, %X2%, %Y2%, %ImageFile%
117}
118IniRead(Filename, Section, Key, Default = "") {
119	IniRead, v, %Filename%, %Section%, %Key%, %Default%
120	Return, v
121}
122IniWrite(Value, Filename, Section, Key)
123{
124	IniWrite, %Value%, %Filename%, %Section%, %Key%
125}
126/*
127Input(Options = "", EndKeys = "", MatchList = "") {
128	Input, v, %Options%, %EndKeys%, %MatchList%
129	Return, v
130}
131*/
132InputBox(Title = "", Prompt = "", HIDE = "", Width = "", Height = "", X = "", Y = "", Font = "", Timeout = "", Default = "") {
133	InputBox, v, %Title%, %Prompt%, %HIDE%, %Width%, %Height%, %X%, %Y%, , %Timeout%, %Default%
134	Return, v
135}
136MouseGetPos(ByRef OutputVarX = "", ByRef OutputVarY = "", ByRef OutputVarWin = "", ByRef OutputVarControl = "", Mode = "") {
137	MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, %Mode%
138}
139PixelGetColor(X, Y, RGB = "") {
140	PixelGetColor, v, %X%, %Y%, %RGB%
141	Return, v
142}
143PixelSearch(ByRef OutputVarX, ByRef OutputVarY, X1, Y1, X2, Y2, ColorID, Variation = "", Mode = "") {
144	PixelSearch, OutputVarX, OutputVarY, %X1%, %Y1%, %X2%, %Y2%, %ColorID%, %Variation%, %Mode%
145}
146Random(Min = "", Max = "") {
147	Random, v, %Min%, %Max%
148	Return, v
149}
150RegRead(RootKey, SubKey, ValueName = "") {
151	RegRead, v, %RootKey%, %SubKey%, %ValueName%
152	Return, v
153}
154RunWait(Target, WorkingDir = "", Mode = "") {
155	RunWait, %Target%, %WorkingDir%, %Mode%, v
156	Return v
157}
158SoundGet(ComponentType = "", ControlType = "", DeviceNumber = "") {
159	SoundGet, v, %ComponentType%, %ControlType%, %DeviceNumber%
160	Return, v
161}
162SoundGetWaveVolume(DeviceNumber = "") {
163	SoundGetWaveVolume, v, %DeviceNumber%
164	Return, v
165}
166StatusBarGetText(Part = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
167	StatusBarGetText, v, %Part%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
168	Return, v
169}
170SplitPath(ByRef InputVar, ByRef OutFileName = "", ByRef OutDir = "", ByRef OutExtension = "", ByRef OutNameNoExt = "", ByRef OutDrive = "") {
171	SplitPath, InputVar, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
172}
173StringGetPos(ByRef InputVar, SearchText, Mode = "", Offset = "") {
174	StringGetPos, v, InputVar, %SearchText%, %Mode%, %Offset%
175	Return, v
176}
177StringLeft(ByRef InputVar, Count) {
178	StringLeft, v, InputVar, %Count%
179	Return, v
180}
181StringLen(ByRef InputVar) {
182	StringLen, v, InputVar
183	Return, v
184}
185StringLower(ByRef InputVar, T = "") {
186	StringLower, v, InputVar, %T%
187	Return, v
188}
189StringMid(ByRef InputVar, StartChar, Count , L = "") {
190	StringMid, v, InputVar, %StartChar%, %Count%, %L%
191	Return, v
192}
193StringReplace(InputVar, SearchText, ReplaceText = "", All = "") {
194	StringReplace, v, InputVar, %SearchText%, %ReplaceText%, %All%
195	Return, v
196}
197StringRight(ByRef InputVar, Count) {
198	StringRight, v, InputVar, %Count%
199	Return, v
200}
201StringTrimLeft(ByRef InputVar, Count) {
202	StringTrimLeft, v, InputVar, %Count%
203	Return, v
204}
205StringTrimRight(ByRef InputVar, Count) {
206	StringTrimRight, v, InputVar, %Count%
207	Return, v
208}
209StringUpper(ByRef InputVar, T = "") {
210	StringUpper, v, InputVar, %T%
211	Return, v
212}
213SysGet(Subcommand, Param3 = "") {
214	SysGet, v, %Subcommand%, %Param3%
215	Return, v
216}
217Transform(Cmd, Value1, Value2 = "") {
218	Transform, v, %Cmd%, %Value1%, %Value2%
219	Return, v
220}
221WinGet(Cmd = "", WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
222	WinGet, v, %Cmd%, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
223	Return, v
224}
225WinGetActiveTitle() {
226	WinGetActiveTitle, v
227	Return, v
228}
229WinGetClass(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
230	WinGetClass, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
231	Return, v
232}
233WinGetText(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
234	WinGetText, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
235	Return, v
236}
237WinGetTitle(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
238	WinGetTitle, v, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
239	Return, v
240}
241WinMaximize(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
242	WinGet, style, style, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
243	if(style & 0x10000)
244		WinMaximize, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
245}
246WinMinimize(WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
247	WinGet, style, style, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
248	outputdebug % "style " style " minimize " style & 0x20000
249	if(style & 0x20000)
250		WinMinimize, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
251}
252;System modal messagebox (Options can't be considered due to msgbox parsing
253MsgBox2(Title, Text, Timeout="")
254{	
255	if(title = "")
256		title := "7plus"
257	Msgbox, 0x1000, %Title%, %Text%, %Timeout%
258}
259MsgBox(Text)
260{
261	MsgBox, %Text%
262}