TranspTester: A Transparency Tester

Post your working scripts, libraries and tools
User avatar
lmstearn
Posts: 330
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

TranspTester: A Transparency Tester

02 Sep 2019, 08:06

Good evening,

Looking for a way of testing transparency?

A common requisite of an operating system is for the provision of a raw function sandbox, somewhere to mix, match and combine the effects of functions for the specific task on hand. In the attempt to render transparent forms, this script offers up a hodgepodge made from basic GUI elements, three functions along with their various conditions and flags:
  • WinSet, ExStyle, ...
  • WinSet, Transparent, ...
  • WinSet TransColor, ...
  • SetLayeredWindowAttributes
  • UpdateLayeredWindow
The effects of moving the rendered forms across the default desktop is also examined, bearing in mind the virtual desktop in a multi-monitor environment requires additional consideration.

TranspTester.JPG
TranspTester.JPG (19.08 KiB) Viewed 508 times
Code
Download at Github.

Usage:
Select controls, if any, for the tester form, then adjust the TranspTester settings, and press Go. Drag the form around with the mouse in the titlebar area. When the form with an overlay is closed or cancelled, the button is clicked to show the underlay form for the purposes of comparison.
Esc mimics the Cancel button, but it also quits the program from any msgbox interrupt, F1 to reload either the test form or gui in focus.
Check Output Vars to output styles & attributes of the underlay form.
Check SO Example to handle the content offered at these Stack Overflow and AutoHotkey questions.
Check Use Setlayer to use the SetLayeredWindowAttributes function exclusively for Layering.

Notes:
In TranspTester, the underlay form is always used to render all of the desired content, the overlay form serves as a filter alone. It can be seen that applying effects to the overlay may not be necessary, and the inclusion of any other overlay form is for no other purpose than an extra TransColor pixel colour.
Enumeration of the ActiveX controls was intended for the retrieval of the child window styles, at least one codebank would play host for a better method. In most cases the transparency methods in the parent window override those of the children, but the validity of this assertion remains to be tested.
On W10, with no overlay form, the tester ActiveX form can be clicked-through on TransColor, with the titlebar also click-through when Layered. There is no click-through on a Transparent selection alone, because the wrapped SetLayeredWindowAttributes function does not use ULW_COLORKEY.
With image underlays, click-through occurs on Layered with Use Setlayer unchecked.
Although slow mouse strokes work well with the sliders on this machine, adjustments were made to the mouse speed in an attempt to address suspected small slider (+ interval) length along with mouse driver issues.

Wishlist:
Update the showing target form(s) dynamically with the settings on the main gui.
Because UpdateLayeredWindow is called throughout window moves, consider algorithms for varying colours and transparency factors to demonstrate the function's capabilities.
Consider the inclusion of GDIPlus functions.

Credits:
Many thanks to the awesome AHK community. Helpful threads are referenced as comments in the script.

Further reading:
1998 Dr. Dobbs Article on Transparency
Window Features
High-Performance Window Layering Using the Windows Composition Engine
Reduce Graphics Flicker with Double Buffering for Forms and Controls
Proof of Concept: Transparent Buttons
Proof Of Concept: Scrollable image list
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Return to “Scripts and Functions”

Who is online

Users browsing this forum: comvox and 149 guests