Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
selecting/unchecking an application menu's subitem
#1
Hello All,

I can't believe I am having trouble with something so basic: selecting/unchecking an application menu's subitem.

Normally, to navigate and select items in an applications menu, I just send the keycodes e.g.
'Av - to select the View menu drop-down
and then if I wanted to select the subitem All, I would just code it all like this:

'Ava

This works reliably and fast HOWEVER,
I would like to uncheck a toggle (only if it is checked)

It is the first and only Item in a View menu -->

Always on Top

Selecting a after 'Av will check/uncheck this but I need to check it's status and then uncheck it if is checked:

The menu listdisappears in the application as soon as I switch applications, so I can't drag QM's reticule onto itt. When I use the Acc reticule and look through every item in the outline, that menu doesn't show up.

I think it may have to do with the Control-Specific Action option in QM but I can't get the reticule on it and the but- syntax doesn't seem to work.

Any ideas?

Thanks so much.
Stuart
#2
Function MenuItemCheck
Code:
Copy      Help
;/
function action $itemText [$menuClass] ;;action: 0 none (just return state), 1 check, 2 uncheck, 3 toggle

;Checks, unchecks or toggles an item in a pop-up menu in currently active window. Or just gets its state.
;Returns 1 if the item was checked when calling this function, or 0 if not.
;Before calling this function, the pop-up menu must be invoked. For example you can use key command that presses Alt+underlined letter.
;If the pop-up menu is still not visible, this function waits max 10 s. On timeout throws error. Also throws error if the specified item not found.
;This function always closes the pop-up menu.


;action - see above.
;itemText - item text.
;menuClass - pop-up menu window class. Default is "#32768", which is class of standard menus. This function also works with some nonstandard pop-up menus, but then must be specified pop-up menu window class. For example, in Word 2003 it is "MsoCommandBarPopup".


;EXAMPLE
;spe ;;to make faster, we don't need autodelay after key
;key Ae ;;invoke pop-up menu. It is necessary because check mark often is added/removed just before invoking the pop-up menu.
;int wasChecked=MenuItemCheck(2 "Wrap Lines") ;;uncheck and get previous state
;out wasChecked
;spe -1 ;;restore normal autodelay to be used further



if(!len(menuClass)) menuClass="#32768"

int h=wait(10 WV win("" menuClass)) ;;wait for pop-up menu
err end "the pop-up menu must be visible"

Acc a=acc(itemText "MENUITEM" h "" "" 0x1000)
err end "item not found"

int checked=a.State&WINAPI.STATE_SYSTEM_CHECKED!=0
int close click
sel action&3
,case 0 close=1
,case 1 if(checked) close=1; else click=1
,case 2 if(checked) click=1; else close=1
,case 3 click=1

if(click) a.DoDefaultAction ;;check or uncheck
else key F10 ;;close the pop-up menu
wait 5 -WV h; err

ret checked


Forum Jump:


Users browsing this thread: 1 Guest(s)