After At all times-On-Prime and Translucent Home windows, Use the WinSet Command to Make a Mouse-Click on Clear Assist Window, Plus a Dialogue of the Mysterious (and Complicated) Microsoft Window Types/ExStyles (WS_XXX and WS_EX_XXX)
The WinSet command presents many extra choices than merely setting home windows to AlwaysOnTop and Clear. As I reviewed WinSet, I spotted that variations on the command may be value exploring for different functions. Along with sending a window to the underside or bringing it to the highest, as a window manipulation software WinSet presents a wide range of choices for adjusting Window Types (WinSet, Model and WinSet, ExStyle), click-through-ness (or mouse-click clear—making clicks drops to the window beneath— WinSet, TransColor), and altering the window form (WinSet, Area).
* * *
New to AutoHotkey? See “Introduction to AutoHotkey: A Review and Guide for Beginners.”
Get this overview and introductory e-book free, AutoHotkey Methods You Should Do with Home windows!
* * *
The WinSet, Model/ExStyle Command
The WinSet, Model/ExStyle command accesses particular Window Model (WS_XXXX) codes constructed into Microsoft Home windows. Showing as hexadecimal codes (a 0x previous the quantity signifies hexadecimal), understanding what they’re and tips on how to use them takes somewhat extra effort. From the AutoHotkey on-line documentation:
WinSet, Model, -0xC00000, A ; Take away title bar (WS_CAPTION). WinSet, ExStyle, ^0x80, WinTitle ; Removes/provides window ; (or toggles) from alt-tab record (WS_EX_TOOLWINDOW).
The WinSet command implements the brand new type with the assigned Hex code preceded by both a minus signal – , a plus signal + (to show off or on the type), or a caret ^ for toggling a setting on and off. Though easy to make use of, the one record of Window Model codes available for AutoHotkey fell wanting my expectations. The record contains just a few of the Window Types (WS_XXXX) and not one of the Prolonged Window Types (WS_EX_XXXX)—which occurs to embrace the code for making a window mouse click-through-able.
I didn’t begin to grasp how WinSet, Model/ExStyle truly works till I discovered this AutoHotkey script by djcpal1 within the previous AutoHotkey discussion board. The routine opens a GUI window named windowstyles which shows lots of the extra helpful Types/ExStyles applied for the window beneath the hovering mouse cursor.
The knowledge inside windowstyles, whereas cryptic, presents perception into tips on how to use the Model/ExStyle codes. These codes come from the Window Types (WS_XXXX) and Prolonged Window Types (WS_EX_XXXX) settings out there in Microsoft Home windows. The picture above shows each the hexadecimal code and the related WS_XXXX or WS_EX_XXXX setting title. Designating the actual type with the code within the WinSet, Model/ExStyle command tells AutoHotkey which setting to alter. However instantly utilizing these codes can get sophisticated.
Word: To get a partial understanding of the impact of every Window Model, test the linked Window Model pages above—though the descriptions don’t all the time assist. Merely inserting the code into the WinSet command might yield a desired outcome, however it usually will get extra complicated than that.
For instance, Microsoft assigned WS_EX_TOPMOST (0x8) because the Window Model for always-on-top. You may assume that this is able to present another technique to toggle a window always-on-top with WinSet, nevertheless further necessities seem within the Microsoft documentation (“use the SetWindowPos function”)—which makes it much more complicated. This can be why AutoHotkey handles it instantly by together with the AlwaysOnTop possibility in WinSet, in addition to, different instructions.
The best approach to decide the usability of a Window Model could also be by making an attempt it. I discovered that toggling the window resizing setting (WS_SIZEBOX) works:
WinSet, Model, ^0x40000, A
However in lots of circumstances, altering WS_XXXX values for an lively window wouldn’t take impact until there have been changes made to different settings at the side of it. Many instances values have to be set earlier than the window will get displayed.
Usually Microsoft explanations confuse as a result of their use of ambiguous phrases. I bumped into this when tips on how to make a window mouse-click clear (or click-through-able).
Making a Window Clear Vs. Mouse-Click on Clear
Whereas, as mentioned final time, the WinSet command contains an possibility for setting the transparency of a window (WinSet, Clear,…), it doesn’t embrace a direct possibility for permitting mouse clicks to drop via a complete window. The WinSet, TransColor command (a subject for subsequent time) presents mouse-click invisibility for specified colours, however not your complete window. For that we flip to WinSet, ExStyle. However first, the phrases clear and invisible want clarifying.
Microsoft has achieved a horrible job of naming varied Window Types. Within the Microsoft documentation you see phrases corresponding to clear and invisible utilized in a wide range of alternative ways with little or no clarification. However for our functions, I take advantage of two particular sorts of transparency or invisibility. The primary is opaqueness which denotes the extent of visible transparency. Visible transparency defines how effectively you’ll be able to see via one window to a window beneath.
The second type of transparency describes mouse-click transparency. Meaning any click on of the mouse on the window drops via to the window beneath. The window is invisible to the mouse, however to not the attention. The excellence is vital.
You may anticipate that WS_EX_TRANSPARENT units how effectively you’ll be able to see via a window. It doesn’t. Whether or not a window is translucent or opaque is wrapped up within the WS_EX_LAYER function. To permit any window to grow to be translucent, AutoHotkey initiates WS_EX_LAYER settings with the WinSet, Clear command—dealing with the opposite capabilities wanted to set the transparency degree.
When turned on, WS_EX_TRANSPARENT permits mouse clicks to drop via a complete window—though WS_EX_LAYER should first be set on for it to work. AutoHotkey doesn’t embrace a mouse-click clear possibility, due to this fact the WinSet, ExStyle command have to be used to make a complete window mouse-click clear.
Word: The WinSet, TransColor command does provide mouse-click transparency for a single shade, however not for the opposite colours within the window. The usage of the time period TransColor tends so as to add to the confusion. Subsequent time, I talk about a sensible use for the TransColor mouse-click clear possibility.
Toggling Mouse-Click on Transparency On and Off
Final time I referenced a script I discovered within the previous AutoHotkey discussion board for making a window always-on-top or clear. In that very same script you’ll discover Hotkeys for altering any window to mouse-click clear and again once more. The next modified model of these Hotkeys embrace one for turning mouse-click transparency on and one for turning it off:
^!x:: ; Make mouse-click clear WinGet, currentWindow, ID, A WinSet, ExStyle, +0x80020, ahk_id %currentWindow% Return ^!z:: ; Undo mouse-click clear WinSet, ExStyle, -0x20, ahk_id %currentWindow% Return
The Hotkey mixture CTRL+ALT+X (^!x) activates mouse-click transparency by first grabbing the lively window ID with the WinGet command, putting it within the variable currentWindow, then setting mouse-click transparency on with the WinSet, ExStyle command.
Initially, I discovered the ExStyle code used on this instance perplexing. I couldn’t discover a reference to 0x80020 anyplace within the Microsoft documentation. I ultimately realized that the code was a mixture of two codes. The WS_EX_LAYER window type (0x80000) and the WS_EX_TRANSPARENT home windows type (0x20). The window layer type have to be turned on for the mouse-click clear mode to work.
If a window already has WS_EX_LAYER set on, then the AutoHotkey line solely requires the mouse-click clear code (0x20). Subsequently, the second Hotkey (CTRL+ALT+Z—^!z), which turns the mouse-click transparency off, solely wants that shortened ExStyle code (-0x20).
Word: The unique script additionally features a MouseGetPos command within the restore Hotkey routine. Nevertheless, this command serves no function since MouseGetPos gained’t detect a mouse-click clear window. Plus, these on and off Hotkeys solely work with one window at a time since utilizing the mouse-click clear Hotkey with one other window resets the worth of the variable currentWindow.
The next line of code presents a extra common toggle for mouse-click transparency:
^#F12::WinSet, ExStyle, ^0x80020, A
Whereas this different method works with any lively window (A), it creates an issue when toggling off the click-through function—the window have to be lively, but it could actually’t be activated with a mouse click on. One answer entails first activating the mouse-click clear window from this system icon within the Home windows Taskbar.
At all times-On-Prime, Clear, Mouse-Click on-By means of Assist Home windows
All this dialogue a couple of distinctive window function will get fairly concerned, however does it have any sensible software? How can I take advantage of these options in a sensible approach?
As an preliminary thought, you’ll be able to create Assist home windows which gained’t intrude together with your work.
First, the Assist window should pop-up always-on-top so it doesn’t get misplaced. Second, you must have the ability to see the working window beneath. Third, the pop-up mustn’t intrude with mouse-click operations.
The next instance script creates a Assist GUI window utilizing the WinSet command to set all three of the above circumstances (AlwaysOnTop, visible transparency, and mouse-click transparency) whereas, since we will’t take away the window with a mouse-click, together with an vital escape Hotkey to shut the Assist pop-up:
^F12:: Gui, Add, Textual content,, 1. Sit up Gui, Add, Textual content,, 2. Have a look at the keyboard Gui, Add, Textual content,, 3. Drink a cup of espresso Gui, Add, Textual content,, CTRL+ALT+F12 to shut assist window. Gui, Present, x800 y20, Clear Assist Menu WinGet, active_id, ID, Clear Assist Menu WinSet, AlwaysOnTop, On, ahk_id %active_id% WinSet, Clear, 190, ahk_id %active_id% WinSet, ExStyle, +0x80020,ahk_id %active_id% Return ^!F12::Gui, Destroy
Though this instance creates a selected GUI window, you need to use the person Hotkeys mentioned on this and former blogs to set these circumstances for any lively Assist window.
The next line of code, when included on the prime of the GUI setup, demonstrates another technique for setting a few these circumstances in a GUI window :
Gui, +AlwaysOnTop +E0x20
This line forces the GUI always-on-top and makes it mouse-click clear (+E0x20—the Hex code), nevertheless an addition possibility for setting GUI visible transparency doesn’t exist. Utilizing the WinSet command as proven within the preliminary instance is important.
Subsequent time, a have a look at the WinSet, TransColor command with a sensible instance which presents mouse-click transparency and visible transparency for a single shade.