What do i need to do to save my hotkey and on off status for next startup Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

What do i need to do to save my hotkey and on off status for next startup

04 Jan 2019, 08:20

Hello first of all :offtopic: happy new year

i like to understand how saving the last used settings of my gui works, most in the help is to overwhelming to me and i so not know where to begin to tackle this

this is part of a bigger project i am trying to figure out, to keep it simple i made a simple gui with just 2 things that need to be saved

1 you can click in the left box and set a new hotkey that you then store by clicking the copy button, the user can make it any key or combination
2 you can also choose to turn the hotkey off in case the user does not want that hotkey

these 2 things i like to save so that on next launch it is set like that, this would allow me to write hotkey tools for programs i use that are tweak able

any help would be appreciated

Code: Select all

#SingleInstance, force

Copy_Hotkey :="NumpadDiv"
hotkey, %Copy_Hotkey% , Copy

Gui,1: +Alwaysontop 
Gui,1: Color, Black
Gui,1: Font, cBlack s12
Gui,1: Add, Text, x5      y10 w193  h30 center cWhite, Current Key
Gui,1: Add, Text, x200 y10 w150   h30 center cWhite, Update / HotKey
Gui,1: Add, Text, x+10        w50     h30 center cWhite, On/Off

Gui,1: Add,Hotkey, x10  y40  vCopy_Hotkey, %Copy_Hotkey% 
Gui,1:Add,Button, x+10  w150 h28  vUpdate_Copy_Button  gUpdate_Copy_Button  ,Copy
Gui,1:Add,Checkbox,  cWhite x+30 w30 h29 vLock1 gUnlockCopy,

Gui,1:Show, w427 h75, Save Test
Gui,1:Submit,NoHide
return

GuiClose:
ExitApp
return

UnlockCopy:
Lock1:=!Lock1
if(Lock1=1)
   {
   GuiControl,1:Disable,Copy_Hotkey
   Hotkey, %Copy_Hotkey%, Copy, Off
   GuiControl,1:Disable,Update_Copy_Button 
   }
if(Lock1=0)
   {
   GuiControl,1:Enable,Copy_Hotkey
   hotkey, %Copy_Hotkey% , Copy, on
   GuiControl,1:Enable,Update_Copy_Button 
   }
return

Update_Copy_Button:
GuiControlGet, New_Key , 1:, Copy_Hotkey
If(New_Key !=Copy_Hotkey)
{
	hotkey, %Copy_Hotkey% , Copy, off
	Copy_Hotkey := New_Key
	hotkey, %Copy_Hotkey% , Copy, on
}
return 

Copy:
tooltip, hey i work
return

User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: What do i need to do to save my hotkey and on off status for next startup  Topic is solved

04 Jan 2019, 09:19

Code: Select all

#SingleInstance, Force

IniRead, MyHotkey, settings.ini, Settings, Hotkey, NumpadDiv
IniRead, MyToggle, settings.ini, Settings, Toggle, 0

Gui, +AlwaysOnTop
Gui, Color, 000000
Gui, Margin, 10, 10

Gui, Font, cFFFFFF S12
Gui, Add, Text, w200 0x201, Hotkey
Gui, Add, Text, x+10 yp w200 hp 0x201, Update
Gui, Add, Text, x+10 yp w200 hp 0x201, Toggle

Gui, Font, c000000 S12
Gui, Add, Hotkey, xm y+10 w200 vHotkey, % MyHotkey
Gui, Add, Button, x+10 yp w200 hp vUpdate gUpdate, Update

Gui, Font, cFFFFFF S12
Gui, Add, Checkbox, x+10 w200 vToggle gToggle Checked%MyToggle%, Off

Gui, Show, AutoSize, Example

GoSub, Update
GoSub, Toggle
return

Update:
	Gui, Submit, NoHide
	Hotkey, % Hotkey, HotkeyAction
	IniWrite, % Hotkey, settings.ini, Settings, Hotkey
return

Toggle:
	Gui, Submit, NoHide
	GuiControl,, Toggle, % (Toggle ? "On" : "Off")
	GuiControl, % (Toggle ? "Disable" : "Enable"), Hotkey
	GuiControl, % (Toggle ? "Disable" : "Enable"), Update
	IniWrite, % Toggle, settings.ini, Settings, Toggle
return

HotkeyAction:
	If (!Toggle) {
		return
	}

	ToolTip, % "Hotkey Pressed: " Hotkey
return
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Re: What do i need to do to save my hotkey and on off status for next startup

04 Jan 2019, 10:30

just wauw that is nice :) also the on off toggle is very nice

thank you very much TheDewd
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Re: What do i need to do to save my hotkey and on off status for next startup

04 Jan 2019, 11:12

TheDewd wrote:
04 Jan 2019, 09:19

Code: Select all

#SingleInstance, Force

IniRead, MyHotkey, settings.ini, Settings, Hotkey, NumpadDiv
IniRead, MyToggle, settings.ini, Settings, Toggle, 0

Gui, +AlwaysOnTop
Gui, Color, 000000
Gui, Margin, 10, 10

Gui, Font, cFFFFFF S12
Gui, Add, Text, w200 0x201, Hotkey
Gui, Add, Text, x+10 yp w200 hp 0x201, Update
Gui, Add, Text, x+10 yp w200 hp 0x201, Toggle

Gui, Font, c000000 S12
Gui, Add, Hotkey, xm y+10 w200 vHotkey, % MyHotkey
Gui, Add, Button, x+10 yp w200 hp vUpdate gUpdate, Update

Gui, Font, cFFFFFF S12
Gui, Add, Checkbox, x+10 w200 vToggle gToggle Checked%MyToggle%, Off

Gui, Show, AutoSize, Example

GoSub, Update
GoSub, Toggle
return

Update:
	Gui, Submit, NoHide
	Hotkey, % Hotkey, HotkeyAction
	IniWrite, % Hotkey, settings.ini, Settings, Hotkey
return

Toggle:
	Gui, Submit, NoHide
	GuiControl,, Toggle, % (Toggle ? "On" : "Off")
	GuiControl, % (Toggle ? "Disable" : "Enable"), Hotkey
	GuiControl, % (Toggle ? "Disable" : "Enable"), Update
	IniWrite, % Toggle, settings.ini, Settings, Toggle
return

HotkeyAction:
	If (!Toggle) {
		return
	}

	ToolTip, % "Hotkey Pressed: " Hotkey
return
hi i seam to have jumped the gun, i had not noticed my copy label is gone and that is where i would add the code for one of the hotkeys (in this case copy) where do i add my code now? edit: got it noob in action
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: What do i need to do to save my hotkey and on off status for next startup

04 Jan 2019, 12:07

OCP wrote:hi i seam to have jumped the gun, i had not noticed my copy label is gone and that is where i would add the code for one of the hotkeys (in this case copy) where do i add my code now? edit: got it noob in action

Look at the HotkeyAction label. See where I've added the ToolTip similar to your earlier example?

I'm sorry that I changed too many things from your original example and made things more confusing.
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Re: What do i need to do to save my hotkey and on off status for next startup

04 Jan 2019, 12:31

TheDewd wrote:
04 Jan 2019, 12:07
OCP wrote:hi i seam to have jumped the gun, i had not noticed my copy label is gone and that is where i would add the code for one of the hotkeys (in this case copy) where do i add my code now? edit: got it noob in action

Look at the HotkeyAction label. See where I've added the ToolTip similar to your earlier example?

I'm sorry that I changed too many things from your original example and made things more confusing.
dont be sorry i like what you did here it enables me to grow i thank you

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: kaka2 and 137 guests