Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding sub menu into window menu
#1
Hello, can you please guide into the right direction on how to add entries to the standard window menu (the one top left, when clicking the icon)?
I already did that ages ago, but i can't the topic anymore.
Thank you!

What i want to build is a 'Copy Info' menu with entries like copy caption, copy hwnd, copy all info formated, etc.
pi
#2
Any window? I think it is impossible or dirty/unreliable. You probably can get and modify menu using GetSystemMenu, but on click it will send WM_SYSCOMMAND to that window, not to you. Unless you intercept mouse clicks with a mouse trigger or mouse hook.
#3
System menu triggers
but I did not test it.
#4
Gintaras Wrote:Any window? I think it is impossible or dirty/unreliable. You probably can get and modify menu using GetSystemMenu, but on click it will send WM_SYSCOMMAND to that window, not to you. Unless you intercept mouse clicks with a mouse trigger or mouse hook.

would that be a performance issue on my fast computer?

after searching for GetSystemMenu i found something Smile

Function __filedialog2
Code:
Copy      Help
function hwnd
0 hwnd
;int hwnd=win()
;int hc=child("" "CommonPlacesWrapperWndClass" hwnd)
int st = GetWinStyle(hwnd)
int x y cx cy; GetWinXY hwnd x y cx cy
int nx= 1600-cx/2
int ny=1200-cy/2
;if(st!=WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX)
;
,;SetWinStyle hwnd WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX 1|8
,;int sys_menu=GetSystemMenu(hwnd 0)
,;AppendMenu(sys_menu MF_BYPOSITION|MF_STRING SC_SIZE "&Size")
,;siz 800 600 hwnd 4
int slv
int hc=id(40965 hwnd)
if(!hc)
,;siz 800 800 hwnd 4
,int sys_menu=GetSystemMenu(hwnd 0)
,RECT rc; GetClientRect hwnd &rc
,_s.getwinexe(hwnd 1)
,str exe.getwinexe(hwnd)
,sel exe 1
,,case "dreamweaver"
,,,;slv=child("FolderView" "SysListView32" hwnd 0x1)
,,,;SetWinStyle hwnd WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX 1|8
,,,;AppendMenu(sys_menu MF_BYPOSITION|MF_STRING SC_SIZE "&Size")
,,,;;SetWinStyle slv WINAPI.LVS_REPORT|LVS_EDITLABELS 1
,,case ["qm","notepad++"]
,,,SetWinStyle hwnd WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX 1|8
,,,AppendMenu(sys_menu MF_BYPOSITION|MF_STRING SC_SIZE "&Size")
,,,0.2
,,,MoveWindow hwnd nx ny 800 600 1
,,,
,,,mov rc.right-80 500 id(1 hwnd)
,,,mov 0 500 id(1090 hwnd) 1
,,,mov 0 500 id(1152 hwnd) 1
,,,mov rc.right-80 530 id(2 hwnd)
,,,mov 0 530 id(1089 hwnd) 1
,,,mov 0 530 id(1136 hwnd) 1
,,,siz rc.right-10 400 child("" "SHELLDLL_DefView" hwnd)
,,case "aicon"
,,,SetWinStyle hwnd WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX 1|8
,,,AppendMenu(sys_menu MF_BYPOSITION|MF_STRING SC_SIZE "&Size")
,,,0.2
,,,MoveWindow hwnd nx ny 800 600 1
,,,;1040
,,,;
,,,mov rc.right-80 500 id(1 hwnd)
,,,mov 0 500 id(1090 hwnd) 1
,,,mov 0 500 id(1148 hwnd) 1
,,,mov rc.right-80 530 id(2 hwnd)
,,,mov 0 480 id(1040 hwnd) 1
,,,mov 0 530 id(1089 hwnd) 1
,,,mov 0 530 id(1136 hwnd) 1
,,,siz rc.right-10 400 child("" "SHELLDLL_DefView" hwnd)    
,,case "devenv"
,,,,sel _s.getwintext(hwnd)
,,,,,case "Komponente ausw�hlen"
,,,,,,siz 900 700 hwnd
,,,,,case "TabPage-Auflistungs-Editor"
,,,,,,siz 900 800 hwnd

,,case else
,,,;SetWinStyle hwnd WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX 1|8
,,,;MoveWindow hwnd nx ny 800 600 1
,,,;GetClientRect hwnd &rc
,,,;mov rc.right-80 500 id(1 hwnd)
,,,;mov 0 500 id(1090 hwnd) 1
,,,;mov 0 500 id(1152 hwnd) 1
,,,;mov rc.right-80 530 id(2 hwnd)
,,,;mov 0 530 id(1089 hwnd) 1
,,,;mov 0 530 id(1136 hwnd) 1
,,,;siz rc.right-10 400 child("" "SHELLDLL_DefView" hwnd)
,,,
,,,
,,,out "alt"
,
else
,;int w1=win("window name")
,
,str xx=""
,;out "neu"

,,

so the idea would be to use a left click trigger -> hit test sys.menu and then find out which item has been clicked?
pi
#5
_pi Wrote:so the idea would be to use a left click trigger -> hit test sys.menu and then find out which item has been clicked?

nah, i should better check for the menu appearing. but how to get that one?
pi
#6
This function detects when you click a menu item, and if you want, disables the click, and can launch a macro and pass hwnd and menu item id.
Function MenuItemClickTrigger
Trigger #L //MenuItemClickTrigger     Help - how to add the trigger to the macro
Code:
Copy      Help
;/
function# iid FILTER&f

if wintest(f.hwnd "" "#32768")
,int hm=SendMessage(f.hwnd MN_GETHMENU 0 0)
,if hm
,,POINT p; xm p
,,int i=MenuItemFromPoint(0 hm p)
,,int itemid=GetMenuItemID(hm i)
,,if i>0
,,,out "system menu clic k: item position=%i, item id=0x%X" i itemid
,,,sel itemid
,,,,case 666
,,,,PostMessage win WM_CANCELMODE 0 0 ;;close menu
,,,,out "my item"
,,,,mac "my macro" "" f.hwnd itemid
,,,,ret -1 ;;eat mouse event but don't run a macro
,,,,
,,,,case SC_MOVE
,,,,PostMessage win WM_CANCELMODE 0 0 ;;close menu
,,,,out "disabled Move"
,,,,ret -1 ;;eat mouse event but don't run a macro

ret -2


Forum Jump:


Users browsing this thread: 1 Guest(s)