Warning, /frameworks/syntax-highlighting/autotests/folding/highlight.ahk.fold is written in an unsupported language. File is not indexed.
0001 ^j:: ; hotkey label 0002 ::ftw::Free the whales ; hotstring label abbreviation 0003 ::btw:: ; hotstring label action 0004 MsgBox, You typed btw. 0005 Run, notepad.exe ; Run Notepad when you press CTRL+N. 0006 MsgBox, Wow! 0007 MsgBox, There are 0008 Run, notepad.exe 0009 WinActivate, Untitled - Notepad 0010 WinWaitActive, Untitled - Notepad 0011 Send, 7 lines{!}{Enter} 0012 SendInput, inside the CTRL{+}J hotkey. 0013 return 0014 0015 Numpad0 & Numpad1:: 0016 MsgBox, You pressed Numpad1 while holding down Numpad0. 0017 Run, notepad.exe 0018 return 0019 0020 ; Untitled - Notepad 0021 #IfWinActive Untitled - Notepad 0022 !q:: 0023 MsgBox, You pressed ALT+Q in Notepad. 0024 return 0025 0026 ; Any window that isn't Untitled - Notepad 0027 #IfWinActive 0028 !q:: 0029 MsgBox, You pressed ALT+Q in any window. 0030 return 0031 0032 ; Retrieve the ID/HWND of the active window 0033 id := WinExist("A") 0034 MsgBox % id 0035 0036 ; Press Win+↑ to maximize the active window 0037 #Up::WinMaximize, A 0038 0039 #i:: 0040 Run, https://www.google.com/ 0041 return 0042 0043 ^p:: 0044 Run, notepad.exe 0045 return 0046 0047 ~j:: 0048 Send, ack 0049 return 0050 0051 :*:acheiv::achiev 0052 ::achievment::achievement 0053 ::acquaintence::acquaintance 0054 :*:adquir::acquir 0055 ::aquisition::acquisition 0056 :*:agravat::aggravat 0057 :*:allign::align 0058 ::ameria::America 0059 :*:ftw::Free the whales ; Hotstring modifiers 0060 this_is_a_label: ; label 0061 0062 #IfWinActive Untitled - Notepad 0063 #Space:: 0064 MsgBox, You pressed WIN+SPACE in Notepad. 0065 return 0066 0067 Send, {Ctrl down}c{Ctrl up} 0068 SendInput, [b]{Ctrl down}v{Ctrl up}[/b] 0069 return ; This ends the hotkey. The code below this point will not get triggered. 0070 0071 Send, This text has been typed{!} 0072 Send, {a} ; WRONG 0073 Send, {a}{b}{c} ; WRONG 0074 Send, {abc} ; WRONG 0075 Send, abc ; CORRECT 0076 Send, ^s ; Both of these send CTRL+S 0077 Send, {Ctrl down}s{Ctrl up} ; Both of these send CTRL+S 0078 Send, {Ctrl down}c{Ctrl up} 0079 Send, {b down}{b up} 0080 Send, {Tab down}{Tab up} 0081 Send, {Up down} ; Press down the up-arrow key. 0082 Sleep, 1000 ; Keep it down for one second. 0083 Send, {Up up} ; Release the up-arrow key. 0084 0085 Send, 0086 <beginfold id='1'>(</beginfold id='1'> 0087 Line 1 0088 Line 2 0089 Apples are a fruit. 0090 <endfold id='1'>)</endfold id='1'> 0091 0092 Send %A_Hour% 0093 SubStr(37 * 12, 1, 2) 0094 SubStr(A_Hour - 12, 2) 0095 SubStr(A_AhkPath, InStr(A_AhkPath, "AutoHotkey")) 0096 SubStr("I'm scripting, awesome!", 16) 0097 0098 SetTitleMatchMode RegEx 0099 WinActivate ahk_exe i)\\notepad\.exe$ ; Match the name part of the full path. 0100 WinActivate ahk_exe im)(*BSR_ANYCRLF)abc\Rxyz 0101 WinActivate ahk_exe im)(*BSR_ANY[^]]CRLF)abc\Rxyz 0102 0103 if (MyVar = 5) 0104 <beginfold id='2'>{</beginfold id='2'> 0105 MsgBox, MyVar equals %MyVar%!! 0106 ExitApp 0107 <endfold id='2'>}</endfold id='2'> 0108 0109 MyVar = Text 0110 MyVar = %MyVar2% 0111 MyVar = %MyVar2% some text %MyVar3%. 0112 MyVar := SubStr("I'm scripting, awesome!", 16) 0113 MyVar := "Text" 0114 MyVar := MyVar2 0115 MyVar := 6 + 8 / 3 * 2 - Sqrt(9) 0116 MyVar := "The value of 5 + " MyVar2 " is: " 5 + MyVar2 0117 if (Var1 != Var2) 0118 Var1 := Var2 + 100 0119 0120 ; Some examples showing when to use percents and when not: 0121 Var = Text ; Assign some text to a variable (legacy). 0122 Number := 6 ; Assign a number to a variable (expression). 0123 Var2 = %Var% ; Assign a variable to another (legacy). 0124 Var3 := Var ; Assign a variable to another (expression). 0125 Var4 .= Var ; Append a variable to the end of another (expression). 0126 Var5 += Var ; Add the value of a variable to another (expression). 0127 Var5 -= Var ; Subtract the value of a variable from another (expression). 0128 Var6 := SubStr(Var, 2, 2) ; Variable inside a function. This is always an expression. 0129 Var7 = %Var% Text ; Assigns a variable to another with some extra text (legacy). 0130 Var8 := Var " Text" ; Assigns a variable to another with some extra text (expression). 0131 MsgBox, %Var% ; Variable inside a command. 0132 StringSplit, Var, Var, x ; Variable inside a command that uses InputVar and OutputVar. 0133 if (Number = 6) ; Whenever an IF has parentheses, it'll be an expression. So no percent signs. 0134 if (Var != Number) ; Whenever an IF has parentheses, it'll be an expression. So no percent signs. 0135 if Number = 6 ; Without parentheses, the IF is legacy. However, only variables on the 'right side' need percent signs. 0136 if Var1 < %Var2% ; Without parentheses, the IF is legacy. However, only variables on the 'right side' need percent signs. 0137 0138 MyObject := ["one", "two", "three", 17] 0139 Banana := <beginfold id='2'>{</beginfold id='2'>"Color": "Yellow", "Taste": "Delicious", "Price": 3<endfold id='2'>}</endfold id='2'> 0140 MyObject := Array("one", "two", "three", 17) 0141 Banana := Object("Color", "Yellow", "Taste", "Delicious", "Price", 3) 0142 Banana["Pickled"] := True ; This banana has been pickled. Eww. 0143 Banana.Consistency := "Mushy" 0144 Value := Banana["Color"] 0145 Value := Banana.Color 0146 MyObject["NewerKey"] := 3.1415 0147 MyObject.NewKey := "Shiny" 0148 MyObject.Push(Value1, Value2, Value3...) 0149 Banana.Consistency := "" 0150 RemovedValue := MyObject.Delete(AnyKey) 0151 NumberOfRemovedKeys := MyObject.Delete(FirstKey, LastKey) 0152 arr := [<beginfold id='2'>{</beginfold id='2'><endfold id='2'>}</endfold id='2'>] ; Creates an array containing an object. 0153 arr[1] := <beginfold id='2'>{</beginfold id='2'><endfold id='2'>}</endfold id='2'> ; Creates a second object, implicitly freeing the first object. 0154 arr.RemoveAt(1) ; Removes and frees the second object. 0155 x := <beginfold id='2'>{</beginfold id='2'><endfold id='2'>}</endfold id='2'>, y := <beginfold id='2'>{</beginfold id='2'><endfold id='2'>}</endfold id='2'> ; Create two objects. 0156 x.child := y, y.parent := x ; Create a circular reference. 0157 y.parent := "" 0158 x := "", y := "" 0159 table.base.__Get(table, x)[y] := content ; A 0160 table.base.__Set(table, x, y, content) ; B 0161 RemovedValue := MyObject.RemoveAt(Index) 0162 NumberOfRemovedKeys := MyObject.RemoveAt(Index, Length) 0163 val := obj.Property := 42 0164 m1 := new GMem(0, 20) 0165 m2 := <beginfold id='2'>{</beginfold id='2'>base: GMem<endfold id='2'>}</endfold id='2'>.__New(0, 30) 0166 x ? CallIfTrue() : CallIfFalse() 0167 ProductIsAvailable := (Color = "Red") 0168 ? false ; We don't have any red products, so don't bother calling the function. 0169 : ProductIsAvailableInColor(Product, Color) 0170 MyObject.Pop() 0171 %Var%() 0172 0173 Sleep MillisecondsToWait 0174 Sleep %MillisecondsToWait% 0175 Sleep % MillisecondsToWait 0176 MsgBox % 1+1 ; Shows "2" 0177 MsgBox 1+1 ; Shows "1+1" 0178 0179 MsgBox % "This is text." 0180 MsgBox This is text. 0181 MsgBox % A_AhkVersion 0182 MsgBox %A_AhkVersion% 0183 MsgBox % %A_AhkVersion% 0184 MsgBox % "Hello %A_UserName%." ; Shows "%A_UserName%" 0185 MsgBox Hello %A_UserName%. ; Shows your username. 0186 MsgBox % "Hello " . A_UserName . "." ; Shows your username. 0187 MyVar := "This is text." 0188 MyVar = This is text. 0189 0190 if (Var1 = Var2) 0191 if Var1 = %Var2% 0192 if (Var1 >= Low and Var1 <= High) 0193 if Var1 between %Low% and %High% 0194 0195 Format("{:L}{:U}{:T}", input, input, input) 0196 0197 *#up::MouseMove, 0, -10, 0, R ; Win+UpArrow hotkey => Move cursor upward 0198 *#Down::MouseMove, 0, 10, 0, R ; Win+DownArrow => Move cursor downward 0199 *#Left::MouseMove, -10, 0, 0, R ; Win+LeftArrow => Move cursor to the left 0200 *#Right::MouseMove, 10, 0, 0, R ; Win+RightArrow => Move cursor to the right 0201 0202 *<#RCtrl:: ; LeftWin + RightControl => Left-click (hold down Control/Shift to Control-Click or Shift-Click). 0203 SendEvent {Blind}{LButton down} 0204 KeyWait RCtrl ; Prevents keyboard auto-repeat from repeating the mouse click. 0205 SendEvent {Blind}{LButton up} 0206 return 0207 0208 *<#AppsKey:: ; LeftWin + AppsKey => Right-click 0209 SendEvent {Blind}{RButton down} 0210 KeyWait AppsKey ; Prevents keyboard auto-repeat from repeating the mouse click. 0211 SendEvent {Blind}{RButton up} 0212 return 0213 0214 #Persistent ; Keep this script running until the user explicitly exits it. 0215 SetTimer, WatchPOV, 5 0216 return 0217 0218 WatchPOV: 0219 POV := GetKeyState("JoyPOV") ; Get position of the POV control. 0220 KeyToHoldDownPrev := KeyToHoldDown ; Prev now holds the key that was down before (if any). 0221 0222 ; Some joysticks might have a smooth/continous POV rather than one in fixed increments. 0223 ; To support them all, use a range: 0224 if (POV < 0) ; No angle to report 0225 KeyToHoldDown := "" 0226 else if (POV > 31500) ; 315 to 360 degrees: Forward 0227 KeyToHoldDown := "Up" 0228 else if POV between 0 and 4500 ; 0 to 45 degrees: Forward 0229 KeyToHoldDown := "Up" 0230 else if POV between 4501 and 13500 ; 45 to 135 degrees: Right 0231 KeyToHoldDown := "Right" 0232 else if POV between 13501 and 22500 ; 135 to 225 degrees: Down 0233 KeyToHoldDown := "Down" 0234 else ; 225 to 315 degrees: Left 0235 KeyToHoldDown := "Left" 0236 0237 if (KeyToHoldDown = KeyToHoldDownPrev) ; The correct key is already down (or no key is needed). 0238 return ; Do nothing. 0239 0240 ; Otherwise, release the previous key and press down the new key: 0241 SetKeyDelay -1 ; Avoid delays between keystrokes. 0242 if KeyToHoldDownPrev ; There is a previous key to release. 0243 Send, {%KeyToHoldDownPrev% up} ; Release it. 0244 if KeyToHoldDown ; There is a key to press down. 0245 Send, {%KeyToHoldDown% down} ; Press it down. 0246 return 0247 0248 <^>!m::MsgBox You pressed AltGr+m. 0249 <^<!m::MsgBox You pressed LeftControl+LeftAlt+m. 0250 0251 AppsKey::ToolTip Press < or > to cycle through windows. 0252 AppsKey Up::ToolTip 0253 ~AppsKey & <::Send !+{Esc} 0254 ~AppsKey & >::Send !{Esc} 0255 0256 ; Press AppsKey and Alt in any order, then slash (/). 0257 #if GetKeyState("AppsKey", "P") 0258 Alt & /::MsgBox Hotkey activated. 0259 0260 ; If the keys are swapped, Alt must be pressed first (use one at a time): 0261 #if GetKeyState("Alt", "P") 0262 AppsKey & /::MsgBox Hotkey activated. 0263 0264 ; [ & ] & \:: 0265 #if GetKeyState("[") && GetKeyState("]") 0266 \::MsgBox 0267 0268 ; Ctrl+Shift+O to open containing folder in Explorer. 0269 ; Ctrl+Shift+E to open folder with current file selected. 0270 ; Supports SciTE and Notepad++. 0271 ^+o:: 0272 ^+e:: 0273 editor_open_folder() <beginfold id='2'>{</beginfold id='2'> 0274 WinGetTitle, path, A 0275 if RegExMatch(path, "\*?\K(.*)\\[^\\]+(?= [-*] )", path) 0276 if (FileExist(path) && A_ThisHotkey = "^+e") 0277 Run explorer.exe /select`,"%path%" 0278 else 0279 Run explorer.exe "%path1%" 0280 <endfold id='2'>}</endfold id='2'> 0281 0282 #h:: ; Win+H hotkey 0283 ; Get the text currently selected. The clipboard is used instead of 0284 ; "ControlGet Selected" because it works in a greater variety of editors 0285 ; (namely word processors). Save the current clipboard contents to be 0286 ; restored later. Although this handles only plain text, it seems better 0287 ; than nothing: 0288 AutoTrim Off ; Retain any leading and trailing whitespace on the clipboard. 0289 ClipboardOld := ClipboardAll 0290 Clipboard := "" ; Must start off blank for detection to work. 0291 Send ^c 0292 ClipWait 1 0293 if ErrorLevel ; ClipWait timed out. 0294 return 0295 ; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring: 0296 ; The same is done for any other characters that might otherwise 0297 ; be a problem in raw mode: 0298 StringReplace, Hotstring, Clipboard, ``, ````, All ; Do this replacement first to avoid interfering with the others below. 0299 StringReplace, Hotstring, Hotstring, `r`n, ``r, All ; Using `r works better than `n in MS Word, etc. 0300 StringReplace, Hotstring, Hotstring, `n, ``r, All 0301 StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All 0302 StringReplace, Hotstring, Hotstring, `;, ```;, All 0303 Clipboard := ClipboardOld ; Restore previous contents of clipboard. 0304 ; This will move the InputBox's caret to a more friendly position: 0305 SetTimer, MoveCaret, 10 0306 if ErrorLevel ; The user pressed Cancel. 0307 return 0308 if InStr(Hotstring, ":R`:::") 0309 <beginfold id='2'>{</beginfold id='2'> 0310 MsgBox You didn't provide an abbreviation. The hotstring has not been added. 0311 return 0312 <endfold id='2'>}</endfold id='2'> 0313 ; Otherwise, add the hotstring and reload the script: 0314 FileAppend, `n%Hotstring%, %A_ScriptFullPath% ; Put a `n at the beginning in case file lacks a blank line at its end. 0315 Reload 0316 Sleep 200 0317 MsgBox, 4,, The hotstring just added appears to be improperly formatted. 0318 IfMsgBox, Yes, Edit 0319 return 0320 0321 MoveCaret: 0322 IfWinNotActive, New Hotstring 0323 return 0324 ; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation. 0325 Send {Home}{Right 3} 0326 SetTimer, MoveCaret, Off 0327 return 0328 0329 ; This example also demonstrates one way to implement case conformity in a script. 0330 :C:BTW:: ; Typed in all-caps. 0331 :C:Btw:: ; Typed with only the first letter upper-case. 0332 : :btw:: ; Typed in any other combination. 0333 case_conform_btw() <beginfold id='2'>{</beginfold id='2'> 0334 hs := A_ThisHotkey ; For convenience and in case we're interrupted. 0335 if (hs == ":C:BTW") 0336 Send BY THE WAY 0337 else if (hs == ":C:Btw") 0338 Send By the way 0339 else 0340 Send by the way 0341 <endfold id='2'>}</endfold id='2'> 0342 0343 #IfWinActive ahk_class Notepad 0344 ::btw::This replacement text will appear only in Notepad. 0345 #IfWinActive 0346 ::btw::This replacement text appears in windows other than Notepad. 0347 0348 #Hotstring EndChars -()[]{}:;'"/\,.?!`n `t 0349 0350 Hotstring("EndChars", "-()[]{}:;") 0351 0352 ::btw:: 0353 MsgBox You typed "``btw``". 0354 return 0355 0356 :*:]d:: ; This hotstring replaces "]d" with the current date and time via the commands below. 0357 0358 MyFunction(FirstParameter, Second, ByRef Third, Fourth:="") 0359 <beginfold id='2'>{</beginfold id='2'> 0360 return "a value" 0361 <endfold id='2'>}</endfold id='2'> 0362 0363 Loop 3 0364 MsgBox % MyArray%A_Index% 0365 0366 SysGet, WA, MonitorWorkArea 0367 MsgBox, Left: %WALeft% -- Top: %WATop% -- Right: %WARight% -- Bottom: %WABottom%. 0368 0369 n := 123 00123 -1. 0x7B 0x007B -0x1 3.14159 0370 0371 FileAppend, ; Comment. 0372 ; Comment. 0373 ( LTrim Join ; Comment. 0374 ; This is not a comment; it is literal. Include the word Comments in the line above to make it a comment. 0375 ), C:\File.txt ; Comment. 0376 0377 param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index. 0378 0379 Add(X, Y, Z:=0) <beginfold id='2'>{</beginfold id='2'> 0380 return X + Y + Z 0381 <endfold id='2'>}</endfold id='2'> 0382 0383 Join(sep, params*) <beginfold id='2'>{</beginfold id='2'> 0384 for index,param in params 0385 str .= param . sep 0386 return SubStr(str, 1, -StrLen(sep)) 0387 <endfold id='2'>}</endfold id='2'> 0388 MsgBox % Join("`n", "one", "two", "three") 0389 0390 LogToFile(TextToLog) 0391 <beginfold id='2'>{</beginfold id='2'> 0392 global LogFileName ; This global variable was previously given a value somewhere outside this function. 0393 FileAppend, %TextToLog%`n, %LogFileName% 0394 <endfold id='2'>}</endfold id='2'> 0395 0396 SetDefaults() 0397 <beginfold id='2'>{</beginfold id='2'> 0398 global 0399 MyGlobal := 33 0400 local x, y:=0, z 0401 <endfold id='2'>}</endfold id='2'> 0402 0403 LogToFile(TextToLog) 0404 <beginfold id='2'>{</beginfold id='2'> 0405 static LoggedLines := 0 0406 LoggedLines += 1 0407 global LogFileName 0408 FileAppend, %LoggedLines%: %TextToLog%`n, %LogFileName% 0409 <endfold id='2'>}</endfold id='2'> 0410 0411 GetFromStaticArray(WhichItemNumber) 0412 <beginfold id='2'>{</beginfold id='2'> 0413 static 0414 static FirstCallToUs := true 0415 if FirstCallToUs 0416 <beginfold id='2'>{</beginfold id='2'> 0417 FirstCallToUs := false 0418 Loop 10 0419 StaticArray%A_Index% := "Value #" . A_Index 0420 <endfold id='2'>}</endfold id='2'> 0421 return StaticArray%WhichItemNumber% 0422 <endfold id='2'>}</endfold id='2'> 0423 0424 if (ColorName != "" AND not FindColor(ColorName)) 0425 MsgBox %ColorName% could not be found. 0426 0427 class baseObject { 0428 static foo := "bar" 0429 } 0430 baseObject := <beginfold id='2'>{</beginfold id='2'>foo: "bar"<endfold id='2'>}</endfold id='2'> 0431 0432 thing := <beginfold id='2'>{</beginfold id='2'><endfold id='2'>}</endfold id='2'> 0433 thing.foo := "bar" 0434 thing.test := Func("thing_test") 0435 thing.test() 0436 0437 thing_test(this) <beginfold id='2'>{</beginfold id='2'> 0438 MsgBox % this.foo 0439 <endfold id='2'>}</endfold id='2'> 0440 0441 class Color 0442 <beginfold id='2'>{</beginfold id='2'> 0443 __New(aRGB) 0444 <beginfold id='2'>{</beginfold id='2'> 0445 this.RGB := aRGB 0446 <endfold id='2'>}</endfold id='2'> 0447 0448 __Delete() 0449 <beginfold id='2'>{</beginfold id='2'> 0450 MsgBox % "Delete Color." 0451 <endfold id='2'>}</endfold id='2'> 0452 0453 static Shift := <beginfold id='2'>{</beginfold id='2'>R:16, G:8, B:0<endfold id='2'>}</endfold id='2'> 0454 0455 __Get(aName) 0456 <beginfold id='2'>{</beginfold id='2'> 0457 ; NOTE: Using this.Shift here would cause an infinite loop! 0458 shift := Color.Shift[aName] ; Get the number of bits to shift. 0459 if (shift != "") ; Is it a known property? 0460 return (this.RGB >> shift) & 0xff 0461 ; NOTE: Using 'return' here would break this.RGB. 0462 <endfold id='2'>}</endfold id='2'> 0463 0464 __Set(aName, aValue) 0465 <beginfold id='2'>{</beginfold id='2'> 0466 if ((shift := Color.Shift[aName]) != "") 0467 <beginfold id='2'>{</beginfold id='2'> 0468 aValue &= 255 ; Truncate it to the proper range. 0469 0470 ; Calculate and store the new RGB value. 0471 this.RGB := (aValue << shift) | (this.RGB & ~(0xff << shift)) 0472 0473 ; 'Return' must be used to indicate a new key-value pair should not be created. 0474 ; This also defines what will be stored in the 'x' in 'x := clr[name] := val': 0475 return aValue 0476 <endfold id='2'>}</endfold id='2'> 0477 ; NOTE: Using 'return' here would break this.stored_RGB and this.RGB. 0478 <endfold id='2'>}</endfold id='2'> 0479 0480 ; Meta-functions can be mixed with properties: 0481 RGB <beginfold id='2'>{</beginfold id='2'> 0482 get <beginfold id='2'>{</beginfold id='2'> 0483 ; Return it in hex format: 0484 return format("0x{:06x}", this.stored_RGB) 0485 <endfold id='2'>}</endfold id='2'> 0486 set <beginfold id='2'>{</beginfold id='2'> 0487 return this.stored_RGB := value 0488 <endfold id='2'>}</endfold id='2'> 0489 <endfold id='2'>}</endfold id='2'> 0490 0491 class __Get extends Properties 0492 <beginfold id='2'>{</beginfold id='2'> 0493 R() <beginfold id='2'>{</beginfold id='2'> 0494 return (this.RGB >> 16) & 255 0495 <endfold id='2'>}</endfold id='2'> 0496 G() <beginfold id='2'>{</beginfold id='2'> 0497 return (this.RGB >> 8) & 255 0498 <endfold id='2'>}</endfold id='2'> 0499 B() <beginfold id='2'>{</beginfold id='2'> 0500 return this.RGB & 255 0501 <endfold id='2'>}</endfold id='2'> 0502 <endfold id='2'>}</endfold id='2'> 0503 0504 Property[] ; Brackets are optional 0505 <beginfold id='2'>{</beginfold id='2'> 0506 get <beginfold id='2'>{</beginfold id='2'> 0507 return ... 0508 <endfold id='2'>}</endfold id='2'> 0509 set <beginfold id='2'>{</beginfold id='2'> 0510 return ... := value 0511 <endfold id='2'>}</endfold id='2'> 0512 <endfold id='2'>}</endfold id='2'> 0513 <endfold id='2'>}</endfold id='2'> 0514 0515 class Properties extends FunctionObject 0516 <beginfold id='2'>{</beginfold id='2'> 0517 Call(aTarget, aName, aParams*) 0518 <beginfold id='2'>{</beginfold id='2'> 0519 ; If this Properties object contains a definition for this half-property, call it. 0520 if ObjHasKey(this, aName) 0521 return this[aName].Call(aTarget, aParams*) 0522 <endfold id='2'>}</endfold id='2'> 0523 <endfold id='2'>}</endfold id='2'> 0524 0525 MyGet(this, Key, Key2) 0526 MySet(this, Key, Key2, Value) 0527 MyCall(this, Name, Params) 0528 0529 ClassName := <beginfold id='2'>{</beginfold id='2'> __Get: Func("MyGet"), __Set: Func("MySet"), __Call: Func("MyCall") <endfold id='2'>}</endfold id='2'> 0530 0531 red := new Color(0xff0000), red.R -= 5 0532 cyan := new Color(0), cyan.G := 255, cyan.B := 255 0533 0534 MsgBox % "red: " red.R "," red.G "," red.B " = " red.RGB 0535 MsgBox % "cyan: " cyan.R "," cyan.G "," cyan.B " = " cyan.RGB 0536 0537 ; This example requires the FunctionObject class in order to work. 0538 blue := new Color(0x0000ff) 0539 MsgBox % blue.R "," blue.G "," blue.B 0540 0541 x := <beginfold id='2'>{</beginfold id='2'>base: <beginfold id='2'>{</beginfold id='2'>addr: Func("x_Addr"), __Set: Func("x_Setter")<endfold id='2'>}</endfold id='2'><endfold id='2'>}</endfold id='2'> 0542 0543 ; Assign value, implicitly calling x_Setter to create sub-objects. 0544 x[1,2,3] := "..." 0545 0546 ; Retrieve value and call example method. 0547 MsgBox % x[1,2,3] "`n" x.addr() "`n" x[1].addr() "`n" x[1,2].addr() 0548 0549 x_Setter(x, p1, p2, p3) <beginfold id='2'>{</beginfold id='2'> 0550 x[p1] := new x.base 0551 <endfold id='2'>}</endfold id='2'> 0552 0553 x_Addr(x) <beginfold id='2'>{</beginfold id='2'> 0554 return &x 0555 <endfold id='2'>}</endfold id='2'> 0556 0557 InputBox, OutputVar, Question 1, What is your first name? 0558 if (OutputVar = "Bill") 0559 MsgBox, That's an awesome name`, %OutputVar%. 0560 0561 InputBox, OutputVar2, Question 2, Do you like AutoHotkey? 0562 if (OutputVar2 = "yes") 0563 MsgBox, Thank you for answering %OutputVar2%`, %OutputVar%! We will become great friends. 0564 else 0565 MsgBox, %OutputVar%`, That makes me sad. 0566 0567 MsgBox, 4,, Would you like to continue? 0568 IfMsgBox, No 0569 return ; If No, stop the code from going further. 0570 MsgBox, You pressed YES. ; Otherwise, the user picked yes. 0571 0572 if (car = "old") 0573 <beginfold id='2'>{</beginfold id='2'> 0574 MsgBox, The car is really old. 0575 if (wheels = "flat") 0576 <beginfold id='2'>{</beginfold id='2'> 0577 MsgBox, This car is not safe to drive. 0578 return 0579 <endfold id='2'>}</endfold id='2'> 0580 else 0581 <beginfold id='2'>{</beginfold id='2'> 0582 MsgBox, Be careful! This old car will be dangerous to drive. 0583 <endfold id='2'>}</endfold id='2'> 0584 <endfold id='2'>}</endfold id='2'> 0585 else 0586 <beginfold id='2'>{</beginfold id='2'> 0587 MsgBox, My`, what a shiny new vehicle you have there. 0588 <endfold id='2'>}</endfold id='2'> 0589 0590 if (Color = "Red" or Color = "Green" or Color = "Blue" ; Comment. 0591 or Color = "Black" or Color = "Gray" or Color = "White") ; Comment. 0592 and ProductIsAvailableInColor(Product, Color) ; Comment. 0593 0594 if (codepage != "") 0595 codepage := " /CP" . codepage 0596 cmd="%A_AhkPath%"%codepage% "`%1" `%* 0597 key=AutoHotkeyScript\Shell\Open\Command 0598 if A_IsAdmin ; Set for all users. 0599 RegWrite, REG_SZ, HKCR, %key%,, %cmd% 0600 else ; Set for current user only. 0601 RegWrite, REG_SZ, HKCU, Software\Classes\%key%,, %cmd% 0602 0603 ^j:: ; hotkey label 0604 MsgBox, You typed btw.