Jump to content

Minimize To System Tray


Recommended Posts

I am also looking for same thing i suppose : a little script to put an application, which is already running (minimized or not), in the tray bar and minimized.

Later, it should be possible to restore this application, just doing a simple or double clic. :)

If somebody can provide us that, we will be very happy. :(

Best Regards :D

Link to comment
Share on other sites

How about using WinSetState, see example in help file for use.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

#include <GuiConstants.au3>
#include <Constants.au3>

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)   
Opt("TrayIconHide", 0)

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent")
TraySetState()


GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

GuiSetState()

While 1
    $msg = GuiGetMsg()
    
    Select
    Case $msg = $GUI_EVENT_MINIMIZE 
        
    GuiSetState(@SW_HIDE)
    Opt("TrayIconHide", 0)  

    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd



Func SpecialEvent()
    GuiSetState(@SW_Show)
    Opt("TrayIconHide", 1)
EndFunc

Edited by ChrisL
Link to comment
Share on other sites

Hi Chris,

When running the above code..I am getting the variable used before declaration error

C:\Scraps\test1.au3(8,37) : WARNING: $TRAY_EVENT_PRIMARYUP: possibly used before declaration.

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Scraps\test1.au3(8,37) : ERROR: $TRAY_EVENT_PRIMARYUP: undeclared global variable.

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Using BETA version..

cheers,

[font="Franklin Gothic Medium"]RnJ[/font][font="Franklin Gothic Medium"]Script: AutoIT v3.1.1.124 (beta)[/font][font="Franklin Gothic Medium"]OS: Windows XP/2000[/font]
Link to comment
Share on other sites

I prefer single-click, and usually do something like this...

; example single-click to toggle main window
#include <Constants.au3>
AutoItSetOption("TrayMenuMode", 9)
AutoItSetOption("TrayOnEventMode", 1)

; left-click to show/hide the main window.
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "Toggle")

TraySetClick(8) ; right-click to bring up the menu
TraySetState() ; show the tray menu
TraySetToolTip ("left-click to toggle the main window")

TrayCreateItem("Quit")
TrayItemSetOnEvent(-1,"Quit")

$me = "example"
$gui = GUICreate($me, 300, 300,)
GUISetState()
$quit = 0

while $quit = 0
wend

func Quit()
    $quit = 1
endfunc

func Toggle()
    $winstate = WinGetState($gui)
    if BitAnd($winstate, 2) then
        GUISetState(@SW_HIDE)
    else
        GUISetState(@SW_SHOW)
    endif
endfunc

-mu

ps. I left in the extra "," after the width declaration because I have a running theme going (which no one will spot unless I mention it) of typos that still work. hahah

Link to comment
Share on other sites

Hi Chris,

When running the above code..I am getting the variable used before declaration error

C:\Scraps\test1.au3(8,37) : WARNING: $TRAY_EVENT_PRIMARYUP: possibly used before declaration.

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Scraps\test1.au3(8,37) : ERROR: $TRAY_EVENT_PRIMARYUP: undeclared global variable.

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Using BETA version..

cheers,

Which beta?

The $tray_event_primaryup is declared int he constsnts.au3 file so did you leave the include constants.au3 at the top?

If not you could replace it with

TraySetOnEvent(-8,"SpecialEvent") and leave out the constants file

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