Jump to content
Sign in to follow this  
au3scr

IniReadSection [I have searched help file]

Recommended Posts

au3scr

Can someone help me here?

I need to list ini items on edit.I know how to do it with msgbox but I have no idea how to list these items in edit.

With msgbox it works that way.

$var = IniReadSection("install.ini","install")

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

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

Next

but same thing dont work with edit.

$var = IniReadSection("install.ini","install")

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

$ProgramName = $var[$i][1]

Next

As yu can see both of them have $var[$i][1], in msg box it works, but with edit it dont work

here is my program,You must have install.ini in your script directory.

#include <GUIConstants.au3>
#include <misc.au3>
#include <GUIEdit.au3>
#include <string.au3>

;~ $var = IniReadSection("install.ini","install")

;~     For $i = 1 To $var[0][0]
;~         MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
;~     Next



global $currentprogram = ""
Global $ishide = IniRead(@ScriptDir&"\install.ini","general","HideGUI","def")


$Form1 = GUICreate("Apt-get", 640, 480, 201, 116, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
$MenuItem1 = GUICtrlCreateMenu("General")
$MenuItem11 = GUICtrlCreateMenuItem("Copy text", $MenuItem1)
$MenuItem12 = GUICtrlCreateMenuItem("Save text", $MenuItem1)
$MenuItem13 = GUICtrlCreateMenuItem("Fullscreen", $MenuItem1)
$MenuItem14 = GUICtrlCreateMenuItem("Hide", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("Help")
$MenuItem21 = GUICtrlCreateMenuItem("About", $MenuItem2)
$MenuItem22 = GUICtrlCreateMenuItem("Install.ini Commands", $MenuItem2)
Global $output = GUICtrlCreateedit ("",3,0,638,460,$ES_NOHIDESEL)
WinActivate ("Apt-get")
Send("dfsd")
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xC0C0C0)
GUICtrlSetFont(-1, 10, 500, 0,"terminal")
GUICtrlSetData ($output,"Welcome to installer, made by Rain"&@crlf&'To see avaible commands click on help menu and then click on "Install.ini Commands"')
$admin = IsAdmin ()
If $admin = 0 Then
$oldoutput = GUICtrlRead($output)
GUICtrlSetData($output,$oldoutput&@CRLF&"Sorry, you DO NOT have permission to install any programm, please exit now")
EndIf
_getlist ()
    
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Exit
    Case $MenuItem11
        $textcopy = GUICtrlRead ($output)
        ClipPut ($textcopy)
    Case $MenuItem13
        WinMove("Apt-get","",0,0,@DesktopWidth,@DesktopHeight)
    case $MenuItem21
        msgbox (48,"Help","No help avaible yet")
    case $MenuItem21
        msgbox (48,"Commands","No any commands yet")
    case $MenuItem14
        $ishide = 1
        GUISetState(@SW_HIDE)
EndSwitch
    WEnd

Func _getlist ()
    $ProgramsToInstall = 0
    $var = IniReadSection("install.ini","install")

    For $i = 1 To $var[0][0]
;~         MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
    $ProgramName = $var[$i][1]
    $ProgramsToInstall =    $ProgramsToInstall +1
    Next
;~  $ProgramName = "Firefox"
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&"Number programs selected for instalation:"&$ProgramsToInstall)
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&$ProgramName)
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&"Starting instalation")
;~  _firefoxask ()
EndFunc 

func _firefoxask ()
    If $ishide = 1 Then
        _firefox ()
    Else
        If $ishide = 0 Then
    $currentprogram = "Firefox"
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&"Do you want install firefox? (If you answer no, it will be skipped) [yes;no]"&@crlf)   
HotKeySet("{enter}","_check")
EndIf
EndIf
EndFunc 
    
Func _firefox ()
FileDelete("firefox.htm")
FileDelete("firefox.exe")

InetGet("http://www.mozilla.com/en-US/firefox/", "firefox.htm", 1, 1)

While @InetGetActive
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&" "&@CRLF&" "&@CRLF&"Dedecting lastest version")
  Sleep(550)
Wend

$version = FileReadLine (@scriptdir&"\firefox.htm",98)
$count=StringLeft($version,75)
$count2=Stringright($count,8)
$oldoutput = GUICtrlRead($output)
GUICtrlSetData($output,$oldoutput&@CRLF&"Dedcted "&$count2)
InetGet("ftp://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest/win32/en-US/Firefox Setup "&$count2&".exe", "firefox.exe", 1, 1)

  $oldoutput = GUICtrlRead($output)   
While @InetGetActive
  $bytes = @InetGetBytesRead
  $size = $bytes&"B"
   If $bytes > 1024 Then
  $bytes = $bytes / 1024
  $rounded = round($bytes, -0)
  $size = $rounded&"KB"
  If $rounded > 1024 Then
  $rounded = $rounded / 1024
  $mb = Round ($rounded,1)
  $size = $mb&"MB"
  EndIf
  EndIf
  GUICtrlSetData($output,$oldoutput&@CRLF&"Downloading firefox "&$count2&" "&$size&" Is downloaded")
  Sleep(250)
  If $ishide = 0 Then
  GUISetState(@SW_SHOW)
  EndIf
    Wend
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&"Downloading firefox "&$count2&" complete,Installing firefox"&$count2)
    ShellExecute("firefox.exe","-ms")
  EndFunc


func _check ()

    $line = _GUICtrlEdit_GetLineCount ($output) - 1
    $Input=_GUICtrlEdit_GetLine($output,$line)
    $command = StringTrimLeft ($Input,0)
    If $command = "no" Then
        $oldoutput = GUICtrlRead($output)
        GUICtrlSetData($output,$oldoutput&@CRLF&$currentprogram&" skipped")
        Else
    If $command = "yes" Then
        $oldoutput = GUICtrlRead($output)
        GUICtrlSetData($output,$oldoutput&@CRLF&"Will now install "&$currentprogram)
    EndIf   
EndIf
_firefox ()
EndFunc

And here is my ini

You need to save it with name install.ini in same directory where you saved that sctipt

[general]
HideGUI=0

[install]
install1=firefox
install2=thunderbird

Share this post


Link to post
Share on other sites
martin

Can someone help me here?

I need to list ini items on edit.I know how to do it with msgbox but I have no idea how to list these items in edit.

With msgbox it works that way.

$var = IniReadSection("install.ini","install")

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

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

Next

but same thing dont work with edit.

$var = IniReadSection("install.ini","install")

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

$ProgramName = $var[$i][1]

Next

As yu can see both of them have $var[$i][1], in msg box it works, but with edit it dont work

here is my program,You must have install.ini in your script directory.

#include <GUIConstants.au3>
#include <misc.au3>
#include <GUIEdit.au3>
#include <string.au3>

;~ $var = IniReadSection("install.ini","install")

;~     For $i = 1 To $var[0][0]
;~         MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
;~     Next



global $currentprogram = ""
Global $ishide = IniRead(@ScriptDir&"\install.ini","general","HideGUI","def")


$Form1 = GUICreate("Apt-get", 640, 480, 201, 116, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
$MenuItem1 = GUICtrlCreateMenu("General")
$MenuItem11 = GUICtrlCreateMenuItem("Copy text", $MenuItem1)
$MenuItem12 = GUICtrlCreateMenuItem("Save text", $MenuItem1)
$MenuItem13 = GUICtrlCreateMenuItem("Fullscreen", $MenuItem1)
$MenuItem14 = GUICtrlCreateMenuItem("Hide", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("Help")
$MenuItem21 = GUICtrlCreateMenuItem("About", $MenuItem2)
$MenuItem22 = GUICtrlCreateMenuItem("Install.ini Commands", $MenuItem2)
Global $output = GUICtrlCreateedit ("",3,0,638,460,$ES_NOHIDESEL)
WinActivate ("Apt-get")
Send("dfsd")
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1,0xC0C0C0)
GUICtrlSetFont(-1, 10, 500, 0,"terminal")
GUICtrlSetData ($output,"Welcome to installer, made by Rain"&@crlf&'To see avaible commands click on help menu and then click on "Install.ini Commands"')
$admin = IsAdmin ()
If $admin = 0 Then
$oldoutput = GUICtrlRead($output)
GUICtrlSetData($output,$oldoutput&@CRLF&"Sorry, you DO NOT have permission to install any programm, please exit now")
EndIf
_getlist ()
    
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Exit
    Case $MenuItem11
        $textcopy = GUICtrlRead ($output)
        ClipPut ($textcopy)
    Case $MenuItem13
        WinMove("Apt-get","",0,0,@DesktopWidth,@DesktopHeight)
    case $MenuItem21
        msgbox (48,"Help","No help avaible yet")
    case $MenuItem21
        msgbox (48,"Commands","No any commands yet")
    case $MenuItem14
        $ishide = 1
        GUISetState(@SW_HIDE)
EndSwitch
    WEnd

Func _getlist ()
    $ProgramsToInstall = 0
    $var = IniReadSection("install.ini","install")

    For $i = 1 To $var[0][0]
;~         MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
    $ProgramName = $var[$i][1]
    $ProgramsToInstall =    $ProgramsToInstall +1
    Next
;~  $ProgramName = "Firefox"
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&"Number programs selected for instalation:"&$ProgramsToInstall)
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&$ProgramName)
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&"Starting instalation")
;~  _firefoxask ()
EndFunc 

func _firefoxask ()
    If $ishide = 1 Then
        _firefox ()
    Else
        If $ishide = 0 Then
    $currentprogram = "Firefox"
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&"Do you want install firefox? (If you answer no, it will be skipped) [yes;no]"&@crlf)   
HotKeySet("{enter}","_check")
EndIf
EndIf
EndFunc 
    
Func _firefox ()
FileDelete("firefox.htm")
FileDelete("firefox.exe")

InetGet("http://www.mozilla.com/en-US/firefox/", "firefox.htm", 1, 1)

While @InetGetActive
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&" "&@CRLF&" "&@CRLF&" "&@CRLF&"Dedecting lastest version")
  Sleep(550)
Wend

$version = FileReadLine (@scriptdir&"\firefox.htm",98)
$count=StringLeft($version,75)
$count2=Stringright($count,8)
$oldoutput = GUICtrlRead($output)
GUICtrlSetData($output,$oldoutput&@CRLF&"Dedcted "&$count2)
InetGet("ftp://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest/win32/en-US/Firefox Setup "&$count2&".exe", "firefox.exe", 1, 1)

  $oldoutput = GUICtrlRead($output)   
While @InetGetActive
  $bytes = @InetGetBytesRead
  $size = $bytes&"B"
   If $bytes > 1024 Then
  $bytes = $bytes / 1024
  $rounded = round($bytes, -0)
  $size = $rounded&"KB"
  If $rounded > 1024 Then
  $rounded = $rounded / 1024
  $mb = Round ($rounded,1)
  $size = $mb&"MB"
  EndIf
  EndIf
  GUICtrlSetData($output,$oldoutput&@CRLF&"Downloading firefox "&$count2&" "&$size&" Is downloaded")
  Sleep(250)
  If $ishide = 0 Then
  GUISetState(@SW_SHOW)
  EndIf
    Wend
    $oldoutput = GUICtrlRead($output)
    GUICtrlSetData($output,$oldoutput&@CRLF&"Downloading firefox "&$count2&" complete,Installing firefox"&$count2)
    ShellExecute("firefox.exe","-ms")
  EndFunc


func _check ()

    $line = _GUICtrlEdit_GetLineCount ($output) - 1
    $Input=_GUICtrlEdit_GetLine($output,$line)
    $command = StringTrimLeft ($Input,0)
    If $command = "no" Then
        $oldoutput = GUICtrlRead($output)
        GUICtrlSetData($output,$oldoutput&@CRLF&$currentprogram&" skipped")
        Else
    If $command = "yes" Then
        $oldoutput = GUICtrlRead($output)
        GUICtrlSetData($output,$oldoutput&@CRLF&"Will now install "&$currentprogram)
    EndIf   
EndIf
_firefox ()
EndFunc

And here is my ini

You need to save it with name install.ini in same directory where you saved that sctipt

[general]
HideGUI=0

[install]
install1=firefox
install2=thunderbird
If you have

$programname = "one"
$programname = "two"

What will you get when you have

msgbox(0,"$programname = ",$programname)

?

Second question. Very important question. Make sure you are paying attention. Have you ever tried adding debugging code to your scripts like you have often been asked to?

If the answer is yes then why haven't you done it this time?

If the answer is no then I recommend that stop asking questions in these forums until you have tried adding debugging and worked out how to solve at least some your own problems. If you don't understand how to add any debugging code then there are plenty of people who can advise you but it is really shocking that you have the desire to write scripts but no obvious desire to put the necessary effort into understanding why things don't work. Everyone has their own capabilities but I simply don't believe that you can produce scripts but can't produce that bit of extra effort to work out how to fix them. Why on earth don't you learn to do that and then change your signature from "I am new and silly a bit" to "I am not so new and I understand more than I did yesterday". That would be much more positive and a lot more welcome.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Jos

..and:

Use SciTE as editor, make it possible to open the Helpfile on your pc and Hit F1 before posting anything.

Jos


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

Share this post


Link to post
Share on other sites
au3scr

I have read help file, but i didnt find answer.

There was example

$days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",")

;$days[1] contains "Sun" ... $days[7] contains "Sat"

$text = "This\nline\ncontains\nC-style breaks."

$array = StringSplit($text, '\n', 1)

but what i can do with it? i make msgbox (1,"",$array) then i get clear msg box, so i have no idea what to do.

..and:

Use SciTE as editor, make it possible to open the Helpfile on your pc and Hit F1 before posting anything.

Jos

Do you think that you are funny?You are just evil and you love looking how i cant do anything. Edited by au3scr

Share this post


Link to post
Share on other sites
SmOke_N

I have read help file, but i didnt find answer.

There was example

but what i can do with it? i make msgbox (1,"",$array) then i get clear msg box, so i have no idea what to do.

Do you think that you are funny?You are just evil and you love looking how i cant do anything.

We aren't looking at how you "can't" do anything, it's just a waste of time for us to have to hold your hand on every little thing.

Arrays are accessed by an index, in AutoIt it is by a [0] or [1] or [2] etc...

Simply doing a MsgBox(0, 0, $array) isn't going to return anything...

MsgBox(0, 0, $array[0]) may however.

You should have a basic understanding of how arrays/functions work before you attempt to use them, if you don't know, then again (Read the help file) or use google:

http://www.autoitscript.com/wiki/index.php?title=Arrays


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Jos

Do you think that you are funny?You are just evil and you love looking how i cant do anything.

If you think that Iam trying to be funny you totally missed the message. I am sure I have assisted you many time with answers to your questions and have also tried to guide you in the direction to were you can start answering your own questions. However, since you told me a couple of days ago that you cannot open the helpfile on your computer it is clear to me that you are not treating me and this forum serious thus am I ignoring you till you start treating us serious and show some interest in doing the biggest part of the work yourself.

-end of lecture-


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        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  

×