Page 1 of 1

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

Posted: 04 Jan 2019, 08:20
by OCP
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


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

Posted: 04 Jan 2019, 09:19
by TheDewd

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

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

Posted: 04 Jan 2019, 10:30
by OCP
just wauw that is nice :) also the on off toggle is very nice

thank you very much TheDewd

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

Posted: 04 Jan 2019, 11:12
by OCP
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

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

Posted: 04 Jan 2019, 12:07
by TheDewd
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.

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

Posted: 04 Jan 2019, 12:31
by OCP
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