Jump to content

File link in system tray


Kent
 Share

Recommended Posts

Hello all, my first post.

I have read some of the attempts at documentation (which I must say are very easy to understand) and have been through the help files, but I am still lacking in trying to set my first really helpful script. What I need is a script that creates a system tray menu populated with links to executables on a shared drive folder. What it is going to be is a file that I push out to all of my users so that they can click on the system tray icon and with one more click, run a macro from a list of macros in a folder. This way, I can manage the contents of the folder and each day, the system tray list macro scans the folder for it's contents at startup to create the list dynamically.

Any suggestions, etc.

My current strategy is to make an array from the file names in the remote folder and pass that to the TrayCreateItem(), but to use that to link back to running the target executable is what is stopping me.

Thank you

Kent

Link to comment
Share on other sites

Look at examples in Autoit HelpFile at TrayCreateItem()

This is start point for you ...

#Include <Constants.au3>
#NoTrayIcon

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$prefsitem  = TrayCreateItem("Preferences")
TrayCreateItem("")
$aboutitem  = TrayCreateItem("About")
TrayCreateItem("")
$exititem   = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $prefsitem
            Msgbox(64, "Preferences:", "OS:" & @OSVersion)
        Case $msg = $aboutitem
            Msgbox(64, "about:", "AutoIt3-Tray-sample.")
        Case $msg = $exititem
            ExitLoop
    EndSelect
WEnd
Link to comment
Share on other sites

Look at examples in Autoit HelpFile at TrayCreateItem()

This is start point for you ...

Thanks,

I do have that part down and thank you . It is getting the item in the list to call it's corresponding executable in the shared folder that is killing me.

Just like in this code snip:

#Include <File.au3>

#Include <Array.au3>

#include <Process.au3>

#include <GUIConstants.au3>

$FileList=_FileListToArray(@DesktopDir)

$Form1 = GUICreate("AForm1", 516, 574, 192, 125)

$List1 = GUICtrlCreateList("", 48, 16, 401, 500, -1, $WS_EX_CLIENTEDGE)

GUISetState(@SW_SHOW)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

$ListCount=UBound($FileList)

$ItemNumber=0

do

GUICtrlSetData($list1,$FileList[$ItemNumber])

$ItemNumber=$ItemNumber+1

until $ItemNumber = $ListCount

while 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

I can get the files into a list whether it be a system tray menu or a pop-up box. It is making an action call the associated file from it's name to make it launch.

Link to comment
Share on other sites

OK, just to let you know what I have so far"

#Include <File.au3>
#Include <Array.au3>
#include <Process.au3>
#Include <Constants.au3>


Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown.

$FileList=_FileListToArray("C:\Program Files\") ;set to this folder just to test
If @Error=1 Then
 MsgBox (0,"","No Files\Folders Found.")
 Exit
EndIf


$ListCount=UBound($FileList)
$ItemNumber=0

 do
  TrayCreateItem($FileList[$ItemNumber])
  TrayCreateItem("")
  $ItemNumber=$ItemNumber+1
    until $ItemNumber = $ListCount
 
 TraySetState()
 
 While 1
 $msg = TrayGetMsg()
 Select
  Case $msg = 0
   ContinueLoop
  Case $msg = $FileList[1]
   Msgbox(64, "You got it!", "You got it!")
  ;Case $msg = $aboutitem
  ; Msgbox(64, "about:", "AutoIt3-Tray-sample.")
  ;Case $msg = $exititem
 case Else
   MsgBox(0,"Crap",$msg)
   ExitLoop
 EndSelect
WEnd

Exit
Link to comment
Share on other sites

#Include <File.au3>
#Include <Array.au3>
#include <Process.au3>
#Include <Constants.au3>

Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
Opt("TrayOnEventMode",1)

$FileList = _FileListToArray("C:\Program Files\") ;set to this folder just to test
If @error Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

Dim $ItemList[UBound($FileList)]
;~ $ItemList[0] = UBound($FileList) - 1

For $i = 1 to UBound($FileList) - 1
    $ItemList[$i] = TrayCreateItem($FileList[$i])
    TrayItemSetOnEvent(-1,'MyTrayEvent')
Next

TraySetState()

While 1
    Sleep(100)
WEnd

Func MyTrayEvent()
    For $i = 1 to UBound($ItemList) - 1
        If $ItemList[$i] = @TRAY_ID Then 
            MsgBox(0,'Info',$FileList[$i])
            ExitLoop
        EndIf
    Next
EndFunc

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