Jump to content

FileOpenDialog + IniWrite problem


Recommended Posts

During the creation of an application linker I came across this problem with my define function, GUI runs fine, and browse button will open the file Open Dialog like asked then clicking 'open' once you have slected the file you want insterts the file directory into the input. However pressing 'OK' then does not write the directory into the ini file, but if one doesn't use the browse button and types the directory manualy it works fine. I want the browse function to work could someone please help.

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

$applinkerwindow1 = GUICreate("Define Button 1", 300, 290)  ;Define button 1
GUICtrlCreateLabel("Enter Button Label", 20, 5)
$applinkerinput1 = GUICtrlCreateInput("", 20, 25, 260, 30)
GUICtrlCreateLabel("Enter .exe directory (must be exact)", 20, 85)
$applinkerinput2 = GUICtrlCreateInput("", 20, 105, 260, 30)
GUICtrlCreateLabel("Enter hotkey", 20, 155)
GUICtrlCreateLabel("Alt", 20, 175)
$applinkerinput3 = GUICtrlCreateInput("", 40, 172, 20, 20)
$applinkerbrowse1 = GUICtrlCreateButton("Browse", 220, 140, 50, 20)
GUICtrlSetOnEvent($applinkerbrowse1, "Browsebutton1")
$applinkerdefine1 = GUICtrlCreateButton("OK", 95, 215, 30, 20)
GUICtrlSetOnEvent($applinkerdefine1, "Defineapplinkerbutton1p2")
$applinkercancel1 = GUICtrlCreateButton("Cancel", 145, 215, 50, 20)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState(@SW_SHOW)

While 1
    Sleep(1)
WEnd

Func Browsebutton1()
    $browse1 = FileOpenDialog("open", "3", "Executables (*.exe)", 1)
    GUICtrlSetData($applinkerinput2, $browse1, "")
EndFunc

Func Defineapplinkerbutton1p2()
    IniWrite("Test.ini", "Applinkerlabels", "Label_1", GUICtrlRead($applinkerinput1))
    INIWrite("Test.ini", "Applinkerdirectories", "Directory_1", GUICtrlRead($applinkerinput2))
    IniWrite("Test.ini", "Applinkerhotkeys", "Hotkey_1", GUICTRLREAD($applinkerinput3))
    GUISetState(@SW_HIDE, $applinkerwindow1)
    Exit
EndFunc

Func close()
    Exit
EndFunc

Why is it that Poilitics is made up of the word poli meaning many and tics being blood sucking creatures?

Link to comment
Share on other sites

I believe IniWrite is writing to the working dir, and browse changes it from the script dir to the chosen directory. Either way the following should be what you're after.

Func Defineapplinkerbutton1p2()
    IniWrite(@ScriptDir & "/Test.ini", "Applinkerlabels", "Label_1", GUICtrlRead($applinkerinput1))
    INIWrite(@ScriptDir & "/Test.ini", "Applinkerdirectories", "Directory_1", GUICtrlRead($applinkerinput2))
    IniWrite(@ScriptDir & "/Test.ini", "Applinkerhotkeys", "Hotkey_1", GUICTRLREAD($applinkerinput3))
    GUISetState(@SW_HIDE, $applinkerwindow1)
    Exit
EndFunc
Link to comment
Share on other sites

ok will try that and get back to you, thanks guys

It did change the directory it writes to all the places that I tested it in my C:/ now have the test .ini in them

Edited by Spaldy

Why is it that Poilitics is made up of the word poli meaning many and tics being blood sucking creatures?

Link to comment
Share on other sites

Works fine now, Thanks to everyone that helped :o

I can't believe I missed that, will read Helpfile more carefully now :D

Why is it that Poilitics is made up of the word poli meaning many and tics being blood sucking creatures?

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