Jump to content

Minimize to Tray


DaLiMan
 Share

Recommended Posts

Hi,

First I like to say I love this new option for minimizing to the tray. :D

Thanx to those who made it possible. :)

Now for my problem.

When I minimize my app. to the tray and restore it all works well.

But when I try to restore it from restarting it, sort of Double Run check it keeps hanging. It does restore the GUI visibly, but the GUI does not react.

TrayIconDebug says : $msg = GuiGetMsg()

Here's some parts of the code:

Global $Versie = "1.0.1.5";FileGetVersion(@ScriptFullPath)
Global $Name = "ITP manager ©"

Global Const $TRAY_DEFAULT = 512
$TrayRestWindow = TrayCreateItem("Open " & $Name)
TraySetItemState(-1, $TRAY_DEFAULT)
TraySetClick ( 16 )

If WinExists($Name) Then
        GuiSetState(@SW_RESTORE, $Name);show GUI
        Opt("TrayIconHide", 1);hide tray icon
    WinActivate($Name)
    Exit
EndIf
 
; Script generated by AutoBuilder 0.5 Prototype
GuiCreate($Name & " - v."& $Versie, 262, 245,(@DesktopWidth-262)/2, (@DesktopHeight-135)/5 )
GUISetBkColor (0xFFFFFF)
; Ordernummer
$Group_6 = GuiCtrlCreateGroup("Geef uw Ordernummer :", 10, 40, 240, 45)
$Input_1 = GUICtrlCreateInput("",20,58,220,17,-1,-1)
; Order / Offerte knop
$Group_5 = GuiCtrlCreateGroup("Geef uw keuze :", 10, 90, 240, 70)
$But_Order = GuiCtrlCreateButton("Order&bevestiging", 20, 110, 100, 40)
$But_Offerte = GuiCtrlCreateButton("&Offerte", 140, 110, 100, 40)
; ProgressBar
$ProgressBar1 = GUICtrlCreateProgress (20,168,220,15)
$Label_PrgsBar = GuiCtrlCreateLabel(" "&"ITP manager - Progress info", 20, 185, 220, 15)
GUICtrlSetBkColor (-1,0x004080)
GUICtrlSetColor(-1,0xFFFFFF)
; STOP knop / annuleren info
$But_STOP = GuiCtrlCreateButton("S T O P", 20, 207, 220, 17)
$But_Cancel = GuiCtrlCreateButton("Druk [ESC] om te annuleren!!!", 20, 207, 220, 17)
GUICtrlSetState(-1,$GUI_DISABLE + $GUI_HIDE)
; Datum / gebruiker info
$Label_3 = GuiCtrlCreateLabel("  Datum      : " & $Today &@CRLF& "   Gebruiker   : " & $Naam, 20, 6, 222, 30, $SS_SUNKEN)
GUICtrlSetBkColor (-1,0xBFEBFF)
; Auteur info
$Label_4 = GuiCtrlCreateLabel("Daniel Lith - Solar Beverwijk", 0, 232, 262, 15,$SS_CENTER)

GuiSetState()

While 1
    $trayMsg = TrayGetMsg() 
    $msg = GuiGetMsg()
    
    Select
    Case $trayMsg = $TrayRestWindow
        GuiSetState(@SW_RESTORE);show GUI
        Opt("TrayIconHide", 1);hide tray icon
   ;
   ; rest of code
Wend
Link to comment
Share on other sites

Try getting rid of Opt("trayIconHide", 1) and instead use traySetState() to hide and show the icon.

I think Opt("trayIconHide") is for only using once in a program to either have it on or off for the whole app cycle.

Maybe it could be deprecated in favor of the new Tray() functions.

While 1
    $trayMsg = TrayGetMsg() 
    $msg = GuiGetMsg()
    
    Select
    Case $trayMsg = $TrayRestWindow
        GuiSetState(@SW_RESTORE);show GUI
        Opt("TrayIconHide", 1);hide tray icon
  ;
  ; rest of code
