Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Menu Item State.

  • Please log in to reply
15 replies to this topic
  • Members
  • 126 posts
  • Last active: Oct 23 2017 06:24 PM
  • Joined: 11 Jul 2005
Thanks Lexikos!
That's so much cleaner than my alternative using send...

ifWinNotExist, Untitled - Notepad
    Run, notepad.exe
    WinWait, Untitled - Notepad

WinGet, hWnd, ID, Untitled - Notepad
hMenu :=DllCall("GetMenu", "Uint", hWnd)
hSubMenu := DllCall("GetSubMenu", "Uint", hMenu, "int", 2)

winactivate, ahk_class Notepad
setkeydelay 1
send {Alt Down}{o}{Alt up}{esc}

; Set the capacity of mii to sizeof(MENUITEMINFO)
VarSetCapacity(mii, 48, 0)
; Set the cbSize field to sizeof(MENUITEMINFO)
NumPut(48, mii, 0)

; Set the mask to whatever you want to retrieve.
; In this case I set it to MIIM_STATE=1.
NumPut(1, mii, 4)

; Note that menu item positions are zero-based.
DllCall("GetMenuItemInfo", "UInt", hSubMenu, "UInt", 0, "UInt", 1, "UInt", &mii)

; Get the state field out of the struct.
fState := NumGet(mii, 12)

if (fState & 0x8) ; MFS_CHECKED
    MsgBox Word Wrap is Enabled!
    MsgBox Word Wrap is Disabled!

Jeff Main