AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tiny "IsWindowVisible" function

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
mario_a



Joined: 12 Dec 2004
Posts: 51

PostPosted: Sun Apr 10, 2005 7:52 pm    Post subject: Tiny "IsWindowVisible" function Reply with quote

Hi,

I've written a small function to determine if a window is visible or not.
Requested by me a long time ago, but never got implemented, so I thought I'd write my own Smile

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.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Mon Apr 11, 2005 12:24 am    Post subject: Re: Tiny "IsWindowVisible" function Reply with quote

mario_a wrote:
Requested by me a long time ago, but never got implemented, so I thought I'd write my own Smile
Nice. Thanks for sharing it, and sorry it took so long to add function support.
Back to top
View user's profile Send private message Send e-mail
mario_a



Joined: 12 Dec 2004
Posts: 51

PostPosted: Mon Apr 11, 2005 8:19 pm    Post subject: Re: Tiny "IsWindowVisible" function Reply with quote

Chris wrote:
mario_a wrote:
Requested by me a long time ago, but never got implemented, so I thought I'd write my own Smile
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 Surprised

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 ! Very Happy
Back to top
View user's profile Send private message
Jerry



Joined: 24 Jun 2004
Posts: 39

PostPosted: Tue Apr 12, 2005 3:29 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group