 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
mario_a
Joined: 12 Dec 2004 Posts: 51
|
Posted: Sun Apr 10, 2005 7:52 pm Post subject: Tiny "IsWindowVisible" function |
|
|
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
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Mon Apr 11, 2005 12:24 am Post subject: Re: Tiny "IsWindowVisible" function |
|
|
| mario_a wrote: | Requested by 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. |
|
| Back to top |
|
 |
mario_a
Joined: 12 Dec 2004 Posts: 51
|
Posted: Mon Apr 11, 2005 8:19 pm Post subject: Re: Tiny "IsWindowVisible" function |
|
|
| Chris wrote: | | mario_a wrote: | Requested by 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
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 !  |
|
| Back to top |
|
 |
Jerry
Joined: 24 Jun 2004 Posts: 39
|
Posted: Tue Apr 12, 2005 3:29 am Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|