Jump to content

BETA, TrayMenu from ini file


Recommended Posts

Hi, this is my first post here but i visit this forum often more then four times a day,

i'm now at a point i don't see any other way then asking YOU to solve my problem.

Problem: i want to create a tray menu with the help of an ini file which includes the sectionnames which work like entries in the root menu and subcategories as key values. nearly everything works now but i can't assign the menu to events because they have all the same variable. would be nice if someone shows me a way to create variablenames just from any other input i make, for example a ini file some kind of dialog or tcp connections etc.

here my code:

#Include <Constants.au3>
#NoTrayIcon

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

$array_menu = IniReadSectionNames(@ScriptDir & "\menu.ini")
If @error Then 
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $array_menu[0]
        $array_created_menus    = TrayCreateMenu($array_menu[$i])
            
        $array_keys = IniReadSection(@ScriptDir & "\menu.ini", $array_menu[$i])
        For $u = 1 To $array_keys[0][0]
            $array_created_keys = TrayCreateItem($array_keys[$u][0],$array_created_menus)
        
    Next
EndIf

i trust in u people....

kind regards

JRSmile

EDIT: please move it to v3_beta_support ....

Edited by JRSmile
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to post
Share on other sites

Okay im not the guru when coding this stuff, but did my best, i think this should do what your asking for.. take a look:

Tray_stuff.au3

Ini File

[Menu1]MenuItem1 = 0

MenuItem2 = 0

[Menu2]

MenuItem1 = 0

MenuItem2 = 0

[Menu3]

MenuItem1 = 0

MenuItem2 = 0

[Menu4]

MenuItem1 = 0

MenuItem2 = 0

[Menu5]

MenuItem1 = 0

MenuItem2 = 0

Edited by Wb-FreeKill
Link to post
Share on other sites

Using the example of Wb-FreeKill I came out with this one.....

The Menu.ini file look like:

[TrayMenu]

Active = Item

Space1 =

Launch at Startup = Item

Interactive = Item

Verbose = Item

Space2 =

Destination = Menu

Set Destination... = MenuItem

View Destination... = MenuItem

Purge Destination... = MenuItem

Space3 =

Force Backup = Menu

Force Monthly... = MenuItem

Force Weekly... = MenuItem

Force Daily... = MenuItem

Force EveryTime... = MenuItem

Space4 =

View Timestamps... = Item

View Last Backup Log... = Item

Edit File List... = Item

Space5 =

Home Page... = Item

About... = Item

Help... = Item

Space6 =

Exit = Item

The above example will create this menu:

Edit post: Make the script smaller and worked faster by removing two for loop and adding IniRead.

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to post
Share on other sites

just do:

dim $array_created_menus[100]
dim $array_created_keys[100]

#Include <Constants.au3>
#NoTrayIcon

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

$array_menu = IniReadSectionNames(@ScriptDir & "\menu.ini")
If @error Then 
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $array_menu[0]
$array_created_menus[$i] = TrayCreateMenu($array_menu[$i])

$array_keys = IniReadSection(@ScriptDir & "\menu.ini", $array_menu[$i])
For $u = 1 To $array_keys[0][0]
$array_created_keys[$u] = TrayCreateItem($array_keys[$u][0],$array_created_menus)

Next
EndIf

this should do the job for your creation if you have more than 1 ini-section

the rest is up to you

Link to post
Share on other sites
  • 3 weeks later...

thank you so much guys ... it helped me a lot...

FYI: our whole firm now uses autoit as primary script language ;)

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...