Hi,
I've written a small function to determine if a window is visible or not.
Requestedby me a long time ago, but never got implemented, so I thought I'd write my own
Code:
IsWindowVisible(p_WindowTitle)
{
WinGet, Style, Style, % p_WindowTitle
Transform, IsVisible, BitAnd, %Style%, 0x10000000 ; 0x10000000 is WS_VISIBLE.
return IsVisible
}
Here's its use in another function. This one toggles the visiblity of a window. i.e. shows the window if it's hidden, and hides it if it's visible:
Code:
ToggleWindowVisibility(p_WindowTitle)
{
if ( IsWindowVisible(p_WindowTitle) )
{
WinHide, % p_WindowTitle
}
else
{
WinShow, % p_WindowTitle
WinActivate, % p_WindowTitle
}
}
Nothing major, but putting even 2 - 3 lines of code into a function, makes scripts more readable, reduces error, and creates central points of control so that bugs need to be fixed in only one place.