ty for the help.
i tried the script and it did work! it saved the hotkey on the close.
i tried to see if i can make a 2nd hotkey and got that to work.
but
then i tested it in a couple of ways.
1) it saved when i close it but then the 2nd time i close it... it goes back to default like no hotkey was used.
2) after i close it and re-open it the hot keys it remembers dont work. the hot key does not trigger the "hello" msgbox
any ideas?
Code: Select all
#SingleInstance Force
#Persistent
#NoEnv
IniRead, MyHK, settings.ini, Application, MyHotkey
IniRead, MyHK2, settings.ini, Application, MyHotkey2
Gui, Margin, 8, 8
Gui, Add, Hotkey, w300 gOneHotkey VHkey, % MyHK
Gui, Add, Hotkey, w300 gOneHotkey2 VHkey2, % MyHK2
Gui, Show, AutoSize, Example
return
OneHotkey:
HClear := Hkey
If (StateHKey = "On") {
HKeyOldest := HClear
StateHKey := "Off"
Hotkey, %HKeyOldmost%, OFF, UseErrorLevel OFF
} Else {
HKeyOldmost := HClear
StateHKey := "On"
Hotkey, %HKeyOldest%, OFF, UseErrorLevel OFF
}
MsgBox, %HKeyOldest%`n%HKeyOldmost%
Hotkey, %HKey%, Hello, UseErrorLevel ON
return
Hello:
Msgbox, Hello
return
OneHotkey2:
HClear2 := Hkey2
If (StateHKey2 = "On") {
HKeyOldest2 := HClear2
StateHKey2 := "Off"
Hotkey, %HKeyOldmost2%, OFF, UseErrorLevel OFF
} Else {
HKeyOldmost2 := HClear2
StateHKey2 := "On"
Hotkey, %HKeyOldest2%, OFF, UseErrorLevel OFF
}
MsgBox, %HKeyOldest2%`n%HKeyOldmost2%
Hotkey, %HKey2%, Hello2, UseErrorLevel ON
return
Hello2:
Msgbox, Hello2
return
GuiClose:
IniWrite, % Hkey2, settings.ini, Application, MyHotkey2
IniWrite, % Hkey, settings.ini, Application, MyHotkey
ExitApp
return