Wend
Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

Ah yes, i am using the latest beta. I always forget that not everyone might be using that :">

try this:

#include <guiconstants.au3>
#include <constants.au3>

opt ("TrayAutoPause", 0)
opt ("TrayMenuMode", 1)

GUICreate("test", 200, 200)
traySetState (@SW_HIDE)

GUISetState()

Do
    $msg = GUIGetMsg()
    $trayMsg = TrayGetMsg ()
    
    Select
        Case $msg = $GUI_EVENT_MINIMIZE
            traySetState (@SW_SHOW)
            GUISetState(@SW_HIDE)
        Case $trayMsg = $TRAY_EVENT_PRIMARYDOWN
            traySetState (@SW_HIDE)
            GUISetState(@SW_SHOW)
    EndSelect
    
Until $msg = $GUI_EVENT_CLOSE
Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

Nope, does not work also.....

Is there a problem with resetting the TraySettings from 1 script to another?

I mean, when my script is minimized at the tray and I start the same script a second time I like this second script to restore the first one and exit itself.

But I think the TraySettings cannot be done from 1 script to another.

Link to comment
Share on other sites

Hmm the example i gave works perfectly over here. I am using the latest beta though.

But, yeah I think you're right. I don't think a script can directly access another programs tray icon. (Not yet anyway)

I added some code to my example. It will kill any new instance of the script and restore the first one. The only problem is the tray icon appears even though the window is activated. But code could be written to fix that.

#include <guiconstants.au3>
#include <constants.au3>

#NoTrayIcon

opt ("TrayAutoPause", 0)
opt ("TrayMenuMode", 1)

if WinExists("test") then 
    WinActivate("test")
    exit
EndIf

    
GUICreate("test", 200, 200)
traySetState (@SW_HIDE)

GUISetState()

Do
    $msg = GUIGetMsg()
    $trayMsg = TrayGetMsg ()
    
    Select
        Case $msg = $GUI_EVENT_MINIMIZE
            traySetState (@SW_SHOW)
            GUISetState(@SW_HIDE)
        Case $trayMsg = $TRAY_EVENT_PRIMARYDOWN
            traySetState (@SW_HIDE)
            GUISetState(@SW_SHOW)
    EndSelect
    
Until $msg = $GUI_EVENT_CLOSE
Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

I have approx. the same code over here and it does restore the window.

BUT, the GUI does not response to input anymore now.

I think it's just not possible right now.

( Maybe one of the dev's can react to that? ) [Holger] :)

I think I have to step back and take another approach.... :D

Link to comment
Share on other sites

Hi DaLiMan :)

this is NOT possible this way cause it is right, two different script(s)-icons can not communicate with each other this way.

Don't had to think about it so long but 1 (ugly) possibility would be if you create a temporary file like i.e. "restore.gui" or something like this and in you script you check in the message-loop for the existence of such a file.

If it exists then you restore the gui, delete the icon and this temporary file.

Regards Holger

Link to comment
Share on other sites

  • 2 weeks later...

What version is this??  I have the latest beta but I can't get the minimize to tray scripts working.

<{POST_SNAPBACK}>

I use the latest beta from JPM.

You can find it here. < Latest Beta >

For the record:

Copy the extracted files to:

AutIt3.exe + AutoIt.chm -> C:\Program Files\AutoIt3

AutoItSC.bin -> C:\Program Files\AutoIt3\Aut2Exe

Constants.au3 + GUIconstants.au3 -> C:\Program Files\AutoIt3\Include

Enjoy ! :)

PS: I saw there was also a latest unstable v3.1.1 from 10-3-2005.

Can someone tell me the difference between the 2?

Link to comment
Share on other sites

3.1.1 is what I have. So maybe something isn't in it?

I'll give this 3.1.0.15 a try. Thanks!

EDIT-- It works, there's a whole bunch of functions in here that weren't in the one I was using.

Edited by momitty
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...