AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Accessing the system menu using WinMenuSelectItem?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
skrommel



Joined: 30 Jul 2004
Posts: 180

PostPosted: Wed Feb 21, 2007 2:03 am    Post subject: Accessing the system menu using WinMenuSelectItem? Reply with quote

Smile 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
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Wed Feb 21, 2007 3:16 am    Post subject: Reply with quote

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
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 180

PostPosted: Thu Feb 22, 2007 9:00 am    Post subject: Sub menus Reply with quote

Smile 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
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Thu Feb 22, 2007 12:24 pm    Post subject: Re: Sub menus Reply with quote

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
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 180

PostPosted: Sat Feb 24, 2007 12:43 am    Post subject: Thanks Reply with quote

Smile There's nothing like working code! Thanks!

Skrommel
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group