FileSelectFile save Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Liaxim
Posts: 35
Joined: 09 Jan 2020, 05:14

FileSelectFile save

06 Feb 2020, 12:50

hey guys, I am trying to make a gui where I can set which program my f1 key starts. My problem is that the path will not saved. hope anyone know how to fix this.

Code: Select all

mainmenue:
Gui, new
Gui, Add, Text , x140 y270 +BackgroundTrans, F1
Gui, Add, Button, gf1a x190 y270 w250 h40, &Load
Gui, Show, w1280 h720
Return

f1a:
FileSelectFile , F1 ,x190 y270 w250 h40,, Select an image:, Images (*.exe; *.de; *.com; *.net; *.org; *.io; *.bat)
;if not file
;	return
gui,submit
gosub, home
Return

F1:
F1::Run "%F1%"
Gosub, mainmenue
Return

home:
gui, submit
IniWrite, %F1%, Settings.ini, Fshortcut, F1
IniRead, F1, Settings.ini, Fshortcut, F1
Return
Albireo
Posts: 1754
Joined: 16 Oct 2013, 13:53

Re: FileSelectFile save

07 Feb 2020, 10:03

The only way I spontaneously thinking on, is to create an ini-file with the latest selection, and use IniRead / IniWrite
Liaxim
Posts: 35
Joined: 09 Jan 2020, 05:14

Re: FileSelectFile save

12 Feb 2020, 14:45

Albireo wrote:
07 Feb 2020, 10:03
The only way I spontaneously thinking on, is to create an ini-file with the latest selection, and use IniRead / IniWrite
Hey thx for your answer. Did you mean I should use an iniwrite / iniread in the same Label where I picked the File? I tried some things and my information is now that after I write the "gosub" the "F1" Variable is empty but before the "gosub" is the right var in it. Have anyone an Idea why this is happening?
User avatar
boiler
Posts: 16932
Joined: 21 Dec 2014, 02:44

Re: FileSelectFile save  Topic is solved

12 Feb 2020, 20:13

You need to put the IniRead at the beginning of your script so it will read the saved file if you have it, and only use IniWrite when you chose a new one (following it with IniRead at that point is superfluous). The version below reads your ini file and displays what it contains in the GUI:

Code: Select all

mainmenue:
IniRead, F1, Settings.ini, Fshortcut, F1
Gui, new
Gui, Add, Text, x50 y50, % "Saved file: " . (F1 = "ERROR" ? "None" : F1)
Gui, Add, Text , x140 y270 +BackgroundTrans, F1
Gui, Add, Button, gf1a x190 y270 w250 h40, &Load
Gui, Show, w1280 h720
Return

f1a:
FileSelectFile , F1 ,x190 y270 w250 h40,, Select an image:, Images (*.exe; *.de; *.com; *.net; *.org; *.io; *.bat)
;if not file
;	return
gui,submit
gosub, home
Return

F1:
F1::Run "%F1%"
Gosub, mainmenue
Return

home:
gui, submit
IniWrite, %F1%, Settings.ini, Fshortcut, F1
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 402 guests