Info about Grayed Buttons
Keywords: info about grayed buttons
Question:
Is there way to check the =grayed/nongrayed state of buttons in pulldownmenues?As in Winbatch Studio: Debug =-> Step over can sometimes be grayed and sometimes not.
Answer:
Here is a way to do it, checks for the grayed / ungrayed state mostly, there are more states.The script checks for the Step Over item in the Debug submenu of the WinBatch Studio menu.
Remember that menu separators are considered menu items too.
;Get menu items info ;Guido 10/2002 MF_BYPOSITION=1024 MF_ENABLED=0 MF_GRAYED=1 MF_DISABLED=2 MF_SEPARATOR=2048 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=4 ; 'Debug' hsub=dllcall(user32,long:"GetSubMenu",long:hmenu,long:subpos) ;get item state based on position, 0 based itempos=8 ; 'Step Over' state=dllcall(user32,long:"GetMenuState",long:hsub,long:itempos,long:MF_BYPOSITION) message("State:",state) select state case -1 message("Info:","Not found") break case MF_ENABLED message("Info:","Enabled") break case MF_GRAYED message("Info:","Grayed") break case MF_DISABLED message("Info:","Disabled") break case MF_DISABLED | MF_GRAYED message("Info:","Disabled and grayed") break case MF_SEPARATOR | MF_DISABLED | MF_GRAYED message("Info:","Separator") endselect dllfree(user32)