ChrisL 13 Posted May 23, 2006 (edited) minimise a gui to the system tray Edit~: Updated to support newer versions of Autoit, thanks to Zedna too I've used some of your suggestions expandcollapse popup#NoTrayIcon #include <GuiConstants.au3> #include <Constants.au3> Opt("GUIEventOptions",1) Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent") $gui = GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_MINIMIZE GuiSetState(@SW_MINIMIZE) GuiSetState(@SW_HIDE) TraySetState(1) ; show If @OSVersion = "WIN_NT4" or @OSVersion = "WIN_ME" or @OSVersion = "WIN_98" or @OSVersion = "WIN_95" then TraySetToolTip ("My app - click here to restore") Else Traytip ("My App", "click here to restore", 5) EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func SpecialEvent() GuiSetState(@SW_RESTORE) GuiSetState(@SW_Show) TraySetState(2) ; hide EndFunc Edited July 17, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Share this post Link to post Share on other sites
Pakku 0 Posted May 23, 2006 Hi ChrisL, nice idee i can use this in one of my scripts! thanks Arjan How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me Share this post Link to post Share on other sites
RazerM 0 Posted May 23, 2006 simple yet effective. Nice My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Share this post Link to post Share on other sites
iceberg 1 Posted September 22, 2006 hi ChrisL, thanks alot for the codes. but can i check with you something....what if i am using "Switch...Case...EndSwitch"? I tried to play around with the codes for half an hr. i cdn't figure it out. pls help me. thanks. mouse not found....scroll any mouse to continue. Share this post Link to post Share on other sites
SmOke_N 210 Posted September 22, 2006 (edited) hi ChrisL, thanks alot for the codes. but can i check with you something....what if i am using "Switch...Case...EndSwitch"? I tried to play around with the codes for half an hr. i cdn't figure it out. pls help me. thanks.I'd like to see what you "tried" if you couldn't get it to work.#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 Switch GUIGetMsg() Case $GUI_EVENT_MINIMIZE GuiSetState(@SW_HIDE) Opt("TrayIconHide", 0) Traytip ("My App", "Click the Icon not the Tool Tip To Restore", 5) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func SpecialEvent() GuiSetState(@SW_Show) Opt("TrayIconHide", 1) EndFuncEdit: (Forgot to paste my code) Edited September 22, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Share this post Link to post Share on other sites
iceberg 1 Posted September 22, 2006 thanks SmOke_N, well one of the scripts i got from the forum was using "Switch...Case...EndSwitch" method. And the other portion of the script i made was with "Select...Case...EndSelect" method. I didn't knew how to combine both of them. I even tried having 2 "whiles". obviously tat didn't work. mouse not found....scroll any mouse to continue. Share this post Link to post Share on other sites
iceberg 1 Posted September 22, 2006 this was the code taken off the forum While 1 Sleep(0) $recv = TCPRecv($sock, 2048) If not $recv Then ContinueLoop $recv = StringSplit($recv, Chr(1)) For $i = 1 to $recv[0] $temp = StringSplit($recv[$i], Chr(2)) Switch $temp[1] Case "rejected" mError("Too many users in chat room.", 1) Case "accepted" ; nothing Case "adduser" _AddUser($temp[2]) Case "deluser" _DelUser($temp[2]) Case "exit" mError("Server has closed.", 1) Case Else If $recv[$i] Then GUICtrlSetData($edit, $recv[$i] & @CRLF, 1) EndSwitch Next _ReduceMemory() WEnd my code was While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "", "Dialog was closed") Exit Case $msg = $GUI_EVENT_MINIMIZE MsgBox(0,"", "Dialog minimized",2) Case $msg = $GUI_EVENT_MAXIMIZE MsgBox(0,"", "Dialog restored",2) Case $msg = $button_1 MsgBox(0, "Default button clicked", "Radio " & $radioval1 ) Case $msg >= $radio_1 AND $msg <= $radio_3 $radioval1 = $msg - $radio_1 EndSelect WEnd so tats where i got blurred. mouse not found....scroll any mouse to continue. Share this post Link to post Share on other sites
Zedna 276 Posted September 22, 2006 (edited) minimise a gui to the system tray Thanks for very nice and simple code I made little changes: 1) #NoTrayIcon - to avoid initial flash of tray 2) hide tray after start of application 3) use TraySetState(2) ; hide and TraySetState(1) ; show instead of Opt("TrayIconHide", 0/1) 4) use TraySetToolTip instead of TrayTip --> to work also on WIN98 #NoTrayIcon #include <GuiConstants.au3> #include <Constants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent") ;TraySetState(2) ; hide --> not needed 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) TraySetState(1) ; show TraySetToolTip ("My app - click here to restore") Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func SpecialEvent() GuiSetState(@SW_Show) TraySetState(2) ; hide EndFunc Edited September 22, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Share this post Link to post Share on other sites
iceberg 1 Posted September 23, 2006 thanks Zedna! mouse not found....scroll any mouse to continue. Share this post Link to post Share on other sites
jftuga 1 Posted September 23, 2006 Nice script, I like it! -John Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Share this post Link to post Share on other sites
slayerz 0 Posted May 16, 2008 Nice and simple script, thanks for sharing AUTOIT[sup] I'm lovin' it![/sup] Share this post Link to post Share on other sites
BinaryCortex 0 Posted February 22, 2010 This script is not working for me. C:\Users\NameDeleted\Desktop\tray.au3 (12) : ==> Variable used without being declared.: $gui = GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $gui = GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR(^ ERROR What are these supposed to be set to? Share this post Link to post Share on other sites
Melba23 3,404 Posted February 22, 2010 BinaryCortex, It is a very old script and the includes have changed a lot since it was written. Put these in place of the includes currently used: #include <GuiConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Share this post Link to post Share on other sites
grimmlock 1 Posted December 5, 2012 Yes that works Thank you!!! ThanksGrimm Share this post Link to post Share on other sites