AutoHotkey Community

It is currently May 27th, 2012, 6:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: February 23rd, 2007, 2:29 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
This is kinda proof of the concept.
It can invoke other app's MenuBar directly from AHK.
And, can be used as another way to invoke AHK's TrayMenu too.

Code:
#NoTrayIcon
#NoEnv

TPM_RECURSE   = 0x0001
TPM_NONOTIFY  = 0x0080
TPM_RETURNCMD = 0x0100

DetectHiddenWindows, On

WinGet, hWnd, ID, ahk_class Notepad
WinGet, hAHK, ID, ahk_class AutoHotkey

CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos

nIndex := 1   ; 1-based index of the SubMenu. If 0 or omitted, thin bar will appear.
;hWnd := hAHK   ; will get AHK's TrayMenu

hMenu := DllCall("GetMenu", "Uint", hWnd)

If nIndex
hMenu := DllCall("GetSubMenu", "Uint", hMenu, "int", nIndex - 1)

WinActivate, ahk_id %hAHK%

nID := DllCall("TrackPopupMenu", "Uint", hMenu
          , "Uint", TPM_RECURSE | TPM_NONOTIFY | TPM_RETURNCMD
          , "int", xpos, "int", ypos, "int", 0, "Uint", hAHK, "Uint", 0)

PostMessage, 0x111, nID, 0, , ahk_id %hWnd%   ; WM_COMMAND

MsgBox, Done



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2007, 11:39 am 
1) You should indicate Notepad must run for this to work.
2) And it would be useful to indicate what it does:
Even if Notepad is not active, you got the first drop-down menu (the File one) at mouse position and you can choose an item and get the task done.
I am not too sure how this can be useful (a kind of tear-down menu?), but it is fun, thanks.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2007, 12:08 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Grumpy wrote:
1) You should indicate Notepad must run for this to work.

Thanks for reminding it. I forgot to do it, which is not unusual for me, unfortunately.

Quote:
2) And it would be useful to indicate what it does:
Even if Notepad is not active, you got the first drop-down menu (the File one) at mouse position and you can choose an item and get the task done.

Yes, it can be regarded as a visual implementation of WinMenuSelectItem. If commented out nIndex field, it will give an actual (thin) menu bar with the menu names are stripped out.

Quote:
I am not too sure how this can be useful (a kind of tear-down menu?), but it is fun, thanks.

Yes, it's just a proof of concept yet.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2008, 8:28 am 
Hi,

Sean wrote:
And, can be used as another way to invoke AHK's TrayMenu too.

Sean,
- how we can do that?
- If we have a running AHK script(A) with a custom tray menu, how can we read it by an other script(B) and append script's(A) tray menu to script's(B) tray menu (as submenu)? Also, if we select a script's(A) appended menu item in script(B), to be executed in script(A)?

Thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2011, 7:34 am 
Offline

Joined: January 20th, 2011, 11:42 am
Posts: 7
Hi Sean,
Can I add any autohotkey menu into desktop context menu? This may possible but I don't know executable file for desktop context menu.This may be explorer.exe? Or any dll file? Can I do this using GetMenu?
[ Moderator!: unpleasant text formatting removed ]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2011, 1:17 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
If you want to modify other process's context menu you have to create a contextmenu handler dll file. But, you can simulate some of them inside AHK:
http://www.autohotkey.com/forum/topic22120.html


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, JamixZol, rbrtryn, Stigg, Yahoo [Bot] and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group