 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Erittaf
Joined: 03 Nov 2007 Posts: 182
|
Posted: Thu Jan 17, 2008 11:21 pm Post subject: |
|
|
I've been playing around with this for a bit and I have questions. (as usual )
Can we not add menu names dynamically? See the code below, when you hit ctrl 1 the menu appears but there are no titles...
Also it seems the a space cannot have a title in it. Is there a work around for this? I like multi-word menu titles, especially when I get into 2-3 layers of submenu.
| Code: |
MenuItems =
(
First
Second
Third
)
main := MMenu_Create("O20")
Loop Parse, MenuItems, `n
{
msgbox, %A_LoopField%
MMenu_Add( main, %A_LoopField%, "shell32.dll:4")
}
return
MenuAction:
msgbox Title:%M_Title%`nID:%M_ID%`nMenu:%M_Menu%`n
return
^1::
CoordMode, mouse, screen
MouseGetPos, Mousex, Mousey
MMenu_Show( main, Mousex, Mousey, "MenuAction")
return
#include includes
#include MMenu.ahk
#include structs.ahk |
|
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jan 17, 2008 11:38 pm Post subject: |
|
|
You have to learn AHK first
MMenu_Add( main, A_LoopField, "shell32.dll:4") |
|
| Back to top |
|
 |
Erittaf
Joined: 03 Nov 2007 Posts: 182
|
Posted: Thu Jan 17, 2008 11:44 pm Post subject: |
|
|
heh... thanks, those percent signs are always my bane.
It appears that solves the spaces issue too! yay! |
|
| Back to top |
|
 |
Erittaf
Joined: 03 Nov 2007 Posts: 182
|
Posted: Tue Jan 22, 2008 11:44 pm Post subject: |
|
|
I've read the entire thread again and I see that evl had problems with the color of the menu text not inverting (turning to white) when any given item is highlighted. I do not see a solution though.
Did this get figured out?
see screenshots:
notice the text in the start menu that is highlighted is white while the text in the custom menu that is highlighted remains black.
I am running newest AHK, XP SP2 and no skinning or themes or any other mods to windows appearance. It seems like the process that moves the highlight to the item under the cursor is neglecting to change the text color.
Is it possible to have this updated? |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 446
|
Posted: Fri Jan 25, 2008 2:58 am Post subject: |
|
|
In answer to your query Erittaf, I don't believe you can modify individual menu items' appearance with the current iteration of MMenu's code. Majkinetor will hopefully bring that ability back in the future with updated code, at which time you could simply change the text color of that menu item upon selection (unless of course that's a built-in feature at that point).
Correct me if I'm wrong, majkinetor
And on a completely unrelated and mostly useless note, in starting to look into MMenu's code I came across this:
Line 626:
| Code: | | local WM_MENUSELECT = 0x11F |
Line 632:
| Code: | | local WM_MENUSELECT = 0x11F |
I know an ingenious way you could make MMenu 1 line shorter  _________________ -Ben
SteamLab
SteamLab Wiki
[Broken] - My industrial music [on GarageBand] |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Fri Jan 25, 2008 8:51 pm Post subject: |
|
|
It can be done ! It was troubling me myself, so I fixed it for me, but I didn't realise yet how to introduce this in API. ANyway, I started slowely rewriting MMenu to remove large number of globas and make dynamic menus shine in speed and performance. Currently its not very effective to constantly delete and recrete menus. You can experience it if you recreate menu more then 1000 times...which is something you may regulary have with some applicaitons For instance I have this little function, FolderMenu which takes path and crates menu from it. As each folder creates submenu (delayed ofc, as you access submenu) you can very quickly create and delete very large number of menus
Anyway, you have to change MMenu_onDraw function and add just 2 lines.
| Code: | MMenu_onDraw(wparam, lparam){
local obj, hBrush
DRAWITEM_GetA("MMenu_di", lparam)
if !MMenu_aItem[%MMenu_di_itemID%]_grayed
{
obj := API_SelectObject( MMenu_di_hDC, hBrush := API_CreateSolidBrush( MMenu_aItem[%MMenu_di_itemID%]_color ))
API_DeleteObject(obj)
if MMenu_di_itemState & 1
API_SetTextColor(MMenu_di_hDC, 0xFFFFFF) ;selected color...
else API_SetTextColor(MMenu_di_hDC, MMenu_aItem[%MMenu_di_itemID%]_color)
}
API_DrawIconEx(MMenu_di_hDC, (API_GetMenuCheckMarkDimensions() & 0xFFFF) + 4, MMenu_di_rcItem_Top, MMenu_di_itemData, 0, 0, 0, 0, 3) ;MMenu_di_NORMAL=3 = MMenu_di_MASK | MMenu_di_IMAGE (1 | 2)
API_DeleteObject(hBrush)
return 1
} |
JUst replace 0xFFFFFFF (white) with any color you want.
And no, changing individual items is not possible and will REMAIN like that. I can post you another version of mmenu that suports PER ITEM fonts, icon sizes and things like that, but due to the limitations of AutoHotKey that even Chris didn't succeed to explain me (he even created special testing version of AHK for testing MMenu back in time), I abandoned project. The bug is still here, in current MMenu, but you must be very unlucky son of a btch to experience it - it simply doesn't draw icons in submenu when you open it. It can happen only if you use keyboard ?! and open your submenu with it ?!. If you do right arrow left arrow very fast, once in 100 times icons will be lost. It depends on how quick I draw in OnDraw routine. Even single api call more makes bug more frequent. So I had to minimize drawing and return from the function as fast as possible. Critical 50 at the start of the script fixes the bug, bug then nothing else works ok...
AHK is full of strange things on message-liek frequencies. Its simply not designed for that. |
|
| Back to top |
|
 |
Erittaf
Joined: 03 Nov 2007 Posts: 182
|
Posted: Tue Jan 29, 2008 10:17 pm Post subject: |
|
|
@majkinetor
You never cease to impress me. Thanks for the fix, I never would have found the right spot to put it, however now I see where it is and how it works it's pretty obvious.
Anyway, thanks, works great! I don't need item by item support, and after reading your post it sounds like a terrible idea anyway!
Thanks again! |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Tue Jan 29, 2008 11:52 pm Post subject: |
|
|
Thank you
... and enjoy! _________________
 |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Apr 26, 2008 10:17 pm Post subject: |
|
|
Thanks for sharing great module.
putting icon on menu is what i've looked for past whole week.
but is there anyway to use this MMenu with traymenu?
i want to replace traymenu with MMenu. (nostandard and etc)
which means my MMenu should pop up when user right click on trayicon.
anyone have idea for this?
Thanks. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Sun Apr 27, 2008 12:25 am Post subject: |
|
|
| Look back one page in this thread, where I answered that question. |
|
| Back to top |
|
 |
majkinetor! Guest
|
Posted: Sun Apr 27, 2008 7:56 pm Post subject: |
|
|
| Its very easy, especially in combination wuth Tray module. If u use custom tray module u will get notification about icon clicks and u can choose to show MMenu in that moment. |
|
| Back to top |
|
 |
majkinetor! Guest
|
Posted: Sun Apr 27, 2008 7:57 pm Post subject: |
|
|
| BTW, u may also try great Lexicos Menu addon if u dont need advanced Menu API and u only care about icons in menus. It will also look better on Vista AFAIK. |
|
| Back to top |
|
 |
Ankur Guest
|
Posted: Fri Jun 27, 2008 4:06 am Post subject: |
|
|
can you please help with the some basic example of mmenu.
- Notepad should have simple tooltip like – creates and edits the text file using basic text formatting; it should execute “run notepad”
- Calc should have simple tooltip like – this simple calc application. Clicking on Calc it should execute run Calc.
- () Print should has tooltip like; this is text for print function. On click,it should types like “send print ()”
Any thought would be highly appreciate.
| Code: |
myMenu := MMenu_Create(C0 TFFFFFF), UtilsMenu := MMenu_Create(C0 TFFFFFF), SendStringsMenu := MMenu_Create(C0 TFFFFFF)
s = %A_WinDir%\System32\Shell32.dll
MMenu_Add(myMenu,"Notepad")
MMenu_Add(myMenu,"Wordpad")
MMenu_Add(myMenu)
MMenu_Add(myMenu,"Utils", s ":" 3, 0, "iv103 m" . UtilsMenu)
MMenu_Add(UtilsMenu,"Calc", s ":"8)
MMenu_Add(UtilsMenu,"Ms Paint", s ":"8)
MMenu_Add(myMenu,"Send Strings", s ":" 3, 0, "iv103 m" . SendStringsMenu)
MMenu_Add(SendStringsMenu,"print()", s ":" 9, 0, "")
MMenu_Add(SendStringsMenu,"exit ()", s ":" 9, 0, "")
MMenu_Show( 1, X, Y, "OnClick", "SOnSelect UOnUninit")
OnSelect:
MMenu_GetPosition(M_SMENU, X, Y) ;get the position of the currently open menu
msg := aMyTooltips%M_SID% ;M_SID is the item id
Tooltip %msg%, % X + 5, % Y – 30 ,Hi! ;and display tooltip above it
return
OnUninit:
Tooltip ;close the tooltip when the (sub)menu closes
return
MouseGetPos, x, y
MMenu_Show(myMenu, x, y, "OnItemClick")
Return
#include includes
#include MMenu.ahk
#include structs.ahk
|
|
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Fri Jun 27, 2008 9:24 am Post subject: |
|
|
| Code: | setbatchlines, -1
myMenu := MMenu_Create("C0 TFFFFFF"), UtilsMenu := MMenu_Create("C0 TFFFFFF"), SendStringsMenu := MMenu_Create("C0 TFFFFFF")
aMyTooltips_Notepad := "run notepad"
aMyTooltips_Calc := "this simple calc application"
s = %A_WinDir%\System32\Shell32.dll
MMenu_Add(myMenu,"Notepad", "", 0, "iNotepad")
MMenu_Add(myMenu,"Wordpad")
MMenu_Add(myMenu)
MMenu_Add(myMenu,"Utils", s ":" 3, 0, "iv103 m" . UtilsMenu)
MMenu_Add(UtilsMenu,"Calc", s ":"8, 0, "iCalc")
MMenu_Add(UtilsMenu,"Ms Paint", s ":"8)
MMenu_Add(myMenu,"Send Strings", s ":" 3, 0, "iv103 m" . SendStringsMenu)
MMenu_Add(SendStringsMenu,"print()", s ":" 9, 0, "")
MMenu_Add(SendStringsMenu,"exit ()", s ":" 9, 0, "")
MMenu_Show( 1, 100, 100, "OnClick", "SOnSelect UOnUninit")
return
OnSelect:
Tooltip % aMyTooltips_%M_SID%
return
OnUninit:
Tooltip ;close the tooltip when the (sub)menu closes
return
OnClick:
Run, %M_TItle%
return
MouseGetPos, x, y
MMenu_Show(myMenu, x, y, "OnItemClick")
Return
#include includes
#include MMenu.ahk
#include structs.ahk |
_________________
 |
|
| Back to top |
|
 |
AnKUR Guest
|
Posted: Fri Jul 04, 2008 10:07 am Post subject: |
|
|
This is a great piece of work...helped me a lot thanks  |
|
| 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
|