Jump to content

Tray Icons with Explorer Context Menu


Recommended Posts

I found some really nifty code here that can get me the contents of the Explorer context menu. So, using the ModernMenu code, I crafted together something that would put an icon in the notification area.

However, what I end up with is this picture:

Posted Image

instead of this context menu taken from Explorer:

Posted Image

How do I create the menu so that it looks like the Explorer context menu? I appreciate any assistance that anybody can give. Thanks in advance!

Here is the code I've got:

#include <ModernMenuRaw.au3>

dim $objShell = ObjCreate("Shell.Application")
dim $objFolder = $objShell.Namespace("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
dim $b = 1, $TRAY[ 27] [ 20 ]
    
; Get a listing of all drives attached to the computer:
$TList = DriveGetDrive( "ALL" )
If @error Then Return
For $a = 1 To $TList[0]
; Get drive icon to use in the tray menu:
    $TMP = RegRead( $ICN & StringLeft( $TList[ $a ], 1 ) & "\DefaultIcon", "" )
    $STR = StringSplit( $TMP, "," )
    $TMP = 0
    If $STR[0] > 1 Then $TMP = $STR[ 2 ]
    $b = $a
    
; Create the tray icon and related stuff:
    $TRAY[ $b ][ 0 ] = $TList[ $a ]
    $TRAY[ $b ][ 1 ] = _TrayIconCreate( "Drive " & StringUpper( $TList[ $a ] ), $STR[ 1 ], $TMP )
    $SHOW = _Iif( StringInStr( $MDrv, $TList[$a] ) <> 0, 1, 0 )
    $TRAY[ $b ][ 2 ] = _TrayCreateContextMenu()
    $b = _CreateSideMenu( $TRAY[ $b ][ 2 ] )
    _SetSideMenuText( $b, "Drive " & StringUpper( $TList[ $a ] ) )
    _SetSideMenuColor( $b, 0x00FFFF ) 
    _SetSideMenuBkColor( $b, 0x802222 )
    _SetSideMenuBkGradColor( $b, 0x4477AA )
    $TRAY[ $b ][ 3 ] = $objFolder.ParseName( $TList[ $a ] & "\")

    local $colVerbs = $TRAY[ $b ][ 3 ].Verbs, $objVerb
    For $objVerb in $colVerbs
        _TrayCreateItem( $objVerb() )
        _TrayItemSetIcon( -1, "", 0 )
    next
        
; Show the tray menu if required to do so:
    _TrayIconSetState()
Next
Edited by Dougiefresh
Link to comment
Share on other sites

The standard TrayCreateMenu() looks like the explorer context menu to me...

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

No, I'm not talking about the appearance of the tray menu. The side bar telling the which drive it is representing and the gray bar beside it are additional things that were added in order to make it look better to me....

I really meant the grouping of the context menu items. For example, "Make Bootable ISO", "Make Data ISO", "Change Attributes", and etc. are part of the "Power Tweaks" menu. The code I included reads the entire context menu, but I don't know how to tell which group the menu items that belong to. Can you help? Thanks!

Link to comment
Share on other sites

No, I'm not talking about the appearance of the tray menu. The side bar telling the which drive it is representing and the gray bar beside it are additional things that were added in order to make it look better to me....

I really meant the grouping of the context menu items. For example, "Make Bootable ISO", "Make Data ISO", "Change Attributes", and etc. are part of the "Power Tweaks" menu. The code I included reads the entire context menu, but I don't know how to tell which group the menu items that belong to. Can you help? Thanks!

I'm sorry, I misunderstood your post. However, the answer is the same. If you want to create submenus, you do so in TrayCreateMenu ( "sub/menutext" [, menuID [, menuentry]] ).
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

I'm sorry, I misunderstood your post. However, the answer is the same. If you want to create submenus, you do so in TrayCreateMenu ( "sub/menutext" [, menuID [, menuentry]] ).

I can create submenus just fine, thank you. Don't need help there....

Do use know how to use WMI? If so, please help me figure out what I need to do in order to figure out what submenus (if any) each menu goes into. I'm sure since WMI can retreive the names of the context items, that there is a way to retreive the submenu name as well. Once I have the submenu name, I can create the submenu so that the appearance of the code will closer match that of the Explorer context menu. Does this make sense? Appreciate it. Thanks!

Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...