Sign in to follow this  
Followers 0
MHz

Au3Menu

4 posts in this topic

#1 ·  Posted (edited)

post-2709-0-46126100-1371813670_thumb.pnpost-2709-0-86605100-1371813704_thumb.pnpost-2709-0-61890700-1371813776_thumb.pn

Introduction

Au3Menu is a context menu handler for the shell and also a menu handler for editors. The use by the shell and editor makes it similar in operation in both cases. More options are available then what you may have had before. It is portable from an editor and can register entries to the HKCU branch in the registry to give you temporary or permanent entries to add the context menu for the shell. This makes it very good for use of AutoIt3 from a unzipped version.

It has been created to handle multiple versions of AutoIt, Aut2Exe etc by using subfolder combo box selection.

It has options to run Scite Installed or Scite Portable with Scite_Home set and other editors could be added to the source so it is extensible.

It reads the source to set combo box items by certain keywords found so it sets suitable defaults for you. You may consider that running windows from an editor may slow things down but I have noticed little affect. If I run something from Scite, then I press F5 to open the run window, notice the selection default is good and just press the spacebar to run the script.

Compiling does more by having a3x, AutoIt3Wrapper handling and Aut2Exe Gui.

It has RunAs ability and it makes getting Stdout easier by showing a separate window that the editor console may not be able to do. It can prompt for old AutoIt versions that use the AutoIt3A.exe ANSI version if it detects it and prompts for its possible use. It allows parameters to be passed from the context menu or editor menu when wanting to run scripts.

A Tools selection is available so you can run tool scripts on au3 scripts from the context menu or editor menu. I have supplied just an example tool script and a template. More tools can be created by you or I may offer some in the download section. Tools are put into the Au3Tools folder and Au3Menu will add them to the selection automatically.

Require

AutoIt 3.3.8.1 or later

Download

au3menu.zip

Version: 1.4
Size: 600 KB

Available for use under the terms of GPL v3

Some tool scripts can be found here

Homepage is here

Cheers :)

Edit: Updated to version 1.4

Added check for Pragma Compile directives introduced in AutoIt 3.3.10.0. Other compile options may not be available when Pragma Compile directives exist to avoid a mixture of settings used for compilation.

Edited by MHz

Share this post


Link to post
Share on other sites



Since most people now use windows 7+, you could look at using a submenu as an option. This is also possible pre win7, but a lot more tricky. Personally I don't like lots of menu items, so I just have "Run", "Edit" and then a submenu with the AutoIt3Wrapper commands.

Share this post


Link to post
Share on other sites

Hi Mat

Thanks for the link. The directions there are like an attempt to pass the Star Trek Kobayashi Maru test :). I used a different structure to get the sub menus to work as shown below.

\---txtfile
    \---shell
        \---mainkey
            |   muiverb=main_title
            |   subcommands=
            |   
            \---shell
                \---subkey1
                    |   muiverb=sub_title_1
                    |   subcommands=
                    |   
                    \---shell
                        \---subkey2
                            |   muiverb=sub_title_2
                            |   subcommands=
                            |   
                            \---shell
                                \---subkey3
                                    |   muiverb=sub_title_3
                                    |   subcommands=
                                    |   
                                    \---shell
                                        \---appkey
                                            |   icon=app_icon_path
                                            |   muiverb=app_title
                                            |   
                                            \---command
                                                    @=path_to_app

I perhaps think just like you do. I consider that many users like a simple context menu system. I looked for a possible balance where some simple context menu entries exist and the entries passed the parameters to 1 main handling application to dynamically choose based on directives. The AutoIt3Wrapper GUI does this from the context menu to some extent with reading directives. Au3Menu is an attempt to handle all au3 related commands from the context menu and to dynamically choose based on directives so you can take it easy. And since much of this behavior in Au3Menu can also be used from a menu system in an editor, so I added some code to enable it to handle this as well.

I use Au3Menu in both context menu handler and as Scites menu handler and it seems to be working well. I may need to consider an option for cascading menu if >= Win7. Or perhaps you can modify the source and show us how it is done to your desire.

Thankyou for your interest and ideas.

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • ChrisL
      By ChrisL
      #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> Global $g_hTreeView Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo Example() Func Example() Local $hGUI, $hItem Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $hGUI = GUICreate("(UDF Created) TreeView Create", 400, 300) $g_hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") _GUICtrlTreeView_BeginUpdate($g_hTreeView) For $x = 1 To Random(2, 10, 1) $hItem = _GUICtrlTreeView_Add($g_hTreeView, 0, StringFormat("[%02d] New Item", $x)) For $y = 1 To Random(2, 10, 1) _GUICtrlTreeView_AddChild($g_hTreeView, $hItem, StringFormat("[%02d] New Child", $y)) Next Next _GUICtrlTreeView_EndUpdate($g_hTreeView) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam ;ConsoleWrite($GUI_RUNDEFMSG & @CRLF) ;Switch $wParam ; Case $hTreeView Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True ;EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_CONTEXTMENU Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $wParam Case $e_idOpen _DebugPrint("WM_COMMAND " & $wParam & " Open") Case $e_idSave _DebugPrint("WM_COMMAND " & $wParam & " Save") Case $e_idInfo _DebugPrint("WM_COMMAND " & $wParam & " Info") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = $g_hTreeView If Not IsHWnd($g_hTreeView) Then $hWndTreeview = GUICtrlGetHandle($g_hTreeView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeview Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint In the example code I have a treeview and a context/popup menu, I can't use a conventional context menu because I need to use the treeview UDF functions.
      The WM_COMMAND never fires from the context/popup menu selection while there is a treeview using  _GuiCtrlTreeview_Create
      If you comment out _GuiCtrlTreeview_Create line you will then see the right click selection works as expected and the debug is written to the console on selection.
      Autoit Ver 3.3.14.2
      Any ideas why this combination won't work together?
      Thanks
       
    • dubd83
      By dubd83
      I am working on an automation project and I am having issues finding documentation on selecting an item from a context menu, or a menu that appears upon a right click. I tried using the Send("{DOWN}") command as a workaround but it's not very redundant. Essentially I need to search the context menu for the string "Abort Text" and click that option. The class of the context menu is showing as CLASS:#32768. I have uploaded a portion of the context menu. If it helps I have the handle of the treeview where the first item is right clicked in order to make the treeview appear.
       
       

    • Leo1906
      By Leo1906
      Hello Guys,
      I was looking for a way to disable a Windows Context Menu Entry (not delete it!). So that it's not clickable and greyed out, like the "Empty Recycle Bin" Entry when the Recycle Bin is empty ..
      I did a lot of reseach, but all I could find was this one: 
       But it doesn't work for me ..
      I also took a look at this one: 
      But I wasn't able to properly run it on Windows 10 x64. So it was no help either ..
      I need a command to simply disable and enable the Entry. :/
      Any ideas on this one?
    • Stacker
      By Stacker
      Hi all,
      i need to enable/disable an item($listitem3) on context menu if find a specific value in listview ($idlistview).The item start disable (see code)
      I use GUIGetMsg() in my code
       
      $listtxt = GUICtrlCreateContextMenu($idListView) $listitem1 = GUICtrlCreateMenuItem("Ignore", $idListView) $listitem2 = GUICtrlCreateMenuItem("Remove Ignore", $idListView) $listitem3 = GUICtrlCreateMenuItem("Provide", $idListView) GUICtrlSetState(-1,$GUI_disable) Any suggestion ?
      Thanks
       
       
       
       
    • DJSizzlePuff
      By DJSizzlePuff
      Hi all! I'm working on my first GUI application, and there's something I'm trying to figure out how to do. I've searched the forums and the help file and didn't see anything that could help me.
      I have a context menu that opens from a button on the bottom of my GUI's form. What I'd *like* it to do is have it expand upward instead of downward. I'm using Example 2 from the help file section on GUICtrlCreateContextMenu as the basis for what I'm doing.
      My question is: is there something simple like a flag I can set or some other trick to just tell the context menu which way to expand, something like "ExpandDirection"? The other way I guess would be to figure out the height of the context menu and subtract that rather than add that from the position of my button control, however I tried using ControlGetPos on the controlID of the GUICtrlCreateContextMenu variable (as well as the GUICtrlCreateDummy variable) and that doesn't seem to work.
      Any advice on how to get a context menu to open the way I want it to?
      Also, what's the best way to set the width of a context menu despite how long the actual subitems in the context menu are? I know I can pad the menu item text with extra spaces, but is there a way to set exact pixels instead?
      (By the way, I've attached a screen shot of what I've got and what I'd like to accomplish, as well as the code I'm using from Example 2 of GUICtrlCreateContextMenu)
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $hGui = GUICreate("My GUI", 170, 40) Local $idOptionsBtn = GUICtrlCreateButton("&Options", 10, 10, 70, 20, $BS_FLAT) ; At first create a dummy control for the options and a contextmenu for it Local $idOptionsDummy = GUICtrlCreateDummy() Local $idOptionsContext = GUICtrlCreateContextMenu($idOptionsDummy) GUICtrlCreateMenuItem("Common", $idOptionsContext) GUICtrlCreateMenuItem("File", $idOptionsContext) GUICtrlCreateMenuItem("", $idOptionsContext) Local $idOptionsExit = GUICtrlCreateMenuItem("Exit", $idOptionsContext) Local $idHelpBtn = GUICtrlCreateButton("&Help", 90, 10, 70, 20, $BS_FLAT) ; Create a dummy control and a contextmenu for the help too Local $idHelpDummy = GUICtrlCreateDummy() Local $idHelpContext = GUICtrlCreateContextMenu($idHelpDummy) GUICtrlCreateMenuItem("Website", $idHelpContext) GUICtrlCreateMenuItem("", $idHelpContext) Local $idHelpAbout = GUICtrlCreateMenuItem("About...", $idHelpContext) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $idOptionsExit, $GUI_EVENT_CLOSE ExitLoop Case $idOptionsBtn ShowMenu($hGui, $idMsg, $idOptionsContext) Case $idHelpBtn ShowMenu($hGui, $idMsg, $idHelpContext) Case $idHelpAbout MsgBox($MB_SYSTEMMODAL, "About...", "GUICtrlGetHandle-Sample") EndSwitch WEnd GUIDelete() EndFunc ;==>Example ; Show a menu in a given GUI window which belongs to a given GUI ctrl Func ShowMenu($hWnd, $idCtrl, $idContext) Local $aPos, $x, $y Local $hMenu = GUICtrlGetHandle($idContext) $aPos = ControlGetPos($hWnd, "", $idCtrl) $x = $aPos[0] $y = $aPos[1] + $aPos[3] ClientToScreen($hWnd, $x, $y) TrackPopupMenu($hWnd, $hMenu, $x, $y) EndFunc ;==>ShowMenu ; Convert the client (GUI) coordinates to screen (desktop) coordinates Func ClientToScreen($hWnd, ByRef $x, ByRef $y) Local $tPoint = DllStructCreate("int;int") DllStructSetData($tPoint, 1, $x) DllStructSetData($tPoint, 2, $y) DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($tPoint)) $x = DllStructGetData($tPoint, 1) $y = DllStructGetData($tPoint, 2) ; release Struct not really needed as it is a local $tPoint = 0 EndFunc ;==>ClientToScreen ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu