Sign in to follow this  
Followers 0
petrojelly

Minimize To System Tray

12 posts in this topic

Hi is it possible to minimize a window into system tray and restore it by double clicking on its tray icon ? Thanks for the help.

Share this post


Link to post
Share on other sites



Hi thanks for the link. But that thread doesn't seem to have what i need. The closest thing i can come up is to create a GUI without taskbar icon an minimize/restore the window with a hotkey.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

#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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

ChrisL, I wasn't referring to your code.

-mu

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