PageRenderTime 58ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://gitlab.com/ahkscript/Autohotkey.docset
HTML | 144 lines | 125 code | 19 blank | 0 comment | 0 complexity | 6032ce2e1c5ac91a0941b6aac33bc7da MD5 | raw file
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>WinSet</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>WinSet</h1>
  12. <p>Makes a variety of changes to the specified window, such as &quot;always on top&quot; and transparency.</p>
  13. <pre class="Syntax">WinSet, Attribute, Value [, WinTitle, WinText, ExcludeTitle, ExcludeText]</pre>
  14. <h3>Parameters</h3>
  15. <dl>
  16. <dt>Attribute, Value</dt>
  17. <dd><p>See list below.</p></dd>
  18. <dt>WinTitle</dt>
  19. <dd><p>A window title or other criteria identifying the target window. See <a href="../misc/WinTitle.htm">WinTitle</a>.</p></dd>
  20. <dt>WinText</dt>
  21. <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>
  22. <dt>ExcludeTitle</dt>
  23. <dd><p>Windows whose titles include this value will not be considered.</p></dd>
  24. <dt>ExcludeText</dt>
  25. <dd><p>Windows whose text include this value will not be considered.</p></dd>
  26. </dl>
  27. <h3>Attribute, Value</h3>
  28. <p id="AlwaysOnTop"><strong>AlwaysOnTop, [On|Off|Toggle]</strong>: Makes a window stay on top of all other windows. Use ON to turn on the setting, OFF to turn it off, or TOGGLE to set it to the opposite of its current state. If omitted, it defaults to TOGGLE. The word Topmost can be used in place of AlwaysOnTop.</p>
  29. <p><strong>Bottom</strong>: Sends a window to the bottom of stack; that is, beneath all other windows. The effect is similar to pressing Alt-Escape. For example: <code>WinSet, Bottom,, WinTitle</code>.</p>
  30. <p><strong>Top</strong>: Brings a window to the top of the stack without explicitly <a href="WinActivate.htm">activating</a> it. However, the system default settings will probably cause it to activate in most cases. In addition, this command may have no effect due to the operating system's protection against applications that try to steal focus from the user (it may depend on factors such as what type of window is currently active and what the user is currently doing). One possible work-around is to make the window briefly <a href="#AlwaysOnTop">AlwaysOnTop</a>, then turn off AlwaysOnTop.</p>
  31. <p><strong>Disable</strong> or <strong>Enable</strong>: Disables or enables a window (respectively). When a window is disabled, the user cannot move it or interact with its controls. In addition, disabled windows are omitted from the alt-tab list.</p>
  32. <p id="Redraw"><strong>Redraw</strong>: Attempts to update the appearance/contents of a window by informing the OS that the window's rectangle needs to be redrawn. If this method does not work for a particular window, try <a href="WinMove.htm">WinMove</a>. If that does not work, try the following:</p>
  33. <pre><a href="WinHide.htm">WinHide</a>, WinTitle
  34. <a href="WinShow.htm">WinShow</a>, WinTitle</pre>
  35. <p><strong>Style, N</strong> <u>or</u> <strong>ExStyle, N</strong>: Changes the style or extended style of a window, respectively. If the first character of <strong>N</strong> is a plus or minus sign, the style(s) in <strong>N</strong> are added or removed, respectively. If the first character is a caret (^), the style(s) in N are each toggled to the opposite state. If the first character is a digit, the window's style is overwritten completely; that is, it becomes <strong>N</strong>.</p>
  36. <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 upon failure and 0 upon success. Failure occurs if the target window is not found or the style is not allowed to be applied.</p>
  37. <p>After applying certain style changes to a visible window, it might be necessary to redraw the window using <code>WinSet Redraw</code> (see below). Finally, the <a href="../misc/Styles.htm">styles table</a> lists some of the common style numbers. Examples:</p>
  38. <pre>WinSet, Style, -0xC00000, A <em>; Remove the active window's title bar (WS_CAPTION).</em>
  39. WinSet, ExStyle, ^0x80, WinTitle <em>; Toggle the WS_EX_TOOLWINDOW attribute, which removes/adds the window from the alt-tab list.</em></pre>
  40. <h3 id="region">WinSet, Region [, Options, WinTitle, ...]</h3>
  41. <p>Changes the shape of a window to be the specified rectangle, ellipse, or polygon. If the <em>Options</em> parameter is blank, the window is restored to its original/default display area. Otherwise, one or more of the following options can be specified, each separated from the others with space(s):</p>
  42. <p><strong>Wn</strong>: Width of rectangle or ellipse. For example: <code>w200</code>.<br>
  43. <strong>Hn</strong>: Height of rectangle or ellipse. For example: <code>h300</code>.<br>
  44. <strong>X-Y</strong>: Each of these is a pair of X/Y coordinates. For example, <code>200-0</code> would use 200 for the X coordinate and 0 for the Y.<br>
  45. <strong>E</strong>: Makes the region an ellipse rather than a rectangle. This option is valid only when <strong>W</strong> and <strong>H</strong> are present.<br>
  46. <strong>R[w-h]</strong>: Makes the region a rectangle with rounded corners. For example, <code>R30-30</code> would use a 30x30 ellipse for each corner. If <strong>w-h</strong> is omitted, 30-30 is used. <strong>R</strong> is valid only when <strong>W</strong> and <strong>H</strong> are present.</p>
  47. <p><strong>Rectangle or ellipse</strong>: If the <strong>W</strong> and <strong>H</strong> options are present, the new display area will be a rectangle whose upper left corner is specified by the first (and only) pair of <strong>X-Y</strong> coordinates. However, if the <strong>E</strong> option is also present, the new display area will be an ellipse rather than a rectangle. For example: <code>WinSet, Region, 50-0 W200 H250 E, WinTitle</code>.</p>
  48. <p><strong>Polygon</strong>: When the <strong>W</strong> and <strong>H</strong> options are absent, the new display area will be a polygon determined by multiple pairs of <strong>X-Y</strong> coordinates (each pair of coordinates is a point inside the window relative to its upper left corner). For example, if three pairs of coordinates are specified, the new display area will be a triangle in most cases. The order of the coordinate pairs with respect to each other is sometimes important. In addition, the word <strong>Wind</strong> maybe be present in <em>Options</em> to use the winding method instead of the alternating method to determine the polygon's region.</p>
  49. <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 upon failure and 0 upon success. Failure occurs when: 1) the target window does not exist; 2) one or more <em>Options</em> are invalid; 3) more than 2000 pairs of coordinates were specified; or 4) the specified region is invalid or could not be applied to the target window.</p>
  50. <p>See the bottom of this page for examples of how to use this command.</p>
  51. <h3 id="trans">WinSet, Transparent, N, WinTitle</h3>
  52. <p>Makes a window semi-transparent. Specify for <em>N</em> a number between 0 and 255 to indicate the degree of transparency: 0 makes the window invisible while 255 makes it opaque. Transparency may be turned off completely for a window by specifying the word OFF. This is different than specifying 255 because it may improve performance and reduce usage of system resources.</p>
  53. <p id="TransLimit"><strong>Known Limitations for Transparent and <a href="#TransColor">TransColor</a></strong>:</p>
  54. <ul>
  55. <li>They have no effect on a window that lacks a caption (title bar) and lacks the <a href="#AlwaysOnTop">always-on-top</a> property. For <a href="Gui.htm">GUI windows</a>, this can be solved by removing the caption only after making the window transparent. Alternatively, the following properties allow transparency to take effect: <code><a href="Gui.htm#Options">Gui -Caption +ToolWindow</a></code>.</li>
  56. <li>Setting &quot;Transparent&quot; to 255 prior to turning it off might avoid window redrawing problems such as a black background. If the window still fails to be redrawn correctly, see <a href="#Redraw">Redraw</a> for a possible workaround.</li>
  57. <li>To change a window's existing <a href="#TransColor">TransColor</a>, it may be necessary to turn off transparency before making the change.</li>
  58. </ul>
  59. <p><strong>Tip</strong>: To make the task bar transparent, use <code>WinSet, Transparent, 150, ahk_class Shell_TrayWnd</code>. Similarly, to make the Start Menu transparent, follow this example:</p>
  60. <pre>DetectHiddenWindows, on
  61. WinSet, Transparent, 150, ahk_class BaseBar <em>; To make the Start Menu's submenus transparent, also include the script below.</em></pre>
  62. <p>To make all or selected menus on the entire system transparent, keep a script such as the following always running. Note that although such a script cannot make its own menus transparent, it can make those of other scripts transparent:</p>
  63. <pre>#Persistent
  64. SetTimer, WatchForMenu, 5
  65. return <em>; End of auto-execute section.</em>
  66. WatchForMenu:
  67. DetectHiddenWindows, on <em>; Might allow detection of menu sooner.</em>
  68. IfWinExist, ahk_class #32768
  69. WinSet, Transparent, 150 <em>; Uses the window found by the above line.</em>
  70. return</pre>
  71. <h3 id="TransColor">WinSet, TransColor, Color [N], WinTitle</h3>
  72. <p>Makes all pixels of the chosen color invisible inside the target window, which allows the contents of the window behind it to show through. If the user clicks on an invisible pixel, the click will &quot;fall through&quot; to the window behind it. Specify for <em>Color</em> a color name or RGB value (see the <a href="Progress.htm#colors">color chart</a> for guidance, or use <a href="PixelGetColor.htm">PixelGetColor</a> in its RGB mode). To additionally make the visible part of the window partially transparent, append a space (not a comma) followed by the transparency level (0-255). For example: <code>WinSet, TransColor, EEAA99 150, WinTitle</code>.</p>
  73. <p>TransColor is often used to create on-screen displays and other visual effects. There is an example of an on-screen display <a href="Gui.htm#OSD">at the bottom of the Gui page</a>.</p>
  74. <p>The word OFF may be specified to completely turn off transparency for a window. Both of the following are identical in function:</p>
  75. <pre>WinSet, Transparent, Off, WinTitle
  76. WinSet, TransColor, Off, WinTitle</pre>
  77. <p>Known Limitations: See the list <a href="#TransLimit">above</a>.</p>
  78. <h3>Remarks</h3>
  79. <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is not changed by this command except where indicated above.</p>
  80. <p>Although transparency is supported on Windows 2000/XP or later, retrieving the current transparency settings of a window is possible only on Windows XP or later (via <a href="WinGet.htm">WinGet</a>).</p>
  81. <p>A script's <a href="SplashTextOn.htm">SplashText</a> window can be made non-AlwaysOnTop via:</p>
  82. <pre>WinSet, AlwaysOnTop, Off, My Splash Window Title</pre>
  83. <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>
  84. <h3>Related</h3>
  85. <p><a href="WinGet.htm">WinGet</a>, <a href="WinHide.htm">WinHide</a>, <a href="WinSetTitle.htm">WinSetTitle</a>, <a href="WinMove.htm">WinMove</a>, <a href="WinActivate.htm">WinActivate</a>, <a href="Control.htm">Control</a></p>
  86. <h3>Examples</h3>
  87. <pre class="NoIndent">WinSet, Transparent, 200, Untitled - Notepad <em>; Make the window a little bit transparent.</em>
  88. WinSet, TransColor, White, Untitled - Notepad <em>; Make all white pixels invisible.</em>
  89. WinSet, AlwaysOnTop, toggle, Calculator <em>; Toggle the always-on-top status of Calculator.</em>
  90. <em>; Longer Example:
  91. ; Here are some hotkeys that demonstrate the effects of &quot;Transparent&quot; and
  92. ; &quot;TransColor&quot;. NOTE: If you press one of the hotkeys while the mouse cursor
  93. ; is hovering over a pixel that is invisible as a result of TransColor, the window
  94. ; visible beneath that pixel will be acted upon instead! Also, Win+G will
  95. ; have an effect only on Windows XP because retrieval of transparency settings
  96. ; is not supported by Windows 2000:</em>
  97. #t:: <em>; Press Win+T to make the color under the mouse cursor invisible.</em>
  98. MouseGetPos, MouseX, MouseY, MouseWin
  99. PixelGetColor, MouseRGB, %MouseX%, %MouseY%, RGB
  100. <em>; In seems necessary to turn off any existing transparency first:</em>
  101. WinSet, TransColor, Off, ahk_id %MouseWin%
  102. WinSet, TransColor, %MouseRGB% 220, ahk_id %MouseWin%
  103. return
  104. #o:: <em>; Press Win+O to turn off transparency for the window under the mouse.</em>
  105. MouseGetPos,,, MouseWin
  106. WinSet, TransColor, Off, ahk_id %MouseWin%
  107. return
  108. #g:: <em>; Press Win+G to show the current settings of the window under the mouse.</em>
  109. MouseGetPos,,, MouseWin
  110. WinGet, Transparent, Transparent, ahk_id %MouseWin%
  111. WinGet, TransColor, TransColor, ahk_id %MouseWin%
  112. ToolTip Translucency:`t%Transparent%`nTransColor:`t%TransColor%
  113. return
  114. <em>; Examples of &quot;WinSet Region&quot;:</em>
  115. WinSet, Region, 50-0 W200 H250, WinTitle <em>; Make all parts of the window outside this rectangle invisible.</em>
  116. WinSet, Region, 50-0 W200 H250 R40-40, WinTitle <em>; Same as above but with corners rounded to 40x40.</em>
  117. WinSet, Region, 50-0 W200 H250 E, WinTitle <em>; An ellipse instead of a rectangle.</em>
  118. WinSet, Region, 50-0 250-0 150-250, WinTitle <em>; A triangle with apex pointing down.</em>
  119. WinSet, Region,, WinTitle <em>; Restore the window to its original/default display area.</em>
  120. <em>; Here is a region with a more complex area. It creates a see-through rectangular hole inside a window.
  121. ; There are two rectangles specified below: an outer and an inner. Each rectangle consists of 5 pairs
  122. ; of X/Y coordinates because the first pair is repeated at the end to &quot;close off&quot; each rectangle.</em>
  123. WinSet, Region, 0-0 300-0 300-300 0-300 0-0 100-100 200-100 200-200 100-200 100-100, WinTitle</pre>
  124. </body>
  125. </html>