PDA

View Full Version : how to check whatever a OSD menu is visible ? (exists)



AlCapone
January 10th, 2006, 07:30 AM
I used "RootMenu:Show (true,"Root Menu",.............."
- a menu is up, now
- how can I another script check whatever it is active/visible ?

Promixis
January 10th, 2006, 07:38 AM
if win.IsWindowObscured (MyMenu.OSD:GetHandle ())

determines if any part of the window is obscured.

use win.GetForegroundWindow to see if its foreground or not.

AlCapone
January 10th, 2006, 08:28 AM
thank you/.....sorry, I guess obscured is like "covered up" or something ?

I am trying to find out whatever it exists, not if it is visible to me.. like - "have it been closed yet or not"

Promixis
January 10th, 2006, 08:40 AM
you can check if

myosd.OSD == nil

then you know its been closed.

Promixis
January 10th, 2006, 08:40 AM
but, that may not be best. what are you trying to do?

AlCapone
January 10th, 2006, 09:05 AM
I want one (menubutton) to toggle the menu
so if it is off, then show it.
if it's alredy on, then hide it.

I tried:

if RootMenu.OSD == nil then
RootMenu:Show (true,"Root ............. (this line works)
end

After adding the IF line, the RootMenu:Show is not executed, even when it does not show.

Promixis
January 10th, 2006, 09:23 AM
if you are not destroying the menu then you can check the Visible property

to toggle the visibility of an osd call


osd:ToggleVisible ()

AlCapone
January 10th, 2006, 09:41 AM
i do ressign some buttons to menucontrol when the menu is activated, so I would rather not use "blind" toggling-...

is there no way to check if the menu is spawned? (exists somewhere?)

Promixis
January 10th, 2006, 11:41 AM
Then use the menu.Visible property.

Its true when visible, false when the menu has been hidden using the Hide method.

AlCapone
January 10th, 2006, 11:51 AM
tried:

if RootMenu.Visible = false then

and got another useless error msg: "then" expected near "="

i somehow fail to understand what LUA wants... :)

Rob H
January 10th, 2006, 12:32 PM
To test for equality use == not =

Although it's usually considered bad form to compare something with false - it's normally done using e.g.



if not RootMenu.Visible then

AlCapone
January 10th, 2006, 01:03 PM
[quote]
if not RootMenu.Visible then
[/quote]

thank you ...

this seems logic, but it does not work..
I used "=" because I was desperate, and tried true/false/0/1
still , even your suggestion sounds fine, it does not work.
the worst thing is that not even YOU seem to get it right... is there anyone that really understands it ? - especially the error messages ? :)

here you go:
a sample bit made fust for you:



RootMenu = osd.Classes.Menu:New ()
RootMenu:Initialize ()
RootMenu.TimeOut = 0

if not RootMenu.Visible then
RootMenu:Show (true,"Test Menu",{"What's up",'with','this','LUA'})
end


goal: skip making another menu if this menu is alredy been drawed once., and instead hide the one that exists.
of coursem the hiding stuff is something I'll add, - when I get this simple logic to work

Rob H
January 10th, 2006, 02:19 PM
Yes, it looks as though Visible is true whether it's visible or not. So that looks like it might be a bug.

I don't use the osd and there is no source code for it, which makes it a bit harder to work out what is going wrong.

Promixis
January 10th, 2006, 03:39 PM
Use

RootMenu = osd.Classes.Menu:New ()
RootMenu:Initialize ()
RootMenu.TimeOut = 0
RootMenu.Visible = false

if not RootMenu.Visible then
RootMenu:Show (true,"Test Menu",{"What's up",'with','this','LUA'})
end

The Visible property needs to be set once.

AlCapone
January 10th, 2006, 04:37 PM
thanks - that helped..
i am surprised to hear that you do not have the source for that OSD - I heard you refer to MSDN before - så I guess it's one of M$'s bugs. :)

Promixis
January 10th, 2006, 04:40 PM
thanks - that helped..
i am surprised to hear that you do not have the source for that OSD - I heard you refer to MSDN before - så I guess it's one of M$'s bugs. :)

The OSD is our code. Rob doesn't have a source copy. We have precompiled some of the lua code to improve startup times.

AlCapone
January 10th, 2006, 04:50 PM
I got to use some tricky test in order to apply "RootMenu.Visible = false " only once per menu .. could have saved some "if-thens" :) if it worked as it should ..

you think this will be fixed ?

Promixis
January 10th, 2006, 05:51 PM
I got to use some tricky test in order to apply "RootMenu.Visible = false " only once per menu .. could have saved some "if-thens" :) if it worked as it should ..

you think this will be fixed ?



you just need the fix at object creation

or do


RootMenu = osd.Classes.Menu:New ({Visible = false})