Jump to content

Minimize To Tray


RagnaroktA
 Share

Recommended Posts

I'm trying to find a way to, upon minimizing a script with a gui, make a script minimize to the system tray instead of the taskbar so the script will truly run in the background. Has this been done? I searched and found nothing helpful... Thanks!

Edited by RagnaroktA
Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki
Link to comment
Share on other sites

First: This is not a general support forum. (Scripts and Scraps)

I'm trying to find a way to, upon minimizing a script with a gui, make a script minimize to the system tray instead of the taskbar so the script will truly run in the background. Has this been done? I searched and found nothing helpful... Thanks!

<{POST_SNAPBACK}>

If you use the Beta version, check in the helpfile: Tray functions.
Link to comment
Share on other sites

I'm trying to find a way to, upon minimizing a script with a gui, make a script minimize to the system tray instead of the taskbar so the script will truly run in the background. Has this been done? I searched and found nothing helpful... Thanks!

<{POST_SNAPBACK}>

Try that ;-)

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

;---------------------------------------------------------------------------

Global Const $W_EXIST = 0x01
Global Const $W_VISIBLE = 0x02
Global Const $W_ENABLE = 0x04
Global Const $W_ACTIVE = 0x08
Global Const $W_MINIMIZE = 0x10
Global Const $W_MAXIMIZE = 0x20

;---------------------------------------------------------------------------

func wndClose()
  exit
endfunc

func wndMinimize()
   guiSetState( @SW_HIDE, $gui )
endfunc

func wndRestore()
   guiSetState( @SW_RESTORE, $gui )
endfunc

func wndMaximize()
   guiSetState( @SW_MAXIMIZE, $gui )
endfunc

func trayLClick()
   dim $state

   $state = winGetState( $gui )
   if bitAnd( $state, $W_VISIBLE) = $W_VISIBLE then
      guiSetState( @SW_HIDE, $gui)
   else
      guiSetState( @SW_SHOW, $gui)
   endif
endfunc

func btn()
   trayTip("I'm a title ", "I'm the message", 4, 1)
   traySetState( @SW_TRAYFLASH )
   sleep(5000)
   trayTip("", "", 0)
   sleep( 1000 )
   trayTip("I'm a title", "I'm the message", 5, 2)
   sleep( 1000 )
   trayTip("I'm a title", "I'm the message", 5, 3)
   sleep (1000)
   trayTip("", "", 0)
   traySetState( @SW_TRAYNOFLASH )
endfunc

opt( "GUIOnEventMode", 1)
opt( "GUIEventCompatibilityMode", 1 )
opt( "TrayAutoPause", 0)
opt( "TrayOnEventMode", 1)

$flag = bitOr( $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)
$gui = guiCreate( "Hello World", 200, 200, 20, 20, $flag )

$btn = guiCtrlCreateButton( "bouton", 20, 20, 90, 30 )
guiCtrlSetOnEvent( -1, "btn" )

guiSetOnEvent( $GUI_EVENT_CLOSE, "wndClose" )
guiSetOnEvent( $GUI_EVENT_MINIMIZE, "wndMinimize" )
guiSetOnEvent( $GUI_EVENT_RESTORE, "wndRestore" )
guiSetOnEvent( $GUI_EVENT_MAXIMIZE, "wndMaximize" )

traySetClick( 16 )
traySetOnEvent( $TRAY_EVENT_PRIMARYUP, "trayLClick" )
;traySetOnEvent( $TRAY_EVENT_PRIMARYDOUBLE, "trayLClick" )

traySetToolTip( "Click Me !" )

guiSetState( @SW_HIDE )
while 1
   sleep( 5000 )
wend
Edited by JoeCool
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...