I want to store these GUI edit box parameters permanently

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Raghava Doregowda
Posts: 130
Joined: 06 Nov 2022, 01:48

I want to store these GUI edit box parameters permanently

Post by Raghava Doregowda » 07 Jun 2023, 02:51

Below is the Code I've partially developed. I want to assign the Numpad keys (which I never use most of the time) to links/URLs to be opened specifically in chrome browser. I've developed this GUI so that a user need not access a AHK code and attempt to understand the code in order to customize the links every time. He/she should be able to press say the Numpad + button to open up this GUI and edit the links/URLs.
I have a problem however with "permanently" storing the links in such a way that even after shutdown/restart, I want the numpad keys to continue working to open the saved links. How do I go about that?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Gui, Add, Text, x20 y36 w115 h19 , NumPad 1 -------------------
Gui, Add, Text, x20 y64 w115 h19 , NumPad 2 -------------------
Gui, Add, Text, x20 y93 w115 h19 , NumPad 3 -------------------
Gui, Add, Text, x20 y122 w115 h19 , NumPad 4 -------------------
Gui, Add, Text, x20 y151 w115 h19 , NumPad 5 -------------------
Gui, Add, Text, x20 y180 w115 h19 , NumPad 6 -------------------
Gui, Add, Text, x20 y208 w115 h19 , NumPad 7 -------------------
Gui, Add, Text, x20 y237 w115 h19 , NumPad 8 -------------------
Gui, Add, Text, x20 y266 w115 h19 , NumPad 9 -------------------
Gui, Add, Edit, x175 y36 w290 h19 vNum1
Gui, Add, Edit, x175 y64 w290 h19 vNum2
Gui, Add, Edit, x175 y93 w290 h19 vNum3
Gui, Add, Edit, x175 y122 w290 h19 vNum4
Gui, Add, Edit, x175 y151 w290 h19 vNum5
Gui, Add, Edit, x175 y180 w290 h19 vNum6
Gui, Add, Edit, x175 y208 w290 h19 vNum7
Gui, Add, Edit, x175 y237 w290 h19 vNum8
Gui, Add, Edit, x175 y266 w290 h19 vNum9
Gui, Add, Text, x20 y7 w76 h19 , KEYS
Gui, Add, Text, x204 y7 w259 h19 , LINKS
Gui, Add, Button, x260 y300 w124 h38 gGuiClose, CANCEL
Gui, Add, Button, x109 y300 w124 h38 gGuiSubmit, OK
; Generated using SmartGUI Creator for SciTE
Gui, Show, w479 h377, LINK SHORTCUTS
return
Guisubmit:
Gui, submit, nohide
Msgbox, %Num1%, %Num2%, %Num3%, %Num4%, %Num5%, %Num6%, %Num7%, %Num8%, %Num9%
GuiClose:
;Msgbox, %Num1%, %Num2%, %Num3%, %Num4%
ExitApp

Rohwedder
Posts: 7643
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: I want to store these GUI edit box parameters permanently

Post by Rohwedder » 07 Jun 2023, 05:47

Hallo,
try:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
IF FileExist("File.ini")
	Loop, 9 ; Generated using https://ahkde.github.io/docs/v1/lib/IniRead.htm
		IniRead, Num%A_Index%, File.ini, Urls, Num%A_Index%,
Gui, Add, Text, x20 y36 w115 h19 , NumPad 1 -------------------
Gui, Add, Text, x20 y64 w115 h19 , NumPad 2 -------------------
Gui, Add, Text, x20 y93 w115 h19 , NumPad 3 -------------------
Gui, Add, Text, x20 y122 w115 h19 , NumPad 4 -------------------
Gui, Add, Text, x20 y151 w115 h19 , NumPad 5 -------------------
Gui, Add, Text, x20 y180 w115 h19 , NumPad 6 -------------------
Gui, Add, Text, x20 y208 w115 h19 , NumPad 7 -------------------
Gui, Add, Text, x20 y237 w115 h19 , NumPad 8 -------------------
Gui, Add, Text, x20 y266 w115 h19 , NumPad 9 -------------------
Gui, Add, Edit, x175 y36 w290 h19 vNum1, %Num1%
Gui, Add, Edit, x175 y64 w290 h19 vNum2, %Num2%
Gui, Add, Edit, x175 y93 w290 h19 vNum3, %Num3%
Gui, Add, Edit, x175 y122 w290 h19 vNum4, %Num4%
Gui, Add, Edit, x175 y151 w290 h19 vNum5, %Num5%
Gui, Add, Edit, x175 y180 w290 h19 vNum6, %Num6%
Gui, Add, Edit, x175 y208 w290 h19 vNum7, %Num7%
Gui, Add, Edit, x175 y237 w290 h19 vNum8, %Num8%
Gui, Add, Edit, x175 y266 w290 h19 vNum9, %Num9%
Gui, Add, Text, x20 y7 w76 h19 , KEYS
Gui, Add, Text, x204 y7 w259 h19 , LINKS
Gui, Add, Button, x260 y300 w124 h38 gGuiClose, CANCEL
Gui, Add, Button, x109 y300 w124 h38 gGuiSubmit, OK
; Generated using SmartGUI Creator for SciTE
Gui, Show, w479 h377, LINK SHORTCUTS
return
Guisubmit:
Gui, submit, nohide
Loop, 9 ; Generated using https://ahkde.github.io/docs/v1/lib/IniWrite.htm
	IniWrite,% Num%A_Index%, File.ini, Urls, Num%A_Index%
Msgbox, %Num1%, %Num2%, %Num3%, %Num4%, %Num5%, %Num6%, %Num7%, %Num8%, %Num9%
GuiClose:
;Msgbox, %Num1%, %Num2%, %Num3%, %Num4%
ExitApp

RussF
Posts: 1266
Joined: 05 Aug 2021, 06:36

Re: I want to store these GUI edit box parameters permanently

Post by RussF » 07 Jun 2023, 06:03

Raghava Doregowda wrote: I want to assign the Numpad keys (which I never use most of the time) ... so that a user need not access a AHK code and attempt to understand the code ...
Just something to think about if you are developing scripts for other users. While you might never use the numpad keys, many other users use them all the time. Your script may seriously impede their normal use of the keyboard.

Russ

Raghava Doregowda
Posts: 130
Joined: 06 Nov 2022, 01:48

Re: I want to store these GUI edit box parameters permanently

Post by Raghava Doregowda » 07 Jun 2023, 11:28

Rohwedder wrote:
07 Jun 2023, 05:47
Hallo,
try:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
IF FileExist("File.ini")
	Loop, 9 ; Generated using https://ahkde.github.io/docs/v1/lib/IniRead.htm
		IniRead, Num%A_Index%, File.ini, Urls, Num%A_Index%,
Gui, Add, Text, x20 y36 w115 h19 , NumPad 1 -------------------
Gui, Add, Text, x20 y64 w115 h19 , NumPad 2 -------------------
Gui, Add, Text, x20 y93 w115 h19 , NumPad 3 -------------------
Gui, Add, Text, x20 y122 w115 h19 , NumPad 4 -------------------
Gui, Add, Text, x20 y151 w115 h19 , NumPad 5 -------------------
Gui, Add, Text, x20 y180 w115 h19 , NumPad 6 -------------------
Gui, Add, Text, x20 y208 w115 h19 , NumPad 7 -------------------
Gui, Add, Text, x20 y237 w115 h19 , NumPad 8 -------------------
Gui, Add, Text, x20 y266 w115 h19 , NumPad 9 -------------------
Gui, Add, Edit, x175 y36 w290 h19 vNum1, %Num1%
Gui, Add, Edit, x175 y64 w290 h19 vNum2, %Num2%
Gui, Add, Edit, x175 y93 w290 h19 vNum3, %Num3%
Gui, Add, Edit, x175 y122 w290 h19 vNum4, %Num4%
Gui, Add, Edit, x175 y151 w290 h19 vNum5, %Num5%
Gui, Add, Edit, x175 y180 w290 h19 vNum6, %Num6%
Gui, Add, Edit, x175 y208 w290 h19 vNum7, %Num7%
Gui, Add, Edit, x175 y237 w290 h19 vNum8, %Num8%
Gui, Add, Edit, x175 y266 w290 h19 vNum9, %Num9%
Gui, Add, Text, x20 y7 w76 h19 , KEYS
Gui, Add, Text, x204 y7 w259 h19 , LINKS
Gui, Add, Button, x260 y300 w124 h38 gGuiClose, CANCEL
Gui, Add, Button, x109 y300 w124 h38 gGuiSubmit, OK
; Generated using SmartGUI Creator for SciTE
Gui, Show, w479 h377, LINK SHORTCUTS
return
Guisubmit:
Gui, submit, nohide
Loop, 9 ; Generated using https://ahkde.github.io/docs/v1/lib/IniWrite.htm
	IniWrite,% Num%A_Index%, File.ini, Urls, Num%A_Index%
Msgbox, %Num1%, %Num2%, %Num3%, %Num4%, %Num5%, %Num6%, %Num7%, %Num8%, %Num9%
GuiClose:
;Msgbox, %Num1%, %Num2%, %Num3%, %Num4%
ExitApp
Hey @Rohwedder Thanks a Lot!! Your code works perfectly.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
NumpadAdd::
{
	IF FileExist("File.ini")
		Loop, 9 ; Generated using https://ahkde.github.io/docs/v1/lib/IniRead.htm
			IniRead, Num%A_Index%, File.ini, Urls, Num%A_Index%,
	Gui, Add, Text, x20 y36 w115 h19 , NumPad 1 -------------------
	Gui, Add, Text, x20 y64 w115 h19 , NumPad 2 -------------------
	Gui, Add, Text, x20 y93 w115 h19 , NumPad 3 -------------------
	Gui, Add, Text, x20 y122 w115 h19 , NumPad 4 -------------------
	Gui, Add, Text, x20 y151 w115 h19 , NumPad 5 -------------------
	Gui, Add, Text, x20 y180 w115 h19 , NumPad 6 -------------------
	Gui, Add, Text, x20 y208 w115 h19 , NumPad 7 -------------------
	Gui, Add, Text, x20 y237 w115 h19 , NumPad 8 -------------------
	Gui, Add, Text, x20 y266 w115 h19 , NumPad 9 -------------------
	Gui, Add, Edit, x175 y36 w290 h19 vNum1, %Num1%
	Gui, Add, Edit, x175 y64 w290 h19 vNum2, %Num2%
	Gui, Add, Edit, x175 y93 w290 h19 vNum3, %Num3%
	Gui, Add, Edit, x175 y122 w290 h19 vNum4, %Num4%
	Gui, Add, Edit, x175 y151 w290 h19 vNum5, %Num5%
	Gui, Add, Edit, x175 y180 w290 h19 vNum6, %Num6%
	Gui, Add, Edit, x175 y208 w290 h19 vNum7, %Num7%
	Gui, Add, Edit, x175 y237 w290 h19 vNum8, %Num8%
	Gui, Add, Edit, x175 y266 w290 h19 vNum9, %Num9%
	Gui, Add, Text, x20 y7 w76 h19 , KEYS
	Gui, Add, Text, x204 y7 w259 h19 , LINKS
	Gui, Add, Button, x260 y300 w124 h38 gGuiClose, CANCEL
	Gui, Add, Button, x109 y300 w124 h38 gGuiSubmit, OK
	; Generated using SmartGUI Creator for SciTE
	Gui, Show, w479 h377, LINK SHORTCUTS
	return
	Guisubmit:
	Gui, submit, nohide
	Loop, 9 ; Generated using https://ahkde.github.io/docs/v1/lib/IniWrite.htm
		IniWrite,% Num%A_Index%, File.ini, Urls, Num%A_Index%
	GuiClose:
	Gui, Destroy
	return
}
Numpad1::
{
	Run chrome.exe %Num1%
	return
}
Numpad2::
{
	Run chrome.exe %Num2%
	return
}
Numpad3::
{
	Run chrome.exe %Num3%
	return
}
Numpad4::
{
	Run chrome.exe %Num4%
	return
}
Numpad5::
{
	Run chrome.exe %Num5%
	return
}
Numpad6::
{
	Run chrome.exe %Num6%
	return
}
Numpad7::
{
	Run chrome.exe %Num7%
	return
}
Numpad8::
{
	Run chrome.exe %Num8%
	return
}
Numpad9::
{
	Run chrome.exe %Num9%
	return
}

Raghava Doregowda
Posts: 130
Joined: 06 Nov 2022, 01:48

Re: I want to store these GUI edit box parameters permanently

Post by Raghava Doregowda » 07 Jun 2023, 11:29

RussF wrote:
07 Jun 2023, 06:03
Raghava Doregowda wrote: I want to assign the Numpad keys (which I never use most of the time) ... so that a user need not access a AHK code and attempt to understand the code ...
Just something to think about if you are developing scripts for other users. While you might never use the numpad keys, many other users use them all the time. Your script may seriously impede their normal use of the keyboard.

Russ
I was just typing out my mind :dance: And yes if one wants to change it then he/she can change it to a modifier key combo with numpad keys.

Post Reply

Return to “Ask for Help (v1)”