IniRead problem| Need some help 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

IniRead problem| Need some help

29 Feb 2020, 10:46

Hello Guys, I need some help with this Script. My program is going to let you choose if you want to save a File or an Url into an Hotkey. the Url part is working fine but the File part just don´t work. The Url works in the way that you write the Url you want into the Editbox and then click on the Home button.
Then the "homef" label saves the var into the ini file I am using. My problem is that the filepath which I try to save into the filef1 variable cannot be saved because as my programm jumps to the homef part the variable is resettet to the value which was already in the ini saved. I testet it when I deleted the first line of code. Then the Scipt just saved nothing into the ini. Why is this happening? Am i being stupid? xD

Code: Select all

; Read the var when the programm starts to show it in the gui
IniRead, filef1, Settings.ini, Fshortcut, filef1

kontroll:
if(filef1 = "ERROR" or filef1 = "")
	filef1 = NONE

Gui,kontroll: new
;Gui, -MaximizeBox -MinimizeBox
IniRead, filef1, Settings.ini, Fshortcut, filef1
Gui,kontroll: font, s25 cwhite
Gui,kontroll: Add, Text , x50 y270 +BackgroundTrans, F1
Gui,kontroll: font, s12 cblack
Gui,kontroll: Add, Button, gf1a x100 y270 w100 h40, &Load
Gui,kontroll: font, s10 
Gui,kontroll: Add, Edit, x210 y270 w400 h40 vfilef1, %filef1%
Gui,kontroll: Add, Picture, x600 y620 +BackgroundTrans ghomef, HomeB.png ; this button saves the Url part..
Return

homef:
;gui, submit, NoHide
gui, submit
MsgBox,,,%filef1%
IniWrite, %filef1%, Settings.ini, Fshortcut, filef1
IniRead, filef1, Settings.ini, Fshortcut, filef1
gosub, kontroll
return

f1a:
FileSelectFile ,filef1,x190 y270 w250 h40,, Select an image:, Images (*.exe; *.de; *.com; *.net; *.org; *.io; *.bat; *.png; *.*)
if filef1 =
{
	gosub, Einstellungen
    MsgBox, The user didn't select anything.
	return
}
else
{

	MsgBox,,,"gosub homef before"
	MsgBox,,,%filef1%
	gosub, homef
	MsgBox,,,%filef1%
	MsgBox,,,"gosub homef after"
	Return
}

	+F1::Run "%filef1%"
User avatar
boiler
Posts: 17052
Joined: 21 Dec 2014, 02:44

Re: IniRead problem| Need some help  Topic is solved

29 Feb 2020, 13:50

One thing that may be causing a problem and making it hard to figure out what is happening is that you are creating multiple GUIs. When you do a Gui, Submit without NoHide and then run your Kontroll subroutine again, you are creating a new GUI each time, and what you are pulling from the Gui, Submit may be from the original GUI. Get rid of the Gui,kontroll,new statement, and use NoHide when you submit it. That means that you'll have to avoid executing the GUI creation subroutine each time, but you shouldn't be doing that anyway.
Liaxim
Posts: 35
Joined: 09 Jan 2020, 05:14

Re: IniRead problem| Need some help

08 Mar 2020, 11:40

boiler wrote:
29 Feb 2020, 13:50
One thing that may be causing a problem and making it hard to figure out what is happening is that you are creating multiple GUIs. When you do a Gui, Submit without NoHide and then run your Kontroll subroutine again, you are creating a new GUI each time, and what you are pulling from the Gui, Submit may be from the original GUI. Get rid of the Gui,kontroll,new statement, and use NoHide when you submit it. That means that you'll have to avoid executing the GUI creation subroutine each time, but you shouldn't be doing that anyway.
Thx dude, that´s working. I made something like this now:
  • MsgBox,,,%filef1%
    IniWrite, %filef1%, Settings.ini, Fshortcut, filef1
    IniRead, filef1, Settings.ini, Fshortcut, filef1
    Reload
    return
I have one last question. Is it possible to reload a specific window?
User avatar
boiler
Posts: 17052
Joined: 21 Dec 2014, 02:44

Re: IniRead problem| Need some help

08 Mar 2020, 13:04

Liaxim wrote: I have one last question. Is it possible to reload a specific window?
I'm not sure what you're trying to accomplish with Reload. It doesn't reload just a window. It restarts the script overall. What are you looking to achieve? You want to refresh a GUI window or something?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jeves, Sarhad and 139 guests