Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Tiny "IsWindowVisible" function


  • Please log in to reply
3 replies to this topic
mario_a
  • Members
  • 52 posts
  • Last active: Jul 05 2011 06:23 PM
  • Joined: 12 Dec 2004
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 :)

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:

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.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Requestedby me a long time ago, but never got implemented, so I thought I'd write my own :)

Nice. Thanks for sharing it, and sorry it took so long to add function support.

mario_a
  • Members
  • 52 posts
  • Last active: Jul 05 2011 06:23 PM
  • Joined: 12 Dec 2004

Requestedby me a long time ago, but never got implemented, so I thought I'd write my own :)

Nice. Thanks for sharing it, and sorry it took so long to add function support.


An apology is the last thing I need to accept from you :O

I'm a programmer myself, and I fairly well realise how much time and effort goes into producing software. You're doing an excellent job, accomodating so many user requests, and being considerate, responsive, and pragmatic while doing so.

Thanks, once again Chris ! :D

Jerry
  • Members
  • 39 posts
  • Last active: Jun 05 2007 05:39 PM
  • Joined: 24 Jun 2004
Not to put down the function or anyone here, but I think Chris created this function back in v1.0.22. I would have used the following command

winget, outvar, MinMax, %p_WindowTitle%

Or does the style WS_VISIBLE reveal something else?