org.safs.natives
Class MenuUtilities

java.lang.Object
  extended by org.safs.natives.NativeWrapper
      extended by org.safs.natives.MenuUtilities

public class MenuUtilities
extends NativeWrapper


Field Summary
static java.lang.String CLASS_NAME
           
static int MAX_MENU_ITEM_LEN
           
static int MF_BITMAP
           
static int MF_BYCOMMAND
           
static int MF_BYPOSITION
           
static int MF_CHECKED
           
static int MF_DEFAULT
           
static int MF_DISABLED
           
static int MF_GRAYED
           
static int MF_HILITE
           
static int MF_MENUBARBREAK
           
static int MF_MENUBREAK
           
static int MF_OWNERDRAW
           
static int MF_POPUP
           
static int MF_SEPARATOR
           
static int MU_STATE_FAILURE
           
static java.lang.String MUStateFailureString
           
 
Fields inherited from class org.safs.natives.NativeWrapper
NO_RESULT, RESULT_KEY, VECTOR_KEY
 
Constructor Summary
MenuUtilities()
           
 
Method Summary
 void checkState(int state)
          Users can call this method to check the state before they call the other methods IsXXX()
static boolean IsMenuItemABitmap(int state)
           
static boolean IsMenuItemAMenu(int state)
           
static boolean IsMenuItemAMenuBarBreak(int state)
           
static boolean IsMenuItemAMenuBreak(int state)
           
static boolean IsMenuItemAMenuSeparator(int state)
           
static boolean IsMenuItemChecked(int state)
           
static boolean IsMenuItemDefault(int state)
           
static boolean IsMenuItemEnabled(int state)
           
static boolean IsMenuItemGrayed(int state)
           
static boolean IsMenuItemHiLited(int state)
           
static java.lang.String MUGetMenuItemStateString(int state)
          DESCRIPTION:
Given state information of the state obtained by User32.GetMenuState(NativeLong, int, int) the routine converts it to a space-delimited string of all the state information known for the provided state.
static java.util.List<java.lang.String> MUGetMenuItemStrings(long lhMenu)
          DESCRIPTION: Given a valid Menu handle and return a list of all the menuitems.
static int MUGetMenuItemTextIndex(long hMenu, java.lang.String menuText)
          DESCRIPTION: Given a valid Menu handle and text string the routine attempts to locate the position within the menu for the associated menuitem.
static long MUGetMenuItemTextState(long hMenu, java.lang.String menuText)
          DESCRIPTION: Given a valid Menu handle and text string the routine attempts to return the state information for the menuitem.
static boolean MUOutputMenuStructure(long lhWnd, java.lang.String path, boolean overwrite, boolean recurse, boolean showState, java.lang.String description)
          DESCRIPTION: Given a valid handle the routine retrieves the menu structure, formats it as text, and saves it to a file or outputs it to the Console.
 
Methods inherited from class org.safs.natives.NativeWrapper
_processLastError, DoesRegistryKeyExist, EnumChildWindows, EnumWindows, GetDesktopWindow, getFileTime, GetForegroundWindow, GetProcessFileName, GetProcessUIResourceCount, GetRegistryKeyValue, GetWindowThreadProcessId, LaunchURLInDefaultWebBrowser, main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MU_STATE_FAILURE

public static final int MU_STATE_FAILURE
See Also:
Constant Field Values

MF_CHECKED

public static final int MF_CHECKED
See Also:
Constant Field Values

MF_DISABLED

public static final int MF_DISABLED
See Also:
Constant Field Values

MF_GRAYED

public static final int MF_GRAYED
See Also:
Constant Field Values

MF_HILITE

public static final int MF_HILITE
See Also:
Constant Field Values

MF_MENUBARBREAK

public static final int MF_MENUBARBREAK
See Also:
Constant Field Values

MF_MENUBREAK

public static final int MF_MENUBREAK
See Also:
Constant Field Values

MF_OWNERDRAW

public static final int MF_OWNERDRAW
See Also:
Constant Field Values

MF_POPUP

public static final int MF_POPUP
See Also:
Constant Field Values

MF_BITMAP

public static final int MF_BITMAP
See Also:
Constant Field Values

MF_SEPARATOR

public static final int MF_SEPARATOR
See Also:
Constant Field Values

MF_DEFAULT

public static final int MF_DEFAULT
See Also:
Constant Field Values

MF_BYCOMMAND

public static final int MF_BYCOMMAND
See Also:
Constant Field Values

MF_BYPOSITION

public static final int MF_BYPOSITION
See Also:
Constant Field Values

MUStateFailureString

public static final java.lang.String MUStateFailureString
See Also:
Constant Field Values

CLASS_NAME

public static final java.lang.String CLASS_NAME

MAX_MENU_ITEM_LEN

public static final int MAX_MENU_ITEM_LEN
See Also:
Constant Field Values
Constructor Detail

MenuUtilities

public MenuUtilities()
Method Detail

checkState

public void checkState(int state)
                throws SAFSException
Users can call this method to check the state before they call the other methods IsXXX()

Throws:
SAFSException

IsMenuItemEnabled

public static boolean IsMenuItemEnabled(int state)

IsMenuItemChecked

public static boolean IsMenuItemChecked(int state)

IsMenuItemGrayed

public static boolean IsMenuItemGrayed(int state)

IsMenuItemHiLited

public static boolean IsMenuItemHiLited(int state)

IsMenuItemDefault

public static boolean IsMenuItemDefault(int state)

IsMenuItemABitmap

public static boolean IsMenuItemABitmap(int state)

IsMenuItemAMenuBreak

public static boolean IsMenuItemAMenuBreak(int state)

IsMenuItemAMenuBarBreak

public static boolean IsMenuItemAMenuBarBreak(int state)

IsMenuItemAMenuSeparator

public static boolean IsMenuItemAMenuSeparator(int state)

IsMenuItemAMenu

public static boolean IsMenuItemAMenu(int state)

MUGetMenuItemStateString

public static java.lang.String MUGetMenuItemStateString(int state)
DESCRIPTION:
Given state information of the state obtained by User32.GetMenuState(NativeLong, int, int) the routine converts it to a space-delimited string of all the state information known for the provided state. Ex: "Enabled Unchecked Ungrayed Unhilited Default" OR "Enabled Unchecked Ungrayed Hilited Normal Menu With 5 MenuItems" Valid States: Enabled Grayed BarBreak Bitmap Disabled Ungrayed Separator Break Checked Hilited Default Menu With N MenuItems Unchecked Unhilited Normal (not default)

Parameters:
state - state information retrieved from User32.GetMenuState(NativeLong, int, int)
Returns:
Space-delimited string of state information. If the state code provided = MU_STATE_FAILURE then return MUStateFailureString

MUGetMenuItemTextState

public static long MUGetMenuItemTextState(long hMenu,
                                          java.lang.String menuText)
DESCRIPTION: Given a valid Menu handle and text string the routine attempts to return the state information for the menuitem. The menuText can optionally include the ampersand character that normally precedes any underlined character in the menuitem.

Parameters:
hMenu - The handle of the Menu
menuText - Case-sensitive text to identify the menuitem with
Returns:
state: Long status flag settings for the menuitem MUStateFailureString on failure.

MUGetMenuItemTextIndex

public static int MUGetMenuItemTextIndex(long hMenu,
                                         java.lang.String menuText)
DESCRIPTION: Given a valid Menu handle and text string the routine attempts to locate the position within the menu for the associated menuitem. MenuItem text that contains one or more underlined characters is represented in Windows by an ampersand (&) preceding each character that is underlined. Our text comparisons use these ampersands when trying to match text as well. This provides verification of the visual cues given the user for what keyboard shortcuts can be used on the menuitems. However, if the existence or position of the ampersand (the underlined character ) is NOT important, the menuText string can be provided void of ALL ampersand characters. This routine will recognize that NO ampersands were provided and will strip the actual menuitem text of ampersands when doing the comparison. This may possibly result in a false match (a match with the wrong menuitem), although this is probably unlikely.

Parameters:
hMenu - The handle of the Menu
menuText - Case-sensitive text to identify the menuitem with
Returns:
N zero-based index into the associated menu for the item with matching text -1 on failure.

MUGetMenuItemStrings

public static java.util.List<java.lang.String> MUGetMenuItemStrings(long lhMenu)
DESCRIPTION: Given a valid Menu handle and return a list of all the menuitems.

Parameters:
lhMenu - The handle of the Menu
Returns:
A list containing all the menuitems. null if failure.

MUOutputMenuStructure

public static boolean MUOutputMenuStructure(long lhWnd,
                                            java.lang.String path,
                                            boolean overwrite,
                                            boolean recurse,
                                            boolean showState,
                                            java.lang.String description)
DESCRIPTION: Given a valid handle the routine retrieves the menu structure, formats it as text, and saves it to a file or outputs it to the Console. You can choose to append or overwrite the existing file (if any) and you can choose to do only one level or the entire menu system.

Parameters:
lhWnd - handle of the Window
path - full path and name of file to use/make as output if path="" the output is directed to the console
overwrite - false Append the file if it already exists true Overwrite the file if it already exists
recurse - false Output only the top level menu information true Recursively output ALL menu information
showState - false Do not show any state information true Show the state string of each menuitem
description - Optional text to place at start of output This should be something which identifies which window or which state of the application the snapshot was taken from. Without this, the output gives no indication of where it came from.
Returns:
true when success.