Sign in to follow this  
Followers 0
shawnmstout

how to make a submenu to the system tray menu

7 posts in this topic

i know to create a tray icon menu item its TrayCreateItem("Tools") but how can i make submenu items inside of tools?

Share this post


Link to post
Share on other sites



Right out of the help file:

#Include <Constants.au3>
#NoTrayIcon

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$settingsitem   = TrayCreateMenu("Settings")
$displayitem    = TrayCreateItem("Display", $settingsitem)
$printeritem    = TrayCreateItem("Printer", $settingsitem)
TrayCreateItem("")
$aboutitem      = TrayCreateItem("About")
TrayCreateItem("")
$exititem       = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $aboutitem
            Msgbox(64,"about:","AutoIt3-Tray-sample")
        Case $msg = $exititem
            ExitLoop
    EndSelect
WEnd

Exit

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

BuckMaster, sorry for wasting your time, i looked after i asked and figured it out, thanks for responding, could you answer me 1 other question i cant seem to find, how can i run a au3 file on a menu click? as you can see im quite new with this, just started programming with it today

here is an example of what i was trying to do

$diagnostics = TrayCreateMenu("Diagnostics")

$memoryStats = TrayCreateItem("Memory Status", $diagnostics)

TraySetState()

While 1

$msg = TrayGetMsg()

Select

Case $msg = 0

ContinueLoop

Case $msg = $memoryStats

run("memorystats.au3") <----this is what im trying to run

EndSelect

WEnd

Exit

Edited by shawnmstout

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

use shellexecute (here's a snippet from my code)

ShellExecute($sFilename, "", @ScriptDir, "run")

Note the "run" action...this is what uses the shell to run (versus edit) the au3.

If your PC is already setup to run au3 files when they are 'dbl-clicked' in explorer, the "run" action is not needed...it just forces the issue.

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites

wow this is great, now i got all kind of technician tools that automatically download and run, thanks alot

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Can we go one level deeper?

Menu 1

- Sub menu 1 1

- Sub sub menu 1 1 1

- Sub menu 1 2

Menu 2

- Sub menu 2 1

Is this can be achieved somehow please?

Edited by KamilZajaczkowski

Share this post


Link to post
Share on other sites

KamilZajaczkowski,

You do it like this: ;)

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$mMenu_1 = TrayCreateMenu("Menu 1")
$mMenu_1_1 = TrayCreateMenu("Menu 1 1", $mMenu_1)
$mMenu_1_1_1 = TrayCreateItem("Menu 1 1 1", $mMenu_1_1)
$mMenu_1_2 = TrayCreateItem("Menu 1 2", $mMenu_1)
$mMenu_2 = TrayCreateMenu("Menu 2")
$mMenu_2_1 = TrayCreateItem("Menu 2 1", $mMenu_2)

While 1
    Switch TrayGetMsg()
        Case $mMenu_1_1_1
            Msgbox(0, "Menu", "1 1 1")
        Case $mMenu_1_2
            Msgbox(0, "Menu", "1 2")
        Case $mMenu_2_1
            Msgbox(0, "Menu", "2 1")
    EndSwitch
WEnd

All clear? :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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