Jump to content

Hidden WinMenuSelectItem


Champak
 Share

Recommended Posts

The help file says you can access hidden menus with WinMenuSelectItem, but I can't (using Hotkeyset)...and I've only come across one vague post in reference to it being possible but no examples. I have a standard menu by using GuiCtrlCreateMenu. I'm using a hotkey and my code looks like:

WinMenuSelectItem($Title, "Info", "Play", "Functions", "Slow")

Is it or isn't it possible? How?

Link to comment
Share on other sites

The help file says you can access hidden menus with WinMenuSelectItem, but I can't (using Hotkeyset)...and I've only come across one vague post in reference to it being possible but no examples. I have a standard menu by using GuiCtrlCreateMenu. I'm using a hotkey and my code looks like:

WinMenuSelectItem($Title, "Info", "Play", "Functions", "Slow")

Is it or isn't it possible? How?

Return Value

Success: Returns 1.

Failure: Returns 0 if the menu could not be found.

Remarks

You should note that underlined menu items actually contain a & character to indicate the underlining. Thus, the menu item File would actually require the text "&File", and Convert would require "Con&vert" You can access menu items up to six levels deep; and the window can be inactive, minimized, and/or even hidden.

WinMenuSelectItem will only work on standard menus. Unfortunately, many menus in use today are actually custom written or toolbars "pretending" to be menus. This is true for most Microsoft applications.

See if any of that helps...
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Not to be rude, but if I've pretty much stated that I've looked in the help file, why would you just post exactly what is in the help file. Now if it is something I didn't understand/missed in the help file, it would help if you stated that. But you are not helping here by showing me what I have already stated I've seen with no explanation.

Thanks anyway.

Edited by Champak
Link to comment
Share on other sites

OK, this is very annoying. I went ahead and made a simple work up of two guis with hide and show, with a menu. And the WinMenuSelectItem does not work when the GUI is hidden. So why does the help file say it does? Am I understanding it wrong? Am I setting this up wrong? Is this a bug? I don't see anything about this on the site, so what is the deal?

My example -

If you click "Button 2" and go to "My GUI 1" and press "Button Menu" or hotkey {ENTER}, that should activate a MsgBox attached to the menu item "TEST", but it doesn't. Now if you comment out "Button Menu" on "My GUI 1" and uncomment ""Button Menu" on "GUI 2"(The GUI actually with the menu) it will work as well as the hotkey.

#include <GUIConstants.au3>

HotKeySet("{ENTER}", "HOTKEY")

$GUI1 = GUICreate("My GUI 1",300,200)
    GUICtrlCreateLabel("TEST PAGE",20,20)
    $Button1 = GUICtrlCreateButton("Button 1", 40, 40)
    $ButtonMenu = GUICtrlCreateButton("Button Menu", 40, 70)
GUISetState (@SW_HIDE)


$GUI2 = GUICreate("My GUI 2",300,200)
    GUICtrlCreateLabel("MAIN PAGE",20,20)
    $filemenu = GUICtrlCreateMenu ("File")
    $fileitem = GUICtrlCreateMenuitem ("TEST",$filemenu)
    $Button2 = GUICtrlCreateButton("Button 2", 40, 40)  
;   $ButtonMenu = GUICtrlCreateButton("Button Menu", 40, 70)
GUISetState ()

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Select
        Case $msg = $Button1
            GUISetState(@SW_HIDE, $GUI1)
            GUISetState(@SW_SHOW, $GUI2)

        Case $msg = $Button2
            GUISetState(@SW_HIDE, $GUI2)
            GUISetState(@SW_SHOW, $GUI1)
            
        Case $msg = $fileitem
            MsgBox(0,1,"Menu Clicked")
            
        Case $msg = $ButtonMenu
            WinMenuSelectItem("My GUI 2", "MAIN PAGE", "File", "TEST")
    EndSelect
WEnd

Func HOTKEY()
    WinMenuSelectItem("My GUI 2", "MAIN PAGE", "File", "TEST")
EndFunc
Link to comment
Share on other sites

Sorry for repeating that, some users never read the helpfile and so when I saw that I thought that you might of just read the function description. But anyways, I see what you mean and can't think of a solution. I modified your code to illustrate the problem better and posted it as a bug report.

#include <GUIConstants.au3>

$GUI1 = GUICreate("My GUI 1",300,200, 200, 200)
    GUICtrlCreateLabel("TEST PAGE",20,20)
    $Button1 = GUICtrlCreateButton("Hide GUI 2", 40, 40)
        $hide = False
    $ButtonMenu = GUICtrlCreateButton("Test WinMenuSelectItem()", 40, 70)
GUISetState ()

$GUI2 = GUICreate("My GUI 2",300,200, 510, 200)
    GUICtrlCreateLabel("MAIN PAGE",20,20)
    $filemenu = GUICtrlCreateMenu ("File")
    $fileitem = GUICtrlCreateMenuitem ("TEST",$filemenu)
GUISetState ()

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then 
        Exit
    EndIf 
    
    Select
        Case $msg = $Button1
            If Not $hide then 
                WinSetState('My GUI 2', '', @SW_HIDE)
                GuiCtrlSetData($Button1, 'Show GUI 2')
            Else 
                WinSetState('My GUI 2', '', @SW_SHOW)
                GuiCtrlSetData($Button1, 'Hide GUI 2')
            EndIf 
            
            $hide = Not $hide
           
        Case $msg = $fileitem
            MsgBox(0,1,"Menu Clicked")
           
        Case $msg = $ButtonMenu
            WinMenuSelectItem("My GUI 2", "MAIN PAGE", "File", "TEST")
    EndSelect

WEnd

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Actually, I just found the answer:

#include <GUIConstants.au3>

$GUI1 = GUICreate("My GUI 1",300,200, 200, 200)
    GUICtrlCreateLabel("TEST PAGE",20,20)
    $Button1 = GUICtrlCreateButton("Hide GUI 2", 40, 40)
        $hide = False
    $ButtonMenu = GUICtrlCreateButton("Test WinMenuSelectItem()", 40, 70)
GUISetState ()
$GUI2 = GUICreate("My GUI 2",300,200, 510, 200)
    GUICtrlCreateLabel("MAIN PAGE",20,20)
    $filemenu = GUICtrlCreateMenu ("File")
    $fileitem = GUICtrlCreateMenuitem ("TEST",$filemenu)
GUISetState ()

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then 
        Exit
    EndIf 
    
    Select
        Case $msg = $Button1
            If Not $hide then 
                WinSetState('My GUI 2', '', @SW_HIDE)
                GuiCtrlSetData($Button1, 'Show GUI 2')
            Else 
                WinSetState('My GUI 2', '', @SW_SHOW)
                GuiCtrlSetData($Button1, 'Hide GUI 2')
            EndIf 
            
            $hide = Not $hide
           
        Case $msg = $fileitem
            MsgBox(0,1,"Menu Clicked")
           
        Case $msg = $ButtonMenu
            WinMenuSelectItem($GUI2, "MAIN PAGE", "File", "TEST")
    EndSelect
WEnd

Edit: Apparently when the window is hidden you can't just use the window text name...

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Nice work around, but it doesn't really work. It only seems to work when both GUIs are initially displayed, which is not the case in my script, and doesn't really make sense. When one OR the other is displayed ALONE initially and => then switched to the GUI that DOESN'T have the menu, this wont work. And is there a reason you took away the hotkey...that is the main purpose of this.

So example: Put "GUISetState (@SW_HIDE)" under GUI2, and then click the "Test WinMenuSelectItem" button, and you'll see what I mean.

Thanks.

Edited by Champak
Link to comment
Share on other sites

Sorry, I don't know how to handle this. This was reported in the bug area, http://svn.autoitscript.com/trac/ticket/97 where it did not seem to be resolved yet was closed (maybe do to not being explained in detail); and this solution does not seem to resolve the issue. So do I continue this post or am I suppose to resubmit a bug that was closed. What do I do? Or is this not a bug and the solution just wasn't posted here. I'm about to resubmit this as a bug, but don't want to break any etiquette.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...