Jump to content

how to make custom taskbar context menu


jercfd
 Share

Recommended Posts

How would I make a custom context menu for an autoit application.

Example

Posted Image

I found some delphi code to do it at http://delphi.about.com/od/vclwriteenhance...taskbarmenu.htm and at http://delphi.about.com/od/windowsshellapi/a/system_menu.htm.

It says it uses the GetSystemMenu API and commands like AppendMenu, SetMenuItemInfo, and TMenuItemInfo. Then it traps the WM_SYSCOMMAND message to see if the menu item was clicked.

Link to comment
Share on other sites

How would I make a custom context menu for an autoit application.

Example

Posted Image

I found some delphi code to do it at http://delphi.about.com/od/vclwriteenhance...taskbarmenu.htm and at http://delphi.about.com/od/windowsshellapi/a/system_menu.htm.

It says it uses the GetSystemMenu API and commands like AppendMenu, SetMenuItemInfo, and TMenuItemInfo. Then it traps the WM_SYSCOMMAND message to see if the menu item was clicked.

Maybe modernMenu will help
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Isn't Modern menu just supposed to add styles to the context menu? I want to create a custom context menu when you right click the application in the taskbar (shows restore, move, size, minmize, maximize, and close context menu)

Link to comment
Share on other sites

Isn't Modern menu just supposed to add styles to the context menu? I want to create a custom context menu when you right click the application in the taskbar (shows restore, move, size, minmize, maximize, and close context menu)

Help File >>Function Reference>>Tray Functions

See TrayCreateMenu() and TrayCreateItem()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I don't want to add the context menu into the tray icon. I want it on the application itself where all the windows on the taskbar are located. The context menu is made by the operating system by default and I want to modify it.

Possible example

Posted Image

Link to comment
Share on other sites

OK, you have to use the GUIMenu.au3:

#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hTransparencyMenu, $hSysMenu
Global Enum $idFIRSTITEM=1000 , $idTrans0, $idTrans10, $idTrans20, $idTrans30, $idTrans40, $idTrans50, $idTrans60, $idTrans70, $idTrans80, $idTrans90, $idTrans100, _
                $idToTray,$idOnTop,$idHide,$idLASTITEM
Global $MENU_RECEIVER

_Main()

Func _Main()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)
    $hSysMenu   = _GUICtrlMenu_GetSystemMenu($hGUI)
    $hTransparencyMenu = _GUICtrlMenu_CreateMenu()
    For $i=0 To 100 Step 10
        _GUICtrlMenu_AddMenuItem($hTransparencyMenu,$i & " %",Eval("idTrans"&$i))
    Next
    _GUICtrlMenu_InsertMenuItem($hSysMenu,0,"&Transparency",0,$hTransparencyMenu)
    _GUICtrlMenu_InsertMenuItem($hSysMenu,1,"Send To Tray",$idToTray)
    _GUICtrlMenu_InsertMenuItem($hSysMenu,2,"Stay On Top",$idOnTop)
    _GUICtrlMenu_InsertMenuItem($hSysMenu,3,"Hide Window",$idHide)
    _GUICtrlMenu_InsertMenuItem($hSysMenu,4,"")
    
    _GUICtrlMenu_CheckRadioItem($hTransparencyMenu,$idTrans0,$idTrans100,$idTrans20,False)
    
    GUIRegisterMsg($WM_SYSCOMMAND,"WM_SYSCOMMAND")
    Global $MENU_RECEIVER = GUICtrlCreateDummy()
    
    GUISetState()
    
    
    ; Loop until user exits
    Local $MSG
    Do
        $MSG = GUIGetMsg()
        Switch $MSG
            Case $MENU_RECEIVER
                _SysMenu_ProcessMessage(GUICtrlRead($MENU_RECEIVER))
        EndSwitch
    Until $MSG = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

Func _SysMenu_ProcessMessage($ID)
    $ID = Number($ID)
    Switch $ID
        Case $idTrans0 To $idTrans100
            _GUICtrlMenu_CheckRadioItem($hTransparencyMenu,$idTrans0,$idTrans100,$ID,False)
            MsgBox(0, '', "Trans change")
        Case $idToTray
            MsgBox(0, '', "To Tray")
        Case $idOnTop
            MsgBox(0, '', "On Top Change")
            Local $WasChecked = (BitAND(_GUICtrlMenu_GetItemState($hSysMenu,$idOnTop,False),1)=1)
            _GUICtrlMenu_CheckMenuItem($hSysMenu,$idOnTop,Not $WasChecked,False)
        Case $idHide
            MsgBox(0, '', "Hide")
    EndSwitch
EndFunc

; Handle menu commands
Func WM_SYSCOMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    $iwParam = Number($iwParam)
    Switch $iwParam;_WinAPI_LoWord ($iwParam)
        Case $idFIRSTITEM To $idLASTITEM
            GUICtrlSendToDummy($MENU_RECEIVER,$iwParam)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

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...