Jump to content

Fileopendialog + Iniwrite Bug?


Recommended Posts

Hello all!

I'm brand new to this AutoIt thingie, and it looks really amazing!

I'm developing an interface to a commandline program, and I've been facing a few problems.

One I couldn't solve, is a weird behaviour I'm witnessing here:

I want to save options to an ini file, and one option is a path to a program executable.

Here is a code example:

#include <GuiConstants.au3>

$GUI_Handle = GuiCreate("MyGUI", 400, 400,(@DesktopWidth-400)/2, (@DesktopHeight-400)/2)

$Button_1 = GuiCtrlCreateButton("Browse", 230, 50, 130, 40)
GUICtrlSetFont(-1,12,700,0,"Tahoma")
$Input_2 = GuiCtrlCreateInput("c:\file", 30, 50, 190, 40)
GUICtrlSetFont(-1,16,400,0,"Tahoma")
$Button_3 = GuiCtrlCreateButton("Save", 230, 130, 130, 40)
GUICtrlSetFont(-1,12,700,0,"Tahoma")

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $Button_1
        GUICtrlSetData ( $Input_2, FileOpenDialog ( "Select file", "","All (*.*)", 1 ) )
    Case $msg = $Button_3
        IniWrite ( "inifile.ini", "option", "file", GUICtrlRead ( $Input_2 ) )
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd

Now, if I just press the Save button, an ini file is saved with the contents of the Input widget, as expected.

BUT, if I press the Browse button to select a file, then press the Save button, nothing is written to the ini file.

I can confirm the problem is with the IniWrite command, since if you add other instructions they are carried out fine.

I noticed that whenever the FileOpenDialog is used, IniWrite commands fail to work, but only if I ever select to open a file. Pressing cancel doesn't trigger the bug. But once a file is selected to open, the bug is triggered and saving does not works anymore at all.

Can anyone confirm this? Is it a bug on AutoIt or a coding error on my side?

I'm running AutoIt v.3.1.1.0 on WinXP SP1.

Thanks for any help.

Edited by LKRaider
Link to comment
Share on other sites

@ScriptDir !!

Hah, my hero! :think:

I see now, it saves the ini file to wherever I selected a file in FileOpenDialog !

Thanks for the help

A quick question:

Is there another way to execute commandline programs, other than using:

@ComSpec & " /c " & "command"
?

What I want is, for example, run more commands one after another, like in a batch file. Or is best I make a batch and run it then?

Link to comment
Share on other sites

@ScriptDir !!

Hah, my hero! :think:

I see now, it saves the ini file to wherever I selected a file in FileOpenDialog !

Thanks for the help

A quick question:

Is there another way to execute commandline programs, other than using:

@ComSpec & " /c " & "command"
?

What I want is, for example, run more commands one after another, like in a batch file. Or is best I make a batch and run it then?

could you not write each command to a ini or txt file then read that file in as an array or something like that and say for 1 to whatever do each line ?

edit - or just add each command direct to an array ?

Edited by craig.gill
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...