Get closed MENU ITEMS STATE in msPAINT (checked?)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Sam Bo
Posts: 7
Joined: 30 Jan 2014, 12:20

Get closed MENU ITEMS STATE in msPAINT (checked?)

10 Apr 2023, 16:41

Hi, i have this code, it gets menu item state (checkmark) for Notepad and partially for Paint, but I NEED it to work for
View --> Color box (in Paint, WinXP)
What should I change to use it in other menus, submenus, or windows if possible ???

Code: Select all

#persistent
SetTitleMatchMode, 2
Loop
{  Sleep, 500
  if WinActive("ahk_class MSPaintApp")
       WhatWin := "MSPaintApp",  WhatSubmenu := "Tools",  #Sub := "2"
  Else if WinActive("ahk_class Notepad")
        WhatWin :="Notepad",   WhatSubmenu :="Status Bar",  #Sub := "3"

  win_hwnd := WinExist("ahk_class " WhatWin )   ;   <<<   WINDOW
  if(win_hwnd = "0x0")
  {   tooltip, Please activate Notepad OR Paint.
     continue
  }
  main_Menu := DllCall("GetMenu", UInt, win_hwnd)   ;   <<<   MENUBAR
  view_menu := DllCall("GetSubMenu", UInt, main_Menu, Int, #Sub)  ;   <<<   SUBMENU
  SendMessage , 0x116, view_menu, 0,, ahk_id %win_hwnd%  ;   <<<   NOTEPAD .   WM_INITMENU
  SendMessage , 0x0117, view_menu, 0,, ahk_id %win_hwnd%  ;   <<<   MSPAINT .  WM_INITMENUPOPUP  "Sent when a drop-down menu or submenu is about to become active" 
    
    if DllCall("GetMenuState", UInt, view_menu, UInt, 0, UInt, 0x400) >> 2 & 2    ; 2 & 2   2 & 3  =  PAINT:tools.     3 & 1 = NOTEPAD:statusbar
              tooltip, %WhatWin% '%WhatSubmenu%' menu is checked ☻
    else  tooltip, %WhatWin% '%WhatSubmenu%' menu is UNchecked ☺
    ; "sometimes a window menu should be refrashed with WM_ENTERMENULOOP, WM_EXITMENULOOP."
}
Return
Attachments
VIEW menu paint 10abr2023 -part.png
VIEW menu paint 10abr2023 -part.png (201.03 KiB) Viewed 174 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: balawi28, Bing [Bot], Chunjee, Google [Bot], moltenchees and 269 guests