Sign in to follow this  
Followers 0
LithiumLi

Tray Question

7 posts in this topic

#1 ·  Posted (edited)

I want to know if I can have tray and GUI in the same while loop.

If possible can you please keep it simple since I already have a huge GUI loop and now my friend has decided he wants it also in the tray :)

While 1
   $GGM = GUIGetMsg()
Switch $GGM   
$TGM = TrayGetMsg()
    Select
        Case $MyGUI
                _MyGUIFunction()
        Case $TGM = $MyTray
                _MyTrayFunction()
EndSwitch
    EndSelect
WEnd

Thanks :)

Edited by LithiumLi

Share this post


Link to post
Share on other sites



You can use AutoIt's tray for your own needs like new menu items or different icon, or primary mouse double click event upon the tray...

Share this post


Link to post
Share on other sites

You can use AutoIt's tray for your own needs like new menu items or different icon, or primary mouse double click event upon the tray...

I know but how can I have a GUI + Tray in the same while loop :)

Share this post


Link to post
Share on other sites

I'd like to suggest using "TrayOnEventMode" or TrayItemSetOnEvent() instead of handling it from within a msg handling loop. If you're insisting to use it within a msg loop you can use the TrayGetMsg() function...

Share this post


Link to post
Share on other sites

I'd like to suggest using "TrayOnEventMode" or TrayItemSetOnEvent() instead of handling it from within a msg handling loop. If you're insisting to use it within a msg loop you can use the TrayGetMsg() function...

I know but can you provide example of using GUI + Tray while/loop please that is what I need.

Share this post


Link to post
Share on other sites

Opt('TrayMenuMode', 1)

Dim $hGUI, $bt
Dim $Frist, $SecondSub, $Third

$hGUI = GUICreate('Title', 400, 385)
$bt = GUICtrlCreateButton('Button&1', 170, 177, 60, 30)

$Frist = TrayCreateMenu('First')
$SecondSub = TrayCreateItem('SecondSub', $Frist)
$Third = TrayCreateItem('Third')

GUISetState()

While 1
    Local $msg = GUIGetMsg()
    Local $tMsg = TrayGetMsg()
    
    Switch $msg
        Case $bt
            MsgBox(0x40, 'Title', 'Button')
            
        Case -3
            ExitLoop
    EndSwitch
    
    Switch $tMsg
        Case $SecondSub
            MsgBox(0x40, 'Tray', 'SecondSub')
            
        Case $Third
            MsgBox(0x10, 'Tray', 'Third')
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit

Share this post


Link to post
Share on other sites

Opt('TrayMenuMode', 1)

Dim $hGUI, $bt
Dim $Frist, $SecondSub, $Third

$hGUI = GUICreate('Title', 400, 385)
$bt = GUICtrlCreateButton('Button&1', 170, 177, 60, 30)

$Frist = TrayCreateMenu('First')
$SecondSub = TrayCreateItem('SecondSub', $Frist)
$Third = TrayCreateItem('Third')

GUISetState()

While 1
    Local $msg = GUIGetMsg()
    Local $tMsg = TrayGetMsg()
    
    Switch $msg
        Case $bt
            MsgBox(0x40, 'Title', 'Button')
            
        Case -3
            ExitLoop
    EndSwitch
    
    Switch $tMsg
        Case $SecondSub
            MsgBox(0x40, 'Tray', 'SecondSub')
            
        Case $Third
            MsgBox(0x10, 'Tray', 'Third')
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit
Thanks very much ill try adding it in my script now :)

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