AutoHotkey Community

It is currently May 26th, 2012, 3:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 149 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10  Next
Author Message
 Post subject:
PostPosted: January 17th, 2008, 11:21 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
I've been playing around with this for a bit and I have questions. (as usual :roll: )

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2008, 11:38 pm 
You have to learn AHK first
MMenu_Add( main, A_LoopField, "shell32.dll:4")


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2008, 11:44 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
heh... thanks, those percent signs are always my bane. :x

It appears that solves the spaces issue too! yay!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2008, 11:44 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
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:
Image

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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2008, 2:58 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
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

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2008, 8:51 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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 :D 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... :D

AHK is full of strange things on message-liek frequencies. Its simply not designed for that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2008, 10:17 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
@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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2008, 11:52 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Thank you

... and enjoy!

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2008, 10:17 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2008, 12:25 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
Look back one page in this thread, where I answered that question.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2008, 7:56 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2008, 7:57 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2008, 4:06 am 
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.

Image

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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2008, 9:24 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2008, 10:07 am 
This is a great piece of work...helped me a lot thanks :-)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 149 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], Google Feedfetcher, oldbrother, Yahoo [Bot] and 20 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