Sign in to follow this  
Followers 0
Krikov

have an idea

11 posts in this topic

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]

Share this post


Link to post
Share on other sites



Sure.... I think :D

Maybe you could try to explain what you really want to do or maybe show some code you have tried already ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Dampe

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

posting the content of Menu.ini would help to be able to "play" with your code :D

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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

:D


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks Jos but can you give me an example for that

Krikov

Edited by Krikov

[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Share this post


Link to post
Share on other sites

Thanks Jos but can you give me an example for that

Krikov

Not sure what you are asking me other than what I already posted ... could you explain ?

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

#11 ·  Posted (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 :D

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


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
Sign in to follow this  
Followers 0