Jump to content
Sign in to follow this  
LithiumLi

Tray Question

Recommended Posts

LithiumLi

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
Authenticity

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
LithiumLi

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
Authenticity

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
LithiumLi

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
Authenticity

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
LithiumLi

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.