Krikov Posted January 26, 2008 Share Posted January 26, 2008 Hello, I Want to Read An ini file With The iniread Function and That any of Key under Each Section will Converted to Varaiable so i can Call it to run Somthing Just like id write $Var = "File Path" is that posibale ? Krikov [topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic] Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 Sure.... I think Maybe you could try to explain what you really want to do or maybe show some code you have tried already ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Dampe Posted January 26, 2008 Share Posted January 26, 2008 (edited) I think he wants to set a variable to an ini value $Var = IniRead ( "Filename", "Section", "key", "default" ) ;and just to test MsgBox (0, "Testing value", "The value read from the ini was " & $Var & ".") Edited January 26, 2008 by Dampe Link to comment Share on other sites More sharing options...
Krikov Posted January 26, 2008 Author Share Posted January 26, 2008 i am try to write an Generic Tray Menu By Read an ini file #Include <Constants.au3> #include <Array.Au3> #NoTrayIcon $INIFile = "Menu.ini" IF FileExists($INIFile) <> 1 Then MsgBox(0,"KQM Error","Unable to find MENU.INI File") Exit EndIf Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $FirstClass = IniReadSectionNames($INIFile) For $X = 1 to $FirstClass[0] $MenuX = TrayCreateMenu($FirstClass[$X]) $SecundCalss = IniReadSection($INIFile,$FirstClass[$X]) For $Y = 1 to $SecundCalss[0][0] TrayCreateItem('"'&$SecundCalss[$Y][0]&'"',$FirstClass[$X]) Next Next $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $exititem ExitLoop EndSelect WEnd Exit Krikov [topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic] Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 (edited) posting the content of Menu.ini would help to be able to "play" with your code Edited January 26, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Krikov Posted January 26, 2008 Author Share Posted January 26, 2008 This is the Menu.ini File Content [Utils] Util1 = Util2 = [Test] Test1 = Test2 = Test3 = [Help] Help1 = Help2 = Help3 = [Document] File1 = File2 = File3 = [topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic] Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 You need to use the returned handles when creating the MenuItems... something like this: #include <Constants.au3> #include <Array.Au3> #NoTrayIcon $INIFile = "Menu.ini" If FileExists($INIFile) <> 1 Then MsgBox(0, "KQM Error", "Unable to find MENU.INI File") Exit EndIf Opt("TrayMenuMode", 1); Default tray menu items (Script Paused/Exit) will not be shown. $FirstClass = IniReadSectionNames($INIFile) Dim $Menu[$FirstClass[0]+1] For $X = 1 To $FirstClass[0] $Menu[$X] = TrayCreateMenu($FirstClass[$X]) $SecundCalss = IniReadSection($INIFile, $FirstClass[$X]) For $Y = 1 To $SecundCalss[0][0] TrayCreateItem($SecundCalss[$Y][0], $Menu[$X]) Next Next $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $exititem ExitLoop EndSelect WEnd Exit SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Krikov Posted January 26, 2008 Author Share Posted January 26, 2008 (edited) Thanks Jos but can you give me an example for that Krikov Edited January 26, 2008 by Krikov [topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic] Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 Thanks Jos but can you give me an example for that KrikovNot sure what you are asking me other than what I already posted ... could you explain ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Krikov Posted January 26, 2008 Author Share Posted January 26, 2008 i notice that this is the main line Dim $Menu[$FirstClass[0]+1] but how can i get the value if the selection Krikov [topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic] Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2008 Developers Share Posted January 26, 2008 (edited) Maybe this script gives you an idea how to continue development. I changed the INI to: [Utils] Util1 = util1 Util2 = util2 [Test] Test1 = test1 Test2 = test2 Test3 = test3 [Help] Help1 = help1 Help2 = help2 Help3 = help3 [Document] File1 = file1 File2 = file2 File3 = file3 Run this code from SciTE and it will display your selection in the outputpane: #include <Constants.au3> #include <Array.Au3> #NoTrayIcon $INIFile = "Menu.ini" If FileExists($INIFile) <> 1 Then MsgBox(0, "KQM Error", "Unable to find MENU.INI File") Exit EndIf Opt("TrayMenuMode", 1); Default tray menu items (Script Paused/Exit) will not be shown. $FirstClass = IniReadSectionNames($INIFile) Dim $Menu[$FirstClass[0]+1] Dim $MenuItems[200] For $X = 1 To $FirstClass[0] $Menu[$X] = TrayCreateMenu($FirstClass[$X]) $SecundCalss = IniReadSection($INIFile, $FirstClass[$X]) For $Y = 1 To $SecundCalss[0][0] $MenuItems[TrayCreateItem($SecundCalss[$Y][0], $Menu[$X])] = $SecundCalss[$Y][1] Next Next $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg < 1 ContinueLoop Case $msg = $exititem ExitLoop Case Else ConsoleWrite("Option Selected:" & $MenuItems[$msg] & @CRLF) EndSelect WEnd Exit Jos Edited January 26, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now