Sign in to follow this  
Followers 0
AlmarM

IniWrite() IniRead()

5 posts in this topic

Hello,

I want my script to create an .ini and read it the next time its started. But the IniWrite() command doenst work.

#include <GUIConstantsEx.au3> ;GUIConstants.au3
#include <EditConstants.au3>

$GUI = GUICreate("PeppermintMS AutoStarter", 260, 130, -1, -1)
$WorldInput = GUICtrlCreateInput("Path to 'lauch_world' here!", 10, 10, 200, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$WorldButton = GUICtrlCreateButton("...", 220, 7, 30)
$LoginInput = GUICtrlCreateInput("Path to 'lauch_login' here!", 10, 40, 200, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$LoginButton = GUICtrlCreateButton("...", 220, 37, 30)
$ChannelInput = GUICtrlCreateInput("Path to 'launch_channel' here!", 10, 70, 200, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$ChannelButton = GUICtrlCreateButton("...", 220, 67, 30)
$Launch = GUICtrlCreateButton("Start Server!", 10, 97, 240)


GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = -3 ;$GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $WorldButton
        $launch_world = FileOpenDialog("Choose 'launch_world'!", @DesktopCommonDir, "Bat Files (*.bat)")
        GUICtrlSetData($WorldInput, $launch_world)
    Case $nMsg = $LoginButton
        $launch_login = FileOpenDialog("Choose 'launch_login'!", @DesktopCommonDir, "Bat Files (*.bat)")
        GUICtrlSetData($LoginInput, $launch_login)
    Case $nMsg = $ChannelButton
        $launch_channel = FileOpenDialog("Choose 'launch_channel'!", @DesktopCommonDir, "Bat Files (*.bat)")
        GUICtrlSetData($ChannelInput, $launch_channel)
    Case $nMsg = $Launch
        $Read_World = GUICtrlRead($WorldInput)
        $Read_Login = GUICtrlRead($LoginInput)
        $Read_Channel = GUICtrlRead($ChannelInput)
        IniWrite("C:\temp\Path.ini", "Paths", "World", $Read_World)
        IniWriteSection("C:\temp\Path.ini", "Paths", $Read_Login)
        IniWriteSection("C:\temp\Path.ini", "Paths", $Read_Channel)
    EndSelect
WEnd

Could someone help me?

-AlmarM-


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites



Is this what you want?

#include <GUIConstantsEx.au3> ;GUIConstants.au3
#include <EditConstants.au3>

$GUI = GUICreate("PeppermintMS AutoStarter", 260, 130, -1, -1)
$WorldInput = GUICtrlCreateInput("Path to 'launch_world' here!", 10, 10, 200, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$WorldButton = GUICtrlCreateButton("...", 220, 7, 30)
$LoginInput = GUICtrlCreateInput("Path to 'lauch_login' here!", 10, 40, 200, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$LoginButton = GUICtrlCreateButton("...", 220, 37, 30)
$ChannelInput = GUICtrlCreateInput("Path to 'launch_channel' here!", 10, 70, 200, 20, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$ChannelButton = GUICtrlCreateButton("...", 220, 67, 30)
$Launch = GUICtrlCreateButton("Start Server!", 10, 97, 240)


GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = -3 ;$GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $WorldButton
        $launch_world = FileOpenDialog("Choose 'launch_world'!", @DesktopCommonDir, "Bat Files (*.bat)")
        GUICtrlSetData($WorldInput, $launch_world)
    Case $nMsg = $LoginButton
        $launch_login = FileOpenDialog("Choose 'launch_login'!", @DesktopCommonDir, "Bat Files (*.bat)")
        GUICtrlSetData($LoginInput, $launch_login)
    Case $nMsg = $ChannelButton
        $launch_channel = FileOpenDialog("Choose 'launch_channel'!", @DesktopCommonDir, "Bat Files (*.bat)")
        GUICtrlSetData($ChannelInput, $launch_channel)
    Case $nMsg = $Launch
        $Read_World = GUICtrlRead($WorldInput)
        $Read_Login = GUICtrlRead($LoginInput)
        $Read_Channel = GUICtrlRead($ChannelInput)
        IniWrite("C:\temp\Path.ini", "Paths", "World", $Read_World)
        IniWrite("C:\temp\Path.ini", "Paths", "Login", $Read_Login)
        IniWrite("C:\temp\Path.ini", "Paths", "Channel", $Read_Channel)
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Yes, thank you. But I want that if the program is started again, it reads the Path.ini and sets the input datas to the readed paths.

-AlmarM-


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Look at ...

IniRead ( "filename", "section", "key", "default" )
GUICtrlSetData ( controlID, data [, default] )

... in helpfile.

Share this post


Link to post
Share on other sites

Oh!

Tottaly forgot that!

Thanks you :)

-AlmarM-


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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