Jump to content

IniWrite and FileOpenDialog bug


nuki
 Share

Recommended Posts

hey guys, in a script im working on i want to read out a filepath through the FileOpenDialog function and put the result into a input. later when a button is pressed the data in the input should be saved in a ini file with IniWrite and here comes the problem, the IniWrite doesnt work if i used the FileOpenDialog to get the path, if i type it manually its no problem...

Example code for my problem that everyone can try:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 241, 93, 193, 125)
$Input1 = GUICtrlCreateInput("", 8, 16, 113, 21)
$Button1 = GUICtrlCreateButton("Browse", 136, 16, 73, 25, 0)
$Button2 = GUICtrlCreateButton("Save to ini", 80, 56, 81, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $Button1 Then
        $dialog = FileOpenDialog("open","C:\","All (*.*)",3,"",$Form1)
        GUICtrlSetData($Input1,$dialog)
    EndIf
    
    If $msg = $Button2 Then
        $read = GUICtrlRead($Input1)
        IniWrite("test.ini","test","path",$read)
        Exit
    EndIf
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    
    Sleep(5)
WEnd

Would be cool if someone would know a solution

Link to comment
Share on other sites

hey guys, in a script im working on i want to read out a filepath through the FileOpenDialog function and put the result into a input. later when a button is pressed the data in the input should be saved in a ini file with IniWrite and here comes the problem, the IniWrite doesnt work if i used the FileOpenDialog to get the path, if i type it manually its no problem...

Example code for my problem that everyone can try:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 241, 93, 193, 125)
$Input1 = GUICtrlCreateInput("", 8, 16, 113, 21)
$Button1 = GUICtrlCreateButton("Browse", 136, 16, 73, 25, 0)
$Button2 = GUICtrlCreateButton("Save to ini", 80, 56, 81, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $Button1 Then
        $dialog = FileOpenDialog("open","C:\","All (*.*)",3,"",$Form1)
        GUICtrlSetData($Input1,$dialog)
    EndIf
    
    If $msg = $Button2 Then
        $read = GUICtrlRead($Input1)
        IniWrite("test.ini","test","path",$read)
        Exit
    EndIf
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    
    Sleep(5)
WEnd

Would be cool if someone would know a solution

Works fine for me:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 241, 93, 193, 125)
$Input1 = GUICtrlCreateInput("", 8, 16, 113, 21)
$Button1 = GUICtrlCreateButton("Browse", 136, 16, 73, 25, 0)
$Button2 = GUICtrlCreateButton("Save to ini", 80, 56, 81, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $Button1 Then
        $dialog = FileOpenDialog("open","C:\","All (*.*)",3,"",$Form1)
        If @error Then ContinueLoop
        GUICtrlSetData($Input1,$dialog)
    EndIf
    
    If $msg = $Button2 Then
        $read = GUICtrlRead($Input1)
        IniWrite(@ScriptDir & "\test.ini","test","path",$read)
        Exit
    EndIf
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
WEnd
Link to comment
Share on other sites

so is it a problem of my system or what :S

because if i didnt start this example program before and put in the path manually without the fileopendialog browser it doesnt even create the ini file because it writes nothing... :D if the ini was created manually it doesnt change or add something too... just nothing happens if i use the dialog.

edit: i compile the test script now and run it on my both other machines.... brb

edit2: same result on my other pcs, nothing happens (not even ini file creation) if i use the dialog browser... and one of the systems just got installed a fresh copy of win xp sp2 nothing else installed on it yet

edit3: im sorry i didnt see the change in your quote -.- ;) its working now thanks alot (even if its still wondering me because its right syntax ;))

Edited by nuki
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...