Sign in to follow this  
Followers 0
qwertylol

TrayCreatItem with array

4 posts in this topic

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 ?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Updated my post in the Last Thread you started qwertylol.

Cheers

Edit: typo's doh

Edited by smashly

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