PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/AutoHotkey.docset/Contents/Resources/Documents/commands/ControlGetText.htm

https://gitlab.com/ahkscript/Autohotkey.docset
HTML | 58 lines | 46 code | 12 blank | 0 comment | 0 complexity | 79beba7a5ec833730cdea90e3a841c75 MD5 | raw file
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>ControlGetText</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <link href="../static/theme.css" rel="stylesheet" type="text/css" />
  8. <script src="../static/content.js" type="text/javascript"></script>
  9. </head>
  10. <body>
  11. <h1>ControlGetText</h1>
  12. <p>Retrieves text from a control.</p>
  13. <pre class="Syntax">ControlGetText, OutputVar [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]</pre>
  14. <h3>Parameters</h3>
  15. <dl>
  16. <dt>OutputVar</dt>
  17. <dd><p>The name of the variable in which to store the retrieved text.</p></dd>
  18. <dt>Control</dt>
  19. <dd><p>Can be either ClassNN (the classname and instance number of the control) or the control's text, both of which can be determined via Window Spy. When using text, the matching behavior is determined by <a href="SetTitleMatchMode.htm">SetTitleMatchMode</a>. If this parameter is blank or omitted, the target window's topmost control will be used.</p>
  20. <p>To operate upon a control's HWND (window handle), leave the <em>Control</em> parameter blank and specify <code>ahk_id %ControlHwnd%</code> for the <em>WinTitle</em> parameter (this also works on hidden controls even when <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> is Off). The HWND of a control is typically retrieved via <a href="ControlGet.htm#Hwnd">ControlGet Hwnd</a>, <a href="MouseGetPos.htm">MouseGetPos</a>, or <a href="DllCall.htm">DllCall</a>.</p></dd>
  21. <dt>WinTitle</dt>
  22. <dd><p>A window title or other criteria identifying the target window. See <a href="../misc/WinTitle.htm">WinTitle</a>.</p></dd>
  23. <dt>WinText</dt>
  24. <dd><p>If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if <a href="DetectHiddenText.htm">DetectHiddenText</a> is ON.</p></dd>
  25. <dt>ExcludeTitle</dt>
  26. <dd><p>Windows whose titles include this value will not be considered.</p></dd>
  27. <dt>ExcludeText</dt>
  28. <dd><p>Windows whose text include this value will not be considered.</p></dd>
  29. </dl>
  30. <h3>ErrorLevel</h3>
  31. <p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
  32. <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if there was a problem or 0 otherwise.</p>
  33. <h3>Remarks</h3>
  34. <p>Note: To retrieve text from a ListView, ListBox, or ComboBox, use <a href="ControlGet.htm#List">ControlGet List</a> instead.</p>
  35. <p>If the retrieved text appears to be truncated (incomplete), try using <code><a href="VarSetCapacity.htm">VarSetCapacity(OutputVar, 55)</a></code> prior to ControlGetText [replace 55 with a size that is considerably longer than the truncated text]. This is necessary because some applications do not respond properly to the WM_GETTEXTLENGTH message, which causes AutoHotkey to make the output variable too small to fit all the text.</p>
  36. <p>The amount of text retrieved is limited to a variable's maximum capacity (which can be changed via the <a href="_MaxMem.htm">#MaxMem</a> directive). As a result, this command might use a large amount RAM if the target control (e.g. an editor with a large document open) contains a large quantity of text. However, a variable's memory can be freed after use by assigning it to nothing, i.e. <code>OutputVar =</code>.</p>
  37. <p>Text retrieved from most control types uses carriage return and linefeed (`r`n) rather than a solitary linefeed (`n) to mark the end of each line.</p>
  38. <p>It is not necessary to do <code>SetTitleMatchMode Slow</code> because ControlGetText always retrieves the text using the slow method (since it works on a broader range of control types).</p>
  39. <p>To retrieve a list of all controls in a window, use <a href="WinGet.htm#ControlList">WinGet ControlList</a>.</p>
  40. <p>Window titles and text are case sensitive. Hidden windows are not detected unless <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> has been turned on.</p>
  41. <h3>Related</h3>
  42. <p><a href="ControlSetText.htm">ControlSetText</a>, <a href="WinGetText.htm">WinGetText</a>, <a href="Control.htm">Control</a>, <a href="ControlGet.htm">ControlGet</a>, <a href="ControlMove.htm">ControlMove</a>, <a href="ControlFocus.htm">ControlFocus</a>, <a href="ControlClick.htm">ControlClick</a>, <a href="ControlSend.htm">ControlSend</a>, <a href="_MaxMem.htm">#MaxMem</a></p>
  43. <h3>Example</h3>
  44. <pre class="NoIndent">ControlGetText, OutputVar, Edit1, Untitled -</pre>
  45. </body>
  46. </html>