AutoHotkey Community

It is currently May 24th, 2012, 1:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: April 10th, 2005, 7:52 pm 
Offline

Joined: December 12th, 2004, 1:34 pm
Posts: 51
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 11th, 2005, 12:24 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
mario_a wrote:
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 11th, 2005, 8:19 pm 
Offline

Joined: December 12th, 2004, 1:34 pm
Posts: 51
Chris wrote:
mario_a wrote:
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2005, 3:29 am 
Offline

Joined: June 24th, 2004, 3:56 am
Posts: 39
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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: cmulcahy, Exabot [Bot], tomoe_uehara and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group