Sign in to follow this  
Followers 0
ForsakenGod

More options ? :)

6 posts in this topic

Hello ,

I would like to ask how could i add up more options when the autoit incon in the right down edge is right clicked ? Now there is pause script and exit and my second question is can i delete those two ?

Share this post


Link to post
Share on other sites



If you use search you could find this

http://www.autoitscript.com/autoit3/docs/functions/TrayCreateMenu.htm

and this

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

First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack. -George Carrette[sub]GD Keylogger Creator (never released)[/sub][sub]Garena Autojoin v3.0[/sub]

Share this post


Link to post
Share on other sites

Whoops :( Sorry for that thanks anyway :)

Share this post


Link to post
Share on other sites

If you use search you could find this

http://www.autoitscript.com/autoit3/docs/functions/TrayCreateMenu.htm

and this

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

Hi adik2dmax666

I am a bit of a Newbee to AutoIt3 (a recent convert from AutoHotKey). I am looking for a way to Reload (Restart) a currently running Script from the System Tray Icon. I have fold a .au3 that will do the Restart but not sure is it is possible to have this as a Default option together with the existing "Script Paused / Exit" option.

In addition I would like to be able to edit the script with an Edit Script option.

Would appreciate any assistance / guidance you can provide.

Rgds

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

MadMaxx,

Welcome to the AutoIt forum. :mellow:

Here is how you can get the script to restart and be edited from the tray menu:

#include <GUIConstantsEx.au3>

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

$aboutitem = TrayCreateItem("About")
TrayCreateItem("")
$Edit = TrayCreateItem("Edit")
TrayCreateItem("")
$Restart = TrayCreateItem("Restart")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")

TraySetState()

$hGUI = GUICreate("Test", 500, 500)

; Label to hold counter
$hLabel = GUICtrlCreateLabel("0", 10, 10, 50, 50)
GUICtrlSetFont(-1, 24)

GUISetState()

$iBegin = TimerInit()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    Switch TrayGetMsg()
        Case $aboutitem
            MsgBox(64, "about:", "AutoIt3-Tray-sample")
        Case $Edit
            ; Convert AutoIt path to SciTE path
            $sScitePath = StringReplace(@AutoItExe, "autoit3.exe", "SCITE\SCITE.exe")
            ; Run SciTE on the script
            Run($sScitePath & ' "' & @ScriptFullPath & '"', @ScriptDir)
            Sleep(500)
            ; Wait until SciTE exits
            While ProcessExists("scite.exe")
                Sleep(10)
            WEnd
            ; And then start a new instnace of the modified script
            ContinueCase
        Case $Restart
            ; Run a new instance of the script
            Run(@AutoItExe & ' "' & @ScriptFullPath & '"', @ScriptDir)
            Sleep(50)
            ; Close this instance
            Exit
        Case $exititem
            Exit
    EndSwitch

    ; Increase counter
    If TimerDiff($iBegin) > 1000 Then
        GUICtrlSetData($hLabel, GUICtrlRead($hLabel) + 1)
        $iBegin = TimerInit()
    EndIf

WEnd

I hope that is understandable - please ask if you have any questions. :P

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :party:

Edit: Typnig!

Edited by Melba23

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

M23

Fantastic!!! Thanks Very Much!

Note your comments re "Add Reply" also & thx for the pointer.

Rgds

M

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