CEllsworth_white

Home   News   For Sale
Home You are here: Home News Computer Related Everything Else RunInTray
 

Who's Online

We have 1 guest online
 
   
RunInTray PDF Print E-mail
User Rating: / 1
PoorBest 
Written by CEllsworth   
Tuesday, 25 January 2011 21:14

zip-file-icon RunInTray.zip is a AutoIt Script designed to start a program and hide it in the system tray.  From there you can show or hide it either with the right click menu or by double clicking on the icon.

Run it using the following syntax:

 RunInTray.exe "c:\windows\system32\notepad.exe" "C:\documents and settings\user" "Notepad"

AutoIt Script Source:
if $CmdLine[0]  3 Then
    Msgbox(4096,"RunInTray","Syntax: " & @CRLF & @ScriptName & " ""C:\program.exe"" ""C:\"" ""Program Title""")
    Exit
EndIf


dim $my_Dir, $my_App, $my_Title
$my_App = $CmdLine[1]
$my_Dir = $CmdLine[2]
$my_Title = $CmdLine[3]



Run($my_App,$my_Dir)
WinWait($my_Title)

TraySetIcon($my_App)

Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu
Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown.

$hTray_Show_Item = TrayCreateItem("Hide")
TrayItemSetOnEvent(-1, "To_Tray")
TrayCreateItem("")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "On_Exit")
TraySetOnEvent(-13, "To_Tray")

To_Tray()

While 1
    Sleep(1000)
WEnd

Func On_Exit()
    WinKill($my_Title)
    Exit
EndFunc

Func To_Tray()

    If TrayItemGetText($hTray_Show_Item) = "Hide" Then
        WinSetState($my_Title, "", @SW_HIDE)
        TrayItemSetText($hTray_Show_Item, "Show")
    Else
        WinSetState($my_Title, "", @SW_SHOW)
        TrayItemSetText($hTray_Show_Item, "Hide")
    EndIf

EndFunc
comments
Last Updated on Friday, 09 December 2011 14:27
 
  Top