Jump to content

Create TrayMenu with INI file and get msg


 Share

Recommended Posts

1. I am trying to create a traymenu reading all the section names from an ini file.

2. Whatever trayitem that I click on, I need to go into the same ini file and read that ini section.

3. Also, I need to create a "refresh" item, which will delete all the current tray items, reread the ini file and recreate all the trayitems.

It would great if someone can provide a small example script.

Thanks.

Link to comment
Share on other sites

Done!! Just in case anyone needs this...

#Include <GUIConstants.au3>

#Include <Array.au3>

;#NoTrayIcon

Opt("TrayAutoPause",0)

Opt("TrayMenuMode",1)

Global $File="Sample.ini"

Dim $item[1]

Dim $Tray_Item[10]

$var = IniReadSectionNames($File)

$Tray_System = TrayCreateMenu("System")

If $var<>1 then

For $i = 1 To $var[0]

_ArrayAdd($item,$var[$i])

Next

EndIf

$Item_String=StringSplit(StringTrimLeft(_ArrayToString($item,"|"),1),"|")

For $x=1 to $Item_String[0]

$Tray_Item[$x]=TrayCreateItem($Item_String[$x],$Tray_System)

Next

$Exit = TrayCreateItem("Exit")

While 1

$msg = TrayGetMsg()

Select

Case $msg = $Exit

Exit

Case Else

For $x=1 to $Item_String[0]

If $msg = $Tray_Item[$x] then

;MsgBox(0,"",$Item_String[$x])

$var = IniReadSection($File,$Item_String[$x])

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 1 To $var[0][0]

MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])

Next

EndIf

EndIf

Next

EndSelect

WEnd

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