Jump to content

how to make a submenu to the system tray menu


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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'

 

Link to comment
Share on other sites

  • 3 years later...
  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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