AutoIt for beginners

1. #NoTrayIcon
2.
3. #Region AutoIt3Wrapper directives section
4. #AutoIt3Wrapper_Icon=icon.ico
5. #AutoIt3Wrapper_Compression=4
6. #AutoIt3Wrapper_UseUpx=Y
7. #EndRegion
8.
9. #include <Misc.au3>
10.
11. _Singleton(@ScriptName)
12.
13. #Region Options
14. Opt('MustDeclareVars', 1)
15. Opt('WinTitleMatchMode', 2)
16. Opt('GUICloseOnESC', 0)
17. Opt('GUIOnEventMode', 1)
18. #EndRegion
19.
20. Const $AUTHOR = 'Juno_okyo'
21.
22. Global $year = 2016
23. Global $JunoDepTrai = True
24. Global $aData[3]
25.
26. $aData[0] = 'Hello World'
27. $aData[1] = @YEAR
28. $aData[2] = True
29.
30. Func example($variable1, $variable2 = Default)
31.
32. If $variable1 > 0 Then
33. MsgBox(0, 'Message', 'Value is positive.')
34. ElseIf $variable1 < 0 Then
35. MsgBox(0, 'Message', 'Value is negative.')
36. Else
37. If StringIsXDigit($variable1) Then
38. MsgBox(0, 'Message', 'Value might be hexadecimal!')
39. Else
40. MsgBox(0, 'Message', 'Value is a string.')
41. EndIf
42. EndIf
43.
44. Local $iValue = 0
45. Local $sBlank = 'Test'
46.
47. Select
48. Case $iValue = 1
49. MsgBox(0, 'Message', 'The first expression was True.')
50. Case $sBlank = 'Test'
51. MsgBox(0, 'Message', 'The second expression was True')
52. Case Else
53. MsgBox(0, 'Message', 'No preceding case was True.')
54. EndSelect
55.
56. Local $sMsg = 'Message'
57.
58. Switch @HOUR
59. Case 6 To 11
60. $sMsg = 'Good Morning'
61. Case 12 To 17
62. $sMsg = 'Good Afternoon'
63. Case 18 To 21
64. $sMsg = 'Good Evening'
65. Case Else
66. $sMsg = 'What are you still doing up?'
67. EndSwitch
68.
69. MsgBox(0, 'Message', $sMsg)
70.
71. Local $i = 0
72. For $i = 0 To 10 Step + 2
73. ConsoleWrite('Current value: ' & $i)
74. Next
75.
76. Local $i = 0
77. While $i <= 10
78. MsgBox(0, 'Message', 'Value of $i is: ' & $i)
79. $i = $i + 1
80. WEnd
81.
82. Local $i = 0
83. Do
84. MsgBox(0, 'Message', 'The value of $i is: ' & $i)
85. $i = $i + 1
86. Until $i = 10
87.
88. For $x In $aData
89. ConsoleWrite($x)
90. Next
91. EndFunc
92.
93. example(15)
94.
Điều hướng với phím lên/xuống của bạn