Jump to content

co-running two functions


 Share

Recommended Posts

I want the tray buttons working while it sleep

$prefsitem  = TrayCreateItem("Preferences")
TrayCreateItem("")
$aboutitem  = TrayCreateItem("About")
TrayCreateItem("")
$exititem   = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $prefsitem
            Msgbox(64, "Preferences:", "OS:" & @OSVersion)
        Case $msg = $aboutitem
            Msgbox(64, "About:", "AutoIt3-Tray-sample.")
        Case $msg = $exititem
            ExitLoop
    EndSelect
WEnd

sleep(353522)
Link to comment
Share on other sites

I want the tray buttons working while it sleep

$prefsitem  = TrayCreateItem("Preferences")
TrayCreateItem("")
$aboutitem  = TrayCreateItem("About")
TrayCreateItem("")
$exititem   = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $prefsitem
            Msgbox(64, "Preferences:", "OS:" & @OSVersion)
        Case $msg = $aboutitem
            Msgbox(64, "About:", "AutoIt3-Tray-sample.")
        Case $msg = $exititem
            ExitLoop
    EndSelect
WEnd

sleep(353522)
This is what event mode was invented for:
Opt("TrayOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayMenuMode", 1)

Global $prefsitem = TrayCreateItem("Preferences")
TrayItemSetOnEvent(-1, "_TrayItemHit")
TrayCreateItem("")
Global $aboutitem = TrayCreateItem("About")
TrayItemSetOnEvent(-1, "_TrayItemHit")
TrayCreateItem("")
Global $exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_TrayItemHit")
TraySetState()

While 1
    Sleep(353522)
WEnd

Func _TrayItemHit()
    Switch @TRAY_ID
        Case $prefsitem
            MsgBox(64, "Preferences", "You clicked on preferences")
        Case $aboutitem
            MsgBox(64, "About", "You clicked on about")
        Case $exititem
            Exit
    EndSwitch
EndFunc  ;==>_TrayItemHit

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This is what event mode was invented for:

Opt("TrayOnEventMode", 1)

;)

Thanks a lot! That's exactly what I searched for a few days ago.

@ Dev / Doku Team:

In the Help File all the Opt() do not have particular examples for all the options.

This sample code for Opt("TrayOnEventMode",1) might be enlighting for others, too?

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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