PageRenderTime 53ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/TutorialLaunch.htm

https://github.com/fincs/AutoHotkey_L-Docs
HTML | 40 lines | 37 code | 3 blank | 0 comment | 0 complexity | 940958d1dccca642550beb6c2016ce63 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <title>AutoHotkey Tutorial - Launch a program or document (continued)</title>
  8. <link href="static/theme.css" rel="stylesheet" type="text/css" />
  9. <script src="static/jquery.js" type="text/javascript"></script>
  10. <script src="static/tree.jquery.js" type="text/javascript"></script>
  11. <script src="static/content.js" type="text/javascript"></script>
  12. </head>
  13. <body>
  14. <h1>Tutorial - Launch a program or document (continued)</h1>
  15. <p>To have a program or document start off maximized, minimized, or hidden, consider the following <a href="Hotkeys.htm">hotkey</a> subroutine, which assigns the Win+Z hotkey to launch two instances of Notepad, the first maximized and the second minimized:</p>
  16. <pre>#z::
  17. Run, Notepad, , max
  18. Run, Notepad, , min
  19. return</pre>
  20. <p>To have a program use a specific folder as its working directory, consider this Win+C hotkey which creates a command prompt window in the specified directory:</p>
  21. <pre>#c::Run, %comspec% /k, C:\My Documents</pre>
  22. <p>In the above example, <a href="Variables.htm#ComSpec">comspec</a> is a built-in variable that resolves to C:\Windows\system32\cmd.exe on a typical system.</p>
  23. <p>To pass parameters, add them immediately after the name of the program or document as in these examples:</p>
  24. <pre>Run, %comspec% /c dir &gt;&quot;Output File.txt&quot;, C:\My Documents
  25. Run, Notepad.exe &quot;C:\My Documents\Address List.txt&quot;
  26. Run, &quot;<a href="Variables.htm#AhkPath">%A_AhkPath%</a>&quot; &quot;C:\Scripts\Test Script.ahk&quot; param1 &quot;param2 with spaces&quot; param3</pre>
  27. <p>In the second and third examples above, parameters with spaces in them are enclosed in quotes, which is generally the safest practice. By contrast, the working directory should not be enclosed in quotes even if it contains spaces, such as in the first example above.</p>
  28. <p>Certain special words known as <em>system verbs</em> are also supported. The first example below opens the Explorer's properties dialog for the indicated file. The second example prints the specified document.</p>
  29. <pre>Run, properties &quot;C:\Address List.txt&quot;
  30. Run, print &quot;C:\Address List.txt&quot;</pre>
  31. <p>Finally, <a href="commands/Run.htm">RunWait</a> sets the built-in <a href="misc/ErrorLevel.htm">ErrorLevel</a> variable to the exit code of the program it ran (it also waits for the program to finish and close). For example, the following displays a non-zero ErrorLevel because cmd.exe is indicating that a problem occurred:</p>
  32. <pre>RunWait, %comspec% /c dir c:\NonExistent.txt, , hide
  33. MsgBox, %ErrorLevel%</pre>
  34. <p>For more about launching programs and documents, see <a href="commands/Run.htm">Run/RunWait</a>.</p>
  35. <p><a href="Tutorial.htm">Return to the Tutorial Table of Contents</a></p>
  36. </body>
  37. </html>