 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
skrommel
Joined: 30 Jul 2004 Posts: 180
|
Posted: Wed Feb 21, 2007 2:03 am Post subject: Accessing the system menu using WinMenuSelectItem? |
|
|
How do I access the system menu silently? I've found no options in WinMenuSelectItem, and using Alt-Space flickers the menu.
Maybe there should be a WinMenuSelectItem,Window,,0&,1&?
Skrommel |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Wed Feb 21, 2007 3:16 am Post subject: |
|
|
I think WinMenuSelectItem applies to the normal menu, i.e., the menu bar.
Try this for SysMenu, seems to work:
| Code: |
nIndex := 3 ; 0-based index of the item
WinGet, hWnd, ID, A
hSysMenu := DllCall("GetSystemMenu", "Uint", hWnd, "int", False)
nID := DllCall("GetMenuItemID", "Uint", hSysMenu, "int", nIndex)
PostMessage, 0x112, nID, 0, , ahk_id %hWnd% ; WM_SYSCOMMAND
|
|
|
| Back to top |
|
 |
skrommel
Joined: 30 Jul 2004 Posts: 180
|
Posted: Thu Feb 22, 2007 9:00 am Post subject: Sub menus |
|
|
Fantastic!
I want to use it to access the Edit menu of command windows, so I'll have to find the sub menus, too.
Skrommel |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Thu Feb 22, 2007 12:24 pm Post subject: Re: Sub menus |
|
|
| skrommel wrote: | | I want to use it to access the Edit menu of command windows, so I'll have to find the sub menus, too. |
You can obtain the submenu by its index as an item in the menu. So, the code would look like:
| Code: |
nIndex0 := 7 ; 0-based index of the SubMenu in SysMenu
nIndex1 := 3 ; 0-based index of the item in the SubMenu
WinGet, hWnd, ID, A
hSysMenu := DllCall("GetSystemMenu", "Uint", hWnd, "int", False)
; nID := DllCall("GetMenuItemID", "Uint", hSysMenu, "int", nIndex0) ; produce -1 for a SubMenu item
hSubMenu := DllCall("GetSubMenu", "Uint", hSysMenu, "int", nIndex0)
nID := DllCall("GetMenuItemID", "Uint", hSubMenu, "int", nIndex1)
PostMessage, 0x112, nID, 0, , ahk_id %hWnd% ; WM_SYSCOMMAND
|
|
|
| Back to top |
|
 |
skrommel
Joined: 30 Jul 2004 Posts: 180
|
Posted: Sat Feb 24, 2007 12:43 am Post subject: Thanks |
|
|
There's nothing like working code! Thanks!
Skrommel |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|