PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Rusty/Core/Accessors.cs

http://github.com/polyethene/IronAHK
C# | 1312 lines | 756 code | 153 blank | 403 comment | 56 complexity | b91f0af5dfb2b97c6e18ec036f77b912 MD5 | raw file
  1. using System;
  2. using System.Globalization;
  3. using System.IO;
  4. using System.Net;
  5. using System.Net.Sockets;
  6. using System.Reflection;
  7. using System.Runtime.InteropServices;
  8. using System.Security.Principal;
  9. using System.Threading;
  10. namespace IronAHK.Rusty
  11. {
  12. partial class Core
  13. {
  14. // TODO: organise Accessors.cs
  15. /// <summary>
  16. /// The full path of the assembly that is currently executing.
  17. /// </summary>
  18. public static string A_AhkPath
  19. {
  20. get { return Assembly.GetExecutingAssembly().Location; }
  21. }
  22. /// <summary>
  23. /// The version of the assembly that is currently executing.
  24. /// </summary>
  25. public static string A_AhkVersion
  26. {
  27. get
  28. {
  29. var asm = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
  30. return asm.GetName().Version.ToString();
  31. }
  32. }
  33. /// <summary>
  34. /// The full path and name of the folder containing the current user's application-specific data. For example: <code>C:\Documents and Settings\Username\Application Data</code>
  35. /// </summary>
  36. public static string A_AppData
  37. {
  38. get { return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); }
  39. }
  40. /// <summary>
  41. /// The full path and name of the folder containing the all-users application-specific data.
  42. /// </summary>
  43. public static string A_AppDataCommon
  44. {
  45. get { return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); }
  46. }
  47. /// <summary>
  48. /// (synonymous with A_NumBatchLines) The current value as set by SetBatchLines. Examples: 200 or 10ms (depending on format).
  49. /// </summary>
  50. [Obsolete]
  51. public static string A_BatchLines
  52. {
  53. get { return null; }
  54. }
  55. /// <summary>
  56. /// The current X coordinate of the caret (text insertion point). The coordinates are relative to the active window unless CoordMode is used to make them relative to the entire screen. If there is no active window or the caret position cannot be determined, these variables are blank.
  57. /// </summary>
  58. public static string A_CaretX
  59. {
  60. get { return string.Empty; }
  61. }
  62. /// <summary>
  63. /// The current Y coordinate of the caret (text insertion point). The coordinates are relative to the active window unless CoordMode is used to make them relative to the entire screen. If there is no active window or the caret position cannot be determined, these variables are blank.
  64. /// </summary>
  65. public static string A_CaretY
  66. {
  67. get { return string.Empty; }
  68. }
  69. /// <summary>
  70. /// The name of the computer as seen on the network.
  71. /// </summary>
  72. public static string A_ComputerName
  73. {
  74. get { return Environment.MachineName; }
  75. }
  76. /// <summary>
  77. /// The delay in milliseconds that will occur after each control-modifying command.
  78. /// </summary>
  79. public static int A_ControlDelay
  80. {
  81. get { return _ControlDelay ?? 20; }
  82. set { _ControlDelay = value; }
  83. }
  84. /// <summary>
  85. /// The type of mouse cursor currently being displayed. It will be one of the following words: AppStarting, Arrow, Cross, Help, IBeam, Icon, No, Size, SizeAll, SizeNESW, SizeNS, SizeNWSE, SizeWE, UpArrow, Wait, Unknown. The acronyms used with the size-type cursors are compass directions, e.g. NESW = NorthEast+SouthWest. The hand-shaped cursors (pointing and grabbing) are classfied as Unknown.
  86. /// </summary>
  87. public static string A_Cursor
  88. {
  89. get { return null; }
  90. }
  91. /// <summary>
  92. /// See <see cref="A_MDay"/>.
  93. /// </summary>
  94. public static string A_DD
  95. {
  96. get { return A_MDay; }
  97. }
  98. /// <summary>
  99. /// Current day of the week's 3-letter abbreviation in the current user's language, e.g. <code>Sun</code>.
  100. /// </summary>
  101. public static string A_DDD
  102. {
  103. get { return DateTime.Now.ToString("ddd"); }
  104. }
  105. /// <summary>
  106. /// Current day of the week's full name in the current user's language, e.g. <code>Sunday</code>.
  107. /// </summary>
  108. public static string A_DDDD
  109. {
  110. get { return DateTime.Now.ToString("dddd"); }
  111. }
  112. /// <summary>
  113. /// Sets the mouse speed that will be used if unspecified in <see cref="Click"/>.
  114. /// </summary>
  115. public static int A_DefaultMouseSpeed
  116. {
  117. get { return _DefaultMouseSpeed ?? 2; }
  118. set { _DefaultMouseSpeed = value; }
  119. }
  120. /// <summary>
  121. /// The full path and name of the folder containing the current user's desktop files.
  122. /// </summary>
  123. public static string A_Desktop
  124. {
  125. get { return Environment.GetFolderPath(Environment.SpecialFolder.Desktop); }
  126. }
  127. /// <summary>
  128. /// The full path and name of the folder containing the all-users desktop files.
  129. /// </summary>
  130. public static string A_DesktopCommon
  131. {
  132. get { return Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); }
  133. }
  134. /// <summary>
  135. /// Determines whether invisible text in a window is "seen" for the purpose of finding the window. This affects commands such as <see cref="WinExist"/> and <see cref="WinActivate"/>.
  136. /// </summary>
  137. public static string A_DetectHiddenText
  138. {
  139. get { return _DetectHiddenText ?? true ? Keyword_On : Keyword_Off; }
  140. set { _DetectHiddenText = OnOff(value); }
  141. }
  142. /// <summary>
  143. /// Determines whether invisible windows are "seen".
  144. /// </summary>
  145. public static string A_DetectHiddenWindows
  146. {
  147. get { return _DetectHiddenWindows ?? false ? Keyword_On : Keyword_Off; }
  148. set { _DetectHiddenWindows = OnOff(value); }
  149. }
  150. /// <summary>
  151. /// The native directory seperator string, i.e. "/" on Unix, "\" on Windows.
  152. /// </summary>
  153. public static string A_DirSeperator
  154. {
  155. get { return Path.DirectorySeparatorChar.ToString(); }
  156. }
  157. /// <summary>
  158. /// Represents the natural logarithmic base, specified by the constant, e.
  159. /// </summary>
  160. public static double A_E
  161. {
  162. get { return Math.E; }
  163. }
  164. /// <summary>
  165. /// The ending character that was pressed by the user to trigger the most recent non-auto-replace hotstring. If no ending character was required (due to the * option), this variable will be blank.
  166. /// </summary>
  167. public static string A_EndChar
  168. {
  169. get { return null; }
  170. }
  171. /// <summary>
  172. /// Contains event information from various commands.
  173. /// </summary>
  174. public static int A_EventInfo
  175. {
  176. get;
  177. set;
  178. }
  179. /// <summary>
  180. /// The most recent reason the script was asked to terminate. This variable is blank unless the script has an OnExit subroutine and that subroutine is currently running or has been called at least once by an exit attempt. See OnExit for details.
  181. /// </summary>
  182. public static string A_ExitReason
  183. {
  184. get { return null; }
  185. }
  186. /// <summary>
  187. /// The current floating point number format.
  188. /// </summary>
  189. [Obsolete]
  190. public static string A_FormatFloat
  191. {
  192. get
  193. {
  194. if (A_FormatNumeric.IndexOf("e", StringComparison.OrdinalIgnoreCase) != -1)
  195. return A_FormatNumeric;
  196. if (A_FormatNumeric.IndexOf("f", StringComparison.OrdinalIgnoreCase) != -1)
  197. {
  198. var format = A_FormatNumeric.Replace("f", string.Empty).Replace("F", string.Empty);
  199. return string.Concat(format.Length == 0 ? "0" : int.Parse(format).ToString(), ".",
  200. System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalDigits.ToString());
  201. }
  202. return string.Empty;
  203. }
  204. set
  205. {
  206. var e = false;
  207. foreach (var exp in new[] { value.IndexOf('e'), value.IndexOf('E') })
  208. {
  209. if (exp == -1)
  210. {
  211. continue;
  212. }
  213. A_FormatNumeric = value.Substring(exp);
  214. value = value.Substring(0, exp);
  215. e = true;
  216. }
  217. var parts = value.Split(new[] { '.' }, 2);
  218. int n;
  219. if (!e && int.TryParse(parts[0], out n) && n != 0)
  220. A_FormatNumeric = "f" + n;
  221. if (parts.Length > 1 && int.TryParse(parts[1], out n))
  222. {
  223. var t = System.Threading.Thread.CurrentThread;
  224. var ci = new CultureInfo(t.CurrentCulture.LCID);
  225. ci.NumberFormat.NumberDecimalDigits = n;
  226. t.CurrentCulture = ci;
  227. }
  228. }
  229. }
  230. /// <summary>
  231. /// The current integer format, either <c>H</c> or <c>D</c>.
  232. /// </summary>
  233. [Obsolete]
  234. public static string A_FormatInteger
  235. {
  236. get { return A_FormatNumeric == "f" ? "D" : A_FormatNumeric == "x" ? "H" : string.Empty; }
  237. set
  238. {
  239. switch (value.ToLowerInvariant())
  240. {
  241. case Keyword_Hex:
  242. case Keyword_FormatHex:
  243. A_FormatNumeric = "x";
  244. break;
  245. case Keyword_FormatDecimal:
  246. A_FormatNumeric = "f";
  247. break;
  248. }
  249. }
  250. }
  251. /// <summary>
  252. /// The current numeric format.
  253. /// </summary>
  254. public static string A_FormatNumeric
  255. {
  256. get
  257. {
  258. if (_FormatNumeric != null)
  259. return _FormatNumeric;
  260. var t = System.Threading.Thread.CurrentThread;
  261. var ci = new CultureInfo(t.CurrentCulture.LCID);
  262. ci.NumberFormat.NumberDecimalDigits = 6;
  263. t.CurrentCulture = ci;
  264. return "f";
  265. }
  266. set { _FormatNumeric = value; }
  267. }
  268. /// <summary>
  269. /// The GUI window number that launched the current thread. This variable is blank unless a Gui control, menu bar item, or event such as GuiClose/GuiEscape launched the current thread.
  270. /// </summary>
  271. public static string A_Gui
  272. {
  273. get { return null; }
  274. }
  275. /// <summary>
  276. /// <para>The type of event that launched the current thread. If the thread was not launched via GUI action, this variable is blank. Otherwise, it contains one of the following strings:</para>
  277. /// <para>Normal: The event was triggered by a single left-click or via keystrokes (arrow keys, TAB key, space bar, underlined shortcut key, etc.). This value is also used for menu bar items and the special events such as GuiClose and GuiEscape.</para>
  278. /// <para>DoubleClick: The event was triggered by a double-click. Note: The first click of the click-pair will still cause a Normal event to be received first. In other words, the subroutine will be launched twice: once for the first click and again for the second.</para>
  279. /// <para>RightClick: Occurs only for GuiContextMenu, ListViews, and TreeViews.</para>
  280. /// <para>Context-sensitive values: For details see GuiContextMenu, GuiDropFiles, Slider, MonthCal, ListView, and TreeView.</para>
  281. /// </summary>
  282. public static string A_GuiEvent
  283. {
  284. get { return null; }
  285. }
  286. /// <summary>
  287. /// The name of the variable associated with the GUI control that launched the current thread. If that control lacks an associated variable, A_GuiControl instead contains the first 63 characters of the control's text/caption (this is most often used to avoid giving each button a variable name). A_GuiControl is blank whenever: 1) A_Gui is blank; 2) a GUI menu bar item or event such as GuiClose/GuiEscape launched the current thread; 3) the control lacks an associated variable and has no caption; or 4) The control that originally launched the current thread no longer exists (perhaps due to Gui Destroy).
  288. /// </summary>
  289. public static string A_GuiControl
  290. {
  291. get { return null; }
  292. }
  293. /// <summary>
  294. /// See <see cref="A_GuiEvent"/>.
  295. /// </summary>
  296. public static string A_GuiControlEvent
  297. {
  298. get { return null; }
  299. }
  300. /// <summary>
  301. /// These contain the GUI window's height when referenced in a GuiSize subroutine. They apply to the window's client area, which is the area excluding title bar, menu bar, and borders.
  302. /// </summary>
  303. public static string A_GuiHeight
  304. {
  305. get { return null; }
  306. }
  307. /// <summary>
  308. /// These contain the GUI window's width when referenced in a GuiSize subroutine. They apply to the window's client area, which is the area excluding title bar, menu bar, and borders.
  309. /// </summary>
  310. public static string A_GuiWidth
  311. {
  312. get { return null; }
  313. }
  314. /// <summary>
  315. /// These contain the X coordinate for GuiContextMenu and GuiDropFiles events. Coordinates are relative to the upper-left corner of the window.
  316. /// </summary>
  317. public static string A_GuiX
  318. {
  319. get { return null; }
  320. }
  321. /// <summary>
  322. /// These contain the Y coordinate for GuiContextMenu and GuiDropFiles events. Coordinates are relative to the upper-left corner of the window.
  323. /// </summary>
  324. public static string A_GuiY
  325. {
  326. get { return null; }
  327. }
  328. /// <summary>
  329. /// Current 2-digit hour (00-23) in 24-hour time (for example, 17 is 5pm).
  330. /// </summary>
  331. public static string A_Hour
  332. {
  333. get { return DateTime.Now.ToString("HH"); }
  334. }
  335. /// <summary>
  336. /// Blank unless a custom tray icon has been specified via Menu, tray, icon -- in which case it's the full path and name of the icon's file.
  337. /// </summary>
  338. public static string A_IconFile
  339. {
  340. get { return null; }
  341. }
  342. /// <summary>
  343. /// Contains 1 if the tray icon is currently hidden or 0 otherwise. The icon can be hidden via #NoTrayIcon or the Menu command.
  344. /// </summary>
  345. public static string A_IconHidden
  346. {
  347. get { return null; }
  348. }
  349. /// <summary>
  350. /// Blank if A_IconFile is blank. Otherwise, it's the number of the icon in A_IconFile (typically 1).
  351. /// </summary>
  352. public static string A_IconNumber
  353. {
  354. get { return null; }
  355. }
  356. /// <summary>
  357. /// Blank unless a custom tooltip for the tray icon has been specified via Menu, Tray, Tip -- in which case it's the text of the tip.
  358. /// </summary>
  359. public static string A_IconTip
  360. {
  361. get { return null; }
  362. }
  363. /// <summary>
  364. /// The number of the current loop iteration.
  365. /// </summary>
  366. public static int A_Index
  367. {
  368. get
  369. {
  370. if (loops.Count > 0)
  371. return loops.Peek().index + 1;
  372. else
  373. return default(int);
  374. }
  375. }
  376. /// <summary>
  377. /// The IP address of the first network adapter in the computer.
  378. /// </summary>
  379. [Obsolete]
  380. public static string A_IPAddress1
  381. {
  382. get { return A_IPAddress.Length > 0 ? A_IPAddress[0] : null; }
  383. }
  384. /// <summary>
  385. /// The IP address of the second network adapter in the computer.
  386. /// </summary>
  387. [Obsolete]
  388. public static string A_IPAddress2
  389. {
  390. get { return A_IPAddress.Length > 1 ? A_IPAddress[1] : null; }
  391. }
  392. /// <summary>
  393. /// The IP address of the third network adapter in the computer.
  394. /// </summary>
  395. [Obsolete]
  396. public static string A_IPAddress3
  397. {
  398. get { return A_IPAddress.Length > 2 ? A_IPAddress[2] : null; }
  399. }
  400. /// <summary>
  401. /// The IP address of the fourth network adapter in the computer.
  402. /// </summary>
  403. [Obsolete]
  404. public static string A_IPAddress4
  405. {
  406. get { return A_IPAddress.Length > 3 ? A_IPAddress[3] : null; }
  407. }
  408. /// <summary>
  409. /// The IP addresses of the network adapters in the computer.
  410. /// </summary>
  411. public static string[] A_IPAddress
  412. {
  413. get
  414. {
  415. var addr = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
  416. var ips = new string[addr.Length];
  417. for (int i = 0; i < addr.Length; i++)
  418. if (addr[i].AddressFamily == AddressFamily.InterNetwork)
  419. ips[i] = addr[i].ToString();
  420. return ips;
  421. }
  422. }
  423. /// <summary>
  424. /// <code>true</code> if the current user has administrator rights, <code>false</code> otherwise.
  425. /// </summary>
  426. public static bool A_ISAdmin
  427. {
  428. get { return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator); }
  429. }
  430. /// <summary>
  431. /// <code>true</code> if the current executing assembly is a compiled script, <code>false</code> otherwise;
  432. /// </summary>
  433. public static bool A_IsCompiled
  434. {
  435. get { return false; }
  436. }
  437. /// <summary>
  438. /// <c>1</c> if the current thread is marked as critical, <c>0</c> otherwise.
  439. /// </summary>
  440. public static int A_IsCritical
  441. {
  442. get { return System.Threading.Thread.CurrentThread.Priority == ThreadPriority.Highest ? 1 : 0; }
  443. }
  444. /// <summary>
  445. /// <code>true</code> if the script is suspended, <code>false</code> otherwise;
  446. /// </summary>
  447. public static bool A_IsSuspended { get; set; }
  448. /// <summary>
  449. /// The delay that will occur after each keystroke sent by <see cref="Send"/> and <see cref="ControlSend"/>.
  450. /// </summary>
  451. public static int A_KeyDelay
  452. {
  453. get { return _KeyDelay ?? 0; }
  454. set { _KeyDelay = value; }
  455. }
  456. /// <summary>
  457. /// The delay between the press of a key and before its release, used with <see cref="A_KeyDelay"/>.
  458. /// </summary>
  459. public static int A_KeyPressDuration
  460. {
  461. get { return _KeyPressDuration ?? 0; }
  462. set { _KeyPressDuration = value; }
  463. }
  464. /// <summary>
  465. /// The system's default language code.
  466. /// </summary>
  467. public static int A_Language
  468. {
  469. get { return System.Threading.Thread.CurrentThread.CurrentCulture.LCID; }
  470. }
  471. /// <summary>
  472. /// The result from Windows <code>GetLastError()</code> function.
  473. /// </summary>
  474. public static int A_LastError
  475. {
  476. get { return Marshal.GetLastWin32Error(); }
  477. }
  478. #region Loops
  479. /// <summary>
  480. /// The current element of a loop.
  481. /// </summary>
  482. public static object A_LoopField
  483. {
  484. get
  485. {
  486. if (loops.Count == 0)
  487. return null;
  488. var stack = loops.ToArray();
  489. for (int i = 0; i < stack.Length; i++)
  490. {
  491. switch (stack[i].type)
  492. {
  493. case LoopType.Parse:
  494. return stack[i].result;
  495. case LoopType.Each:
  496. {
  497. if (!(stack[i].result is object[]))
  498. return null;
  499. var pair = (object[])stack[i].result;
  500. return pair.Length > 0 ? pair[1] : null;
  501. }
  502. }
  503. }
  504. return null;
  505. }
  506. }
  507. /// <summary>
  508. /// The current object key in an each-loop.
  509. /// </summary>
  510. public static object A_LoopKey
  511. {
  512. get
  513. {
  514. if (loops.Count == 0)
  515. return null;
  516. var stack = loops.ToArray();
  517. for (int i = 0; i < stack.Length; i++)
  518. {
  519. switch (stack[i].type)
  520. {
  521. case LoopType.Each:
  522. {
  523. if (!(stack[i].result is object[]))
  524. return null;
  525. var pair = (object[])stack[i].result;
  526. return pair[0];
  527. }
  528. }
  529. }
  530. return null;
  531. }
  532. }
  533. /// <summary>
  534. /// The attributes of the file currently retrieved.
  535. /// </summary>
  536. public static string A_LoopFileAttrib
  537. {
  538. get { return null; }
  539. }
  540. /// <summary>
  541. /// The full path of the directory in which A_LoopFileName resides. However, if FilePattern contains a relative path rather than an absolute path, the path here will also be relative. A root directory will not contain a trailing backslash. For example: C:
  542. /// </summary>
  543. public static string A_LoopFileDir
  544. {
  545. get { return null; }
  546. }
  547. /// <summary>
  548. /// The file's extension (e.g. TXT, DOC, or EXE). The period (.) is not included.
  549. /// </summary>
  550. public static string A_LoopFileExt
  551. {
  552. get { return null; }
  553. }
  554. /// <summary>
  555. /// The full path and name of the file/folder currently retrieved. However, if FilePattern contains a relative path rather than an absolute path, the path here will also be relative. In addition, any short (8.3) folder names in FilePattern will still be short (see next item to get the long version).
  556. /// </summary>
  557. public static string A_LoopFileFullPath
  558. {
  559. get { return null; }
  560. }
  561. /// <summary>
  562. /// This is different than A_LoopFileFullPath in the following ways: 1) It always contains the absolute/complete path of the file even if FilePattern contains a relative path; 2) Any short (8.3) folder names in FilePattern itself are converted to their long names; 3) Characters in FilePattern are converted to uppercase or lowercase to match the case stored in the file system. This is useful for converting file names -- such as those passed into a script as command line parameters -- to their exact path names as shown by Explorer.
  563. /// </summary>
  564. public static string A_LoopFileLongPath
  565. {
  566. get { return null; }
  567. }
  568. /// <summary>
  569. /// The name of the file or folder currently retrieved (without the path).
  570. /// </summary>
  571. public static string A_LoopFileName
  572. {
  573. get { return null; }
  574. }
  575. /// <summary>
  576. /// The 8.3 short name, or alternate name of the file. If the file doesn't have one (due to the long name being shorter than 8.3 or perhaps because short-name generation is disabled on an NTFS file system), A_LoopFileName will be retrieved instead.
  577. /// </summary>
  578. public static string A_LoopFileShortName
  579. {
  580. get { return null; }
  581. }
  582. /// <summary>
  583. /// The 8.3 short path and name of the file/folder currently retrieved. For example: C:\MYDOCU~1\ADDRES~1.txt. However, if FilePattern contains a relative path rather than an absolute path, the path here will also be relative.
  584. /// </summary>
  585. public static string A_LoopFileShortPath
  586. {
  587. get { return null; }
  588. }
  589. /// <summary>
  590. /// The size in bytes of the file currently retrieved. Files larger than 4 gigabytes are also supported.
  591. /// </summary>
  592. public static string A_LoopFileSize
  593. {
  594. get { return null; }
  595. }
  596. /// <summary>
  597. /// The size in Kbytes of the file currently retrieved, rounded down to the nearest integer.
  598. /// </summary>
  599. public static string A_LoopFileSizeKB
  600. {
  601. get { return null; }
  602. }
  603. /// <summary>
  604. /// The size in Mbytes of the file currently retrieved, rounded down to the nearest integer.
  605. /// </summary>
  606. public static string A_LoopFileSizeMB
  607. {
  608. get { return null; }
  609. }
  610. /// <summary>
  611. /// The time the file was last accessed. Format YYYYMMDDHH24MISS.
  612. /// </summary>
  613. public static string A_LoopFileTimeAccessed
  614. {
  615. get { return null; }
  616. }
  617. /// <summary>
  618. /// The time the file was created. Format YYYYMMDDHH24MISS.
  619. /// </summary>
  620. public static string A_LoopFileTimeCreated
  621. {
  622. get { return null; }
  623. }
  624. /// <summary>
  625. /// The time the file was last modified. Format YYYYMMDDHH24MISS.
  626. /// </summary>
  627. public static string A_LoopFileTimeModified
  628. {
  629. get { return null; }
  630. }
  631. /// <summary>
  632. /// Contains the contents of the current line excluding the carriage return and linefeed (`r`n) that marks the end of the line.
  633. /// </summary>
  634. public static string A_LoopReadLine
  635. {
  636. get { return null; }
  637. }
  638. /// <summary>
  639. /// The name of the root key being accessed (HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_USER, HKEY_CLASSES_ROOT, or HKEY_CURRENT_CONFIG). For remote registry access, this value will not include the computer name.
  640. /// </summary>
  641. public static string A_LoopRegKey
  642. {
  643. get { return null; }
  644. }
  645. /// <summary>
  646. /// Name of the currently retrieved item, which can be either a value name or the name of a subkey. Value names displayed by Windows RegEdit as "(Default)" will be retrieved if a value has been assigned to them, but A_LoopRegName will be blank for them.
  647. /// </summary>
  648. public static string A_LoopRegName
  649. {
  650. get { return null; }
  651. }
  652. /// <summary>
  653. /// Name of the current SubKey. This will be the same as the Key parameter unless the Recurse parameter is being used to recursively explore other subkeys. In that case, it will be the full path of the currently retrieved item, not including the root key. For example: Software\SomeApplication\My SubKey
  654. /// </summary>
  655. public static string A_LoopRegSubkey
  656. {
  657. get { return null; }
  658. }
  659. /// <summary>
  660. /// The time the current subkey or any of its values was last modified. Format YYYYMMDDHH24MISS. This variable will be empty if the currently retrieved item is not a subkey (i.e. A_LoopRegType is not the word KEY) or if the operating system is Win9x (since Win9x does not track this info).
  661. /// </summary>
  662. public static string A_LoopRegTimeModified
  663. {
  664. get { return null; }
  665. }
  666. /// <summary>
  667. /// The type of the currently retrieved item, which is one of the following words: KEY (i.e. the currently retrieved item is a subkey not a value), REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ, REG_DWORD, REG_QWORD, REG_BINARY, REG_LINK, REG_RESOURCE_LIST, REG_FULL_RESOURCE_DESCRIPTOR, REG_RESOURCE_REQUIREMENTS_LIST, REG_DWORD_BIG_ENDIAN (probably rare on most Windows hardware). It will be empty if the currently retrieved item is of an unknown type.
  668. /// </summary>
  669. public static string A_LoopRegType
  670. {
  671. get { return null; }
  672. }
  673. #endregion
  674. /// <summary>
  675. /// Current 2-digit day of the month (01-31).
  676. /// </summary>
  677. public static string A_MDay
  678. {
  679. get { return DateTime.Now.ToString("dd"); }
  680. }
  681. /// <summary>
  682. /// Current 2-digit minute (00-59).
  683. /// </summary>
  684. public static string A_Min
  685. {
  686. get { return DateTime.Now.ToString("mm"); }
  687. }
  688. /// <summary>
  689. /// Current 2-digit month (01-12). Synonymous with <see cref="A_Mon"/>.
  690. /// </summary>
  691. public static string A_MM
  692. {
  693. get { return A_Mon; }
  694. }
  695. /// <summary>
  696. /// Current month's abbreviation in the current user's language, e.g. <code>Jul</code>.
  697. /// </summary>
  698. public static string A_MMM
  699. {
  700. get { return DateTime.Now.ToString("MMM"); }
  701. }
  702. /// <summary>
  703. /// Current month's full name in the current user's language, e.g. <code>July</code>.
  704. /// </summary>
  705. public static string A_MMMM
  706. {
  707. get { return DateTime.Now.ToString("MMMM"); }
  708. }
  709. /// <summary>
  710. /// Current 2-digit month (01-12).
  711. /// </summary>
  712. public static string A_Mon
  713. {
  714. get { return DateTime.Now.ToString("MM"); }
  715. }
  716. /// <summary>
  717. /// Sets the delay that will occur after each mouse movement or click.
  718. /// </summary>
  719. public static int A_MouseDelay
  720. {
  721. get { return _MouseDelay ?? 10; }
  722. set { _MouseDelay = value; }
  723. }
  724. /// <summary>
  725. /// Current 3-digit millisecond (000-999).
  726. /// </summary>
  727. public static string A_MSec
  728. {
  729. get { return DateTime.Now.ToString("fff"); }
  730. }
  731. /// <summary>
  732. /// The full path and name of the current user's "My Documents" folder.
  733. /// </summary>
  734. public static string A_MyDocuments
  735. {
  736. get { return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); }
  737. }
  738. /// <summary>
  739. /// The current local time in YYYYMMDDHH24MISS format.
  740. /// </summary>
  741. public static string A_Now
  742. {
  743. get { return ToYYYYMMDDHH24MISS(DateTime.Now); }
  744. }
  745. /// <summary>
  746. /// The current Coordinated Universal Time (UTC) in YYYYMMDDHH24MISS format.
  747. /// </summary>
  748. public static string A_NowUTC
  749. {
  750. get { return ToYYYYMMDDHH24MISS(DateTime.Now.ToUniversalTime()); }
  751. }
  752. /// <summary>
  753. /// See <see cref="A_BatchLines"/>.
  754. /// </summary>
  755. [Obsolete]
  756. public static string A_NumBatchLines
  757. {
  758. get { return A_BatchLines; }
  759. }
  760. /// <summary>
  761. /// The type of Operating System being run, e.g. <code>WIN32_WINDOWS</code> for Windows 95/98/ME or <code>WIN32_NT</code> for Windows NT4/2000/XP/2003/Vista.
  762. /// </summary>
  763. public static string A_OSType
  764. {
  765. get { return ToOSType(Environment.OSVersion.Platform); }
  766. }
  767. /// <summary>
  768. /// The Operating System version, e.g. <code>WIN_VISTA</code>, <code>WIN_2003</code>, <code>WIN_XP</code>, <code>WIN_2000</code>, <code>WIN_NT4</code>, <code>WIN_95</code>, <code>WIN_98</code>, <code>WIN_ME</code>.
  769. /// </summary>
  770. public static string A_OSVersion
  771. {
  772. get
  773. {
  774. if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
  775. {
  776. switch (Environment.OSVersion.Version.Minor)
  777. {
  778. case 0: return "WIN_95";
  779. case 10: return "WIN_98";
  780. case 90: return "WIN_ME";
  781. default: return Environment.OSVersion.VersionString;
  782. }
  783. }
  784. else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
  785. {
  786. switch (Environment.OSVersion.Version.Major)
  787. {
  788. case 4: return "WIN_NT4";
  789. case 5:
  790. {
  791. switch (Environment.OSVersion.Version.Minor)
  792. {
  793. case 0: return "WIN_2000";
  794. case 1: return "WIN_XP";
  795. case 2: return "WIN_2003";
  796. default: return Environment.OSVersion.VersionString;
  797. }
  798. }
  799. case 6:
  800. {
  801. switch (Environment.OSVersion.Version.Minor)
  802. {
  803. case 0: return "WIN_VISTA";
  804. case 1: return "WIN_7";
  805. default: return Environment.OSVersion.VersionString;
  806. }
  807. }
  808. default: return Environment.OSVersion.VersionString;
  809. }
  810. }
  811. else
  812. {
  813. return Environment.OSVersion.VersionString;
  814. }
  815. }
  816. }
  817. /// <summary>
  818. /// Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π.
  819. /// </summary>
  820. public static double A_PI
  821. {
  822. get { return Math.PI; }
  823. }
  824. /// <summary>
  825. /// The key name of the previously executed hotkey or hotstring.
  826. /// </summary>
  827. public static string A_PriorHotkey
  828. {
  829. get { return keyboardHook == null ? null : keyboardHook.PriorHotkey; }
  830. }
  831. /// <summary>
  832. /// The Program Files directory (e.g. <code>C:\Program Files</code>).
  833. /// </summary>
  834. public static string A_ProgramFiles
  835. {
  836. get { return Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); }
  837. }
  838. /// <summary>
  839. /// The full path and name of the Programs folder in the current user's Start Menu.
  840. /// </summary>
  841. public static string A_Programs
  842. {
  843. get { return Environment.GetFolderPath(Environment.SpecialFolder.Programs); }
  844. }
  845. /// <summary>
  846. /// The full path and name of the Programs folder in the all-users Start Menu.
  847. /// </summary>
  848. public static string A_ProgramsCommon
  849. {
  850. get { return Environment.GetFolderPath(Environment.SpecialFolder.Startup); }
  851. }
  852. /// <summary>
  853. /// <para>The width and height of the primary monitor, in pixels (e.g. 1024 and 768).</para>
  854. /// <para>To discover the dimensions of other monitors in a multi-monitor system, use SysGet.</para>
  855. /// <para>To instead discover the width and height of the entire desktop (even if it spans multiple monitors), use the following example (but on Windows 95/NT, both of the below variables will be set to 0):</para>
  856. /// <code>
  857. /// SysGet, VirtualWidth, 78
  858. /// SysGet, VirtualHeight, 79
  859. /// </code>
  860. /// <para>In addition, use SysGet to discover the work area of a monitor, which can be smaller than the monitor's total area because the taskbar and other registered desktop toolbars are excluded.</para>
  861. /// </summary>
  862. public static int A_ScreenHeight
  863. {
  864. get
  865. {
  866. IntPtr handle = WindowsAPI.GetDesktopWindow(); /* get the hDC of the target window */
  867. WindowsAPI.RECT windowRect;
  868. WindowsAPI.GetWindowRect(handle, out windowRect);
  869. return windowRect.Bottom - windowRect.Top;
  870. }
  871. }
  872. /// <summary>
  873. /// See <see cref="A_ScreenHeight"/>.
  874. /// </summary>
  875. public static int A_ScreenWidth
  876. {
  877. get
  878. {
  879. IntPtr handle = WindowsAPI.GetDesktopWindow(); /* get the hDC of the target window */
  880. WindowsAPI.RECT windowRect;
  881. WindowsAPI.GetWindowRect(handle, out windowRect);
  882. return windowRect.Right - windowRect.Left;
  883. }
  884. }
  885. /// <summary>
  886. /// Current 2-digit second (00-59).
  887. /// </summary>
  888. public static string A_Sec
  889. {
  890. get { return DateTime.Now.ToString("ss"); }
  891. }
  892. /// <summary>
  893. /// This variable contains a single space character.
  894. /// </summary>
  895. [Obsolete]
  896. public static string A_Space
  897. {
  898. get { return " "; }
  899. }
  900. /// <summary>
  901. /// The full path and name of the current user's Start Menu folder.
  902. /// </summary>
  903. public static string A_StartMenu
  904. {
  905. get { return Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); }
  906. }
  907. /// <summary>
  908. /// The full path and name of the all-users Start Menu folder.
  909. /// </summary>
  910. public static string A_StartMenuCommon
  911. {
  912. get { return Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); }
  913. }
  914. /// <summary>
  915. /// The full path and name of the Startup folder in the current user's Start Menu.
  916. /// </summary>
  917. public static string A_Startup
  918. {
  919. get { return Environment.GetFolderPath(Environment.SpecialFolder.Startup); }
  920. }
  921. /// <summary>
  922. /// The full path and name of the Startup folder in the all-users Start Menu.
  923. /// </summary>
  924. public static string A_StartupCommon
  925. {
  926. get { return Environment.GetFolderPath(Environment.SpecialFolder.Startup); }
  927. }
  928. /// <summary>
  929. /// Determines whether string comparisons are case sensitive.
  930. /// </summary>
  931. /// <value>
  932. /// <list type="bullet">
  933. /// <item><term>On</term>: <description>comparisons are case sensitive.</description></item>
  934. /// <item><term>Off</term>: <description>the letters A-Z are considered identical to their lowercase counterparts.</description></item>
  935. /// <item><term>Locale</term>: <description>comparisons are case insensitive according to the rules of the current locale.</description></item>
  936. /// </list>
  937. /// </value>
  938. [Obsolete]
  939. public static string A_StringCaseSense
  940. {
  941. get { return ToStringCaseSense(A_StringComparison);}
  942. set
  943. {
  944. switch (value.ToLowerInvariant())
  945. {
  946. case Keyword_On: _StringComparison = StringComparison.Ordinal; break;
  947. default: case Keyword_Off: _StringComparison = StringComparison.OrdinalIgnoreCase; break;
  948. case Keyword_Locale: _StringComparison = StringComparison.CurrentCulture; break;
  949. }
  950. }
  951. }
  952. /// <summary>
  953. /// The culture, case and sort rules to use when comparing strings.
  954. /// </summary>
  955. static StringComparison A_StringComparison
  956. {
  957. get { return _StringComparison ?? StringComparison.OrdinalIgnoreCase; }
  958. set { _StringComparison = value; }
  959. }
  960. /// <summary>
  961. /// This variable contains a single tab character.
  962. /// </summary>
  963. [Obsolete]
  964. public static string A_Tab
  965. {
  966. get { return "\t"; }
  967. }
  968. /// <summary>
  969. /// The full path and name of the folder designated to hold temporary files.
  970. /// </summary>
  971. public static string A_Temp
  972. {
  973. get { return Path.GetTempPath().TrimEnd(Path.DirectorySeparatorChar); }
  974. }
  975. /// <summary>
  976. /// Temporary file name.
  977. /// </summary>
  978. public static string A_TempFile
  979. {
  980. get { return Path.GetTempFileName(); }
  981. }
  982. /// <summary>
  983. /// The key name of the most recently executed hotkey or hotstring.
  984. /// </summary>
  985. public static string A_ThisHotkey
  986. {
  987. get { return keyboardHook == null ? null : keyboardHook.CurrentHotkey; }
  988. }
  989. /// <summary>
  990. /// The name of the menu from which A_ThisMenuItem was selected.
  991. /// </summary>
  992. public static string A_ThisMenu
  993. {
  994. get { return null; }
  995. }
  996. /// <summary>
  997. /// The name of the most recently selected custom menu item (blank if none).
  998. /// </summary>
  999. public static string A_ThisMenuItem
  1000. {
  1001. get { return null; }
  1002. }
  1003. /// <summary>
  1004. /// A number indicating the current position of A_ThisMenuItem within A_ThisMenu. The first item in the menu is 1, the second is 2, and so on. Menu separator lines are counted. This variable is blank if A_ThisMenuItem is blank or no longer exists within A_ThisMenu. It is also blank if A_ThisMenu itself no longer exists.
  1005. /// </summary>
  1006. public static string A_ThisMenuItemPos
  1007. {
  1008. get { return null; }
  1009. }
  1010. /// <summary>
  1011. /// The number of milliseconds since the computer was rebooted.
  1012. /// </summary>
  1013. public static int A_TickCount
  1014. {
  1015. get { return Environment.TickCount; }
  1016. }
  1017. /// <summary>
  1018. /// The number of milliseconds that have elapsed since the system last received keyboard, mouse, or other input. This is useful for determining whether the user is away. This variable will be blank unless the operating system is Windows 2000, XP, or beyond. Physical input from the user as well as artificial input generated by any program or script (such as the Send or MouseMove commands) will reset this value back to zero. Since this value tends to increase by increments of 10, do not check whether it is equal to another value. Instead, check whether it is greater or less than another value. For example: IfGreater, A_TimeIdle, 600000, MsgBox, The last keyboard or mouse activity was at least 10 minutes ago.
  1019. /// </summary>
  1020. public static string A_TimeIdle
  1021. {
  1022. get { return null; }
  1023. }
  1024. /// <summary>
  1025. /// Same as above but ignores artificial keystrokes and/or mouse clicks whenever the corresponding hook (keyboard or mouse) is installed. If neither hook is installed, this variable is equivalent to A_TimeIdle. If only one hook is present, only that one type of artificial input will be ignored. A_TimeIdlePhysical may be more useful than A_TimeIdle for determining whether the user is truly present.
  1026. /// </summary>
  1027. public static string A_TimeIdlePhysical
  1028. {
  1029. get { return null; }
  1030. }
  1031. /// <summary>
  1032. /// Time in ms that have elapsed since <see cref="A_PriorHotkey"/> was pressed. It will be -1 whenever <see cref="A_PriorHotkey"/> is blank.
  1033. /// </summary>
  1034. public static int A_TimeSincePriorHotkey
  1035. {
  1036. get { return keyboardHook == null || keyboardHook.PriorHotkey == null ? -1 : Environment.TickCount - keyboardHook.PriorHotkeyTime; }
  1037. }
  1038. /// <summary>
  1039. /// Time in ms that have elapsed since <see cref="A_ThisHotkey"/> was pressed. It will be -1 whenever <see cref="A_ThisHotkey"/> is blank.
  1040. /// </summary>
  1041. public static int A_TimeSinceThisHotkey
  1042. {
  1043. get { return keyboardHook == null || keyboardHook.CurrentHotkey == null ? -1 : Environment.TickCount - keyboardHook.CurrentHotkeyTime; }
  1044. }
  1045. /// <summary>
  1046. /// The current mode set by <code>SetTitleMatchMode</code>: <code>1</code>, <code>2</code>, <code>3</code>, or <code>RegEx</code>.
  1047. /// </summary>
  1048. public static string A_TitleMatchMode
  1049. {
  1050. get
  1051. {
  1052. int mode = _TitleMatchMode ?? 1;
  1053. return mode == 4 ? Keyword_RegEx : mode.ToString();
  1054. }
  1055. set
  1056. {
  1057. switch (value.ToLowerInvariant())
  1058. {
  1059. case "1": _TitleMatchMode = 1; break;
  1060. case "2": _TitleMatchMode = 1; break;
  1061. case "3": _TitleMatchMode = 1; break;
  1062. case Keyword_RegEx: _TitleMatchMode = 4; break;
  1063. }
  1064. }
  1065. }
  1066. /// <summary>
  1067. /// The current match speed (<code>fast</code> or <code>slow</code>) set by <code>SetTitleMatchMode</code>.
  1068. /// </summary>
  1069. public static string A_TitleMatchModeSpeed
  1070. {
  1071. get { return _TitleMatchModeSpeed ?? true ? Keyword_Fast : Keyword_Slow; }
  1072. set
  1073. {
  1074. switch (value.ToLowerInvariant())
  1075. {
  1076. case Keyword_Fast: _TitleMatchModeSpeed = true; break;
  1077. case Keyword_Slow: _TitleMatchModeSpeed = false; break;
  1078. }
  1079. }
  1080. }
  1081. /// <summary>
  1082. /// The logon name of the current user.
  1083. /// </summary>
  1084. public static string A_UserName
  1085. {
  1086. get { return Environment.UserName; }
  1087. }
  1088. /// <summary>
  1089. /// Current 1-digit day of the week (1-7). 1 is Sunday in all locales.
  1090. /// </summary>
  1091. public static int A_WDay
  1092. {
  1093. get { return (int)DateTime.Now.DayOfWeek + 1; }
  1094. }
  1095. /// <summary>
  1096. /// The current delay set by <code>SetWinDelay</code>.
  1097. /// </summary>
  1098. public static int A_WinDelay
  1099. {
  1100. get { return _WinDelay ?? 100; }
  1101. set { _WinDelay = value; }
  1102. }
  1103. /// <summary>
  1104. /// The Windows directory. For example: <code>C:\Windows</code>.
  1105. /// </summary>
  1106. public static string A_WinDir
  1107. {
  1108. get { return Environment.GetFolderPath(Environment.SpecialFolder.System); }
  1109. }
  1110. /// <summary>
  1111. /// The script's current working directory, which is where files will be accessed by default.
  1112. /// </summary>
  1113. public static string A_WorkingDir
  1114. {
  1115. get { return Environment.CurrentDirectory; }
  1116. set
  1117. {
  1118. if (!string.IsNullOrEmpty(value) && Directory.Exists(value))
  1119. Environment.CurrentDirectory = value;
  1120. }
  1121. }
  1122. /// <summary>
  1123. /// Current day of the year (1-366).
  1124. /// </summary>
  1125. public static int A_YDay
  1126. {
  1127. get { return DateTime.Now.DayOfYear; }
  1128. }
  1129. /// <summary>
  1130. /// Current 4-digit year (e.g. 2004).
  1131. /// </summary>
  1132. public static int A_Year
  1133. {
  1134. get { return DateTime.Now.Year; }
  1135. }
  1136. /// <summary>
  1137. /// Current year and week number (e.g. <code>200453</code>) according to ISO 8601.
  1138. /// </summary>
  1139. public static string A_YWeek
  1140. {
  1141. get { return DateTime.Now.ToString("yyyy") + Math.Floor((double)(DateTime.Now.DayOfYear / 12)); }
  1142. }
  1143. /// <summary>
  1144. /// See <see cref="A_Year"/>.
  1145. /// </summary>
  1146. public static int A_YYYY
  1147. {
  1148. get { return A_Year; }
  1149. }
  1150. /// <summary>
  1151. /// HTTP user agent for <see cref="URLDownloadToFile"/>.
  1152. /// </summary>
  1153. public static string A_UserAgent
  1154. {
  1155. get { return _UserAgent; }
  1156. set { _UserAgent = value; }
  1157. }
  1158. }
  1159. }