Jump to content

IniWrite from FileOpenDialog info?


 Share

Recommended Posts

Can anyone tell me why I can't write the file path information to an .ini file retrieved from the FileOpenDialog?

When the test MsgBox pops up it shows the FileOpenDialog path ok.

It writes to the .ini if i manually type the file path in.

I've tried adding focus to the text field, and wrapping the FileOpenDialog() in a String() to make sure it's a string but it diddn't work.

$var = ""
$btn2 = GUICtrlCreateButton("find file", 470, 300, 120)
GUICtrlSetOnEvent($btn2, "FindFile")
Func FindFile()
$var = FileOpenDialog("Choose file...","C:","All (*.*)", 1 + 2)
GUICtrlSetState($DFpath, $GUI_FOCUS)
GUICtrlSetData($DFpath,$var)
;testing message
MsgBox(0, "wot tha...?","$var = " & $var)

IniWrite("settings.ini","config","DFpath", $var)

EndFunc

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

this works

#include "GUIConstants.au3"

Opt("GUIOnEventMode", 1)       ;0=disabled, 1=OnEvent mode enabled


GUICreate("MY GUI")
$var = ""
$btn2 = GUICtrlCreateButton("find file", 100, 230, 120)
GUICtrlSetOnEvent($btn2, "FindFile")

$btn3 = GUICtrlCreateButton("find ini", 100, 330, 120)
GUICtrlSetOnEvent($btn3, "Findini")


GUISetState()

while 1
    sleep(20)
wend

Func FindFile()
$var = FileOpenDialog("Choose file...","C:","All (*.*)", 1 + 2)
;GUICtrlSetState($DFpath, $GUI_FOCUS)
;GUICtrlSetData($DFpath,$var)
;testing message
MsgBox(0, "wot tha...?","$var = " & $var)

IniWrite(@ScriptDir & "\settings.ini","config","DFpath", $var)

EndFunc



Func Findini()
    MsgBox(0,"test read", (iniread(@ScriptDir & "\settings.ini","config","DFpath", "not found")))
EndFunc

8)

NEWHeader1.png

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...