Outlines a rectangular region of the screen with a colored, click-through border.
This class is exported by the KS module.
HighlightObj := Highlight(X, Y, W, H, Color, Thickness)
Type: Integer
The top-left corner of the rectangle to outline, in screen coordinates. If omitted, 0 is used.
Type: Integer
The width and height of the rectangle, in pixels. If omitted, 0 is used, in which case nothing is shown until a size is set.
Type: String or Integer
The border color, as a color name such as "Lime", a hexadecimal string such as "FF0000", or a 0xRRGGBB integer. If omitted, red is used.
Type: Integer
The border thickness in pixels. If omitted, 2 is used. Zero hides the border.
Type: Highlight
Returns a new Highlight object. Constructing one does not display anything; call Show to put it on screen.
The border is drawn just outside the given rectangle, so the rectangle itself remains fully visible. Coordinates are absolute screen pixels, matching the coordinates produced by screen-inspection APIs.
The overlay is click-through and always on top: it never takes focus and never intercepts mouse input, so the outlined application continues to work normally while it is displayed.
Each Highlight object owns exactly one overlay, which is created on the first Show and then reused. Moving an outline repositions that overlay rather than rebuilding it, so a highlight can be moved continuously without flicker.
There is no global registry of highlights. The object is released when Destroy is called or when the last reference to it goes away, at which point the overlay is torn down automatically. Assign it to a variable that stays alive for as long as the outline should remain visible.
On high-DPI displays the thickness is scaled to the display containing the rectangle, so a 2-pixel border looks the same on every monitor.
All properties can be changed while the outline is displayed; the change takes effect immediately.
HighlightObj.X: The left edge of the rectangle, in screen pixels.
HighlightObj.Y: The top edge of the rectangle, in screen pixels.
HighlightObj.W: The width of the rectangle, in pixels.
HighlightObj.H: The height of the rectangle, in pixels.
HighlightObj.Color: The border color. It can be set with a color name, a hexadecimal string or a 0xRRGGBB integer, and always reads back as a six-digit hexadecimal string such as "FF0000".
HighlightObj.Thickness: The border thickness in pixels. Zero hides the border.
HighlightObj.Visible: Returns 1 if the outline is currently on screen and 0 otherwise. This property is read-only.
HighlightObj.Hwnd: The window handle of the overlay, or 0 where the platform draws the overlay without a client-side window. This property is read-only.
HighlightObj.Show(X, Y, W, H): Displays the outline, creating the overlay on first use, and returns immediately without blocking. Any coordinates given replace the current ones first, so Show doubles as a move or resize.
HighlightObj.Move(X, Y, W, H): Changes the rectangle without changing visibility. All parameters are optional, so Move(, , 300, 200) resizes without moving. On a hidden outline this only records the new geometry, to be used by the next Show.
HighlightObj.Hide(): Removes the outline from the screen but keeps the overlay, so a later Show is immediate.
HighlightObj.Destroy(): Destroys the overlay and frees its resources. It is safe to call more than once, and the object can be reused afterwards: a later Show builds a new overlay.
Outlines a region for two seconds.
#Import "Ks" { Highlight }
Hl := Highlight(100, 100, 300, 200)
Hl.Show()
Sleep 2000
Hl.Destroy()
Follows the active window until Escape is pressed. Because the overlay is reused, the outline tracks the window without flicker.
#Import "Ks" { Highlight }
Hl := Highlight(0, 0, 0, 0, "Lime", 3)
Hl.Show()
SetTimer Track, 100
Track()
{
if WinExist("A")
{
WinGetPos &X, &Y, &W, &H, "A"
Hl.Move(X, Y, W, H)
}
}
Esc::ExitApp