WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check If Third Party Menu Item Is Checkmarked


Question:

I am trying to automate the setting of file filters in the WinDiff utility, but I have run into a snag.

How would you determine whether a menu item has been checked marked or not?

I can't see a way to narrow in on the right function call using Roboscripter, because once you get the menu to drop down, you have to click on Roboscripter to try and drag the cursor to the menu - and that causes the menu to disappear.

Any help would be appreciated.

Answer:

If you feel up to a little SDK programming there is a Guido script that can be found at the following link: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/How~To+Check~the~Grayed-NonGrayed~State~of~Buttons~in~Pull~Down~Menus.txt

I believe that if you look for the value of MF_CHECKED instead of using the select statement in the example , it should report if the menu item is checked.

A modified version of Guido's script would look something like this:

MF_BYPOSITION=1024
MF_CHECKED= 8

user32=dllload(strcat(dirwindows(1),"user32.dll"))

;get window handle
hwnd=dllhwnd("WinBatch Studio")
if hwnd==0
message("","Window not found")
exit
endif

;get menu handle
hmenu=dllcall(user32,long:"GetMenu",long:hwnd)

;get dropdown menu handle based on position, 0 based
subpos=3 ; 'View'
hsub=dllcall(user32,long:"GetSubMenu",long:hmenu,long:subpos)

;get item state based on position, 0 based
itempos=1 ; 'Status bar'
state=dllcall(user32,long:"GetMenuState",long:hsub,long:itempos,long:MF_BYPOSITION)

if state & MF_CHECKED then Message("State", "Checked") 
else Message("State", "Unchecked")

dllfree(user32) 

User Reply:

Thankyouthankyouthankyou! That did the trick. I had to do a little fiddling to find the proper values 
for subpos and itempos, but it works like a charm. And thank you Guido.

Article ID:   W16450
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38