Jump to content

TrayCreatItem with array


Recommended Posts

AutoItSetOption ( "TrayMenuMode" , 1 )

Dim $close[100]
Dim $order = 0


Do 

    $close[$order] = TrayCreateItem( $order )
    $order = $order + 1

Until $order == 10

While 1
    

    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $close[$order]
            Msgbox ( 0 , "The order is", $order )
    EndSelect
    

WEnd

Exit

this code should create 10 items on the traymenu, and it should display a msgbox with the corresponding number.

yet only the last one will produce such a result when selected.

How can I make this work ?

Link to comment
Share on other sites

AutoItSetOption ( "TrayMenuMode" , 1 )
Opt('TrayOnEventMode', 1)

Dim $close[100]
Dim $order = 0


Do

    $close[$order] = TrayCreateItem( $order )
    TrayItemSetOnEvent(-1, 'funkyfunc')
    $order = $order + 1

Until $order == 10

TrayCreateItem('')
TrayCreateItem('Exit')
TrayItemSetOnEvent(-1, 'quit')

While 1
   

    $msg = TrayGetMsg()

WEnd

Func funkyfunc()
    MsgBox(0, '', TrayItemGetText(@TRAY_ID))
EndFunc

Func quit()
    Exit
EndFunc

Edited by xcal
Link to comment
Share on other sites

Or another way to solve this (without OnEvent mode):

AutoItSetOption ( "TrayMenuMode" , 1 )

Dim $close[100]
Dim $order = 0

Do 

    $close[$order] = TrayCreateItem( $order )
    $order = $order + 1

Until $order == 10

While 1

    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case Else
            For $i = 1 To 10
                If $msg = $close[$i] Then
                    Msgbox ( 0 , "The order is", $i )
                    ExitLoop
                EndIf
            Next
            
    EndSelect

WEnd

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