Что нового

Изменение горячей клавиши

eBug

Новичок
Сообщения
4
Репутация
0
После попытки "изменения" горячей клавиши через GUI, горячая клавиша не изменяется, а добавляется новая. Как исправить?

Код:
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>

$Dir_ini1 = @ScriptDir & "\Settings.ini"
If Not FileExists($Dir_ini1) Then IniWriteSection($Dir_ini1, "Settings - Ackey", "Key", "2")
$Key1 = IniRead($Dir_ini1, "Settings - Ackey", "Key", "")
If StringIsDigit($Key1) Then
   If $Key1 < 2 Or $Key1 > 12 Then IniWrite($Dir_ini1, "Settings - Ackey", "Key", "2")
Else
   IniWrite($Dir_ini1, "Settings - Ackey", "Key", "2")
EndIf
$Key1 = IniRead($Dir_ini1, "Settings - Ackey", "Key", "")

$Form1 = GUICreate("Ackey v.1.0 by eBug", 334, 360)
$MenuItem1 = GUICtrlCreateMenu("Помощь")
$Group1 = GUICtrlCreateGroup("Добавление нового аккаунта", 16, 8, 182, 129)
$Label1 = GUICtrlCreateLabel("Имя:", 40, 32, 29, 17)
$Label2 = GUICtrlCreateLabel("Логин:", 31, 56, 38, 17)
$Label3 = GUICtrlCreateLabel("Пароль:", 24, 80, 45, 17)
$Input1 = GUICtrlCreateInput("", 69, 29, 121, 21)
$Input2 = GUICtrlCreateInput("", 69, 53, 121, 21)
$Input3 = GUICtrlCreateInput("", 69, 77, 121, 21)
$Button1 = GUICtrlCreateButton("Добавить", 24, 104, 166, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Горячая клавиша", 206, 8, 111, 129)
$Label4 = GUICtrlCreateLabel("Текущая: F" & $Key1, 214, 32, 73, 17)
$Label5 = GUICtrlCreateLabel("Новая:", 227, 56, 39, 17)
$Combo1 = GUICtrlCreateCombo("", 266, 53, 43, 25, $CBS_DROPDOWNLIST)
   GUICtrlSetData(-1, "F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12", "F" & $Key1)
$Button2 = GUICtrlCreateButton("Изменить", 214, 80, 95, 25)
$Checkbox1 = GUICtrlCreateCheckbox("Сохранять", 216, 108, 73, 17)
   GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListView1 = GUICtrlCreateListView("", 16, 144, 301, 150)
$Input4 = GUICtrlCreateInput("", 111, 302, 115, 21)
$Label6 = GUICtrlCreateLabel("Текущий аккаунт:", 16, 305, 95, 17)
$Button3 = GUICtrlCreateButton("Удалить", 242, 302, 75, 21)
GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
	  Case $GUI_EVENT_CLOSE
		 Exit
	  Case $Button2
		 $Read1 = GUICtrlRead($Checkbox1)
		 $Read2 = GUICtrlRead($Combo1)
		 $Key1 = StringTrimLeft($Read2, 1)
		 If $Read1 = 1 Then IniWrite($Dir_ini1, "Settings - Ackey", "Key", $Key1)
		 GUICtrlSetData($Label4, "Текущая: F" & $Key1)
   EndSwitch
   HotKeySet("{F" & $Key1 & "}", "FuncKey")
WEnd

Func FuncKey()
   MsgBox(0, "", "")
EndFunc
 

C2H5OH

AutoIT Гуру
Сообщения
1,473
Репутация
333
Сбрасывать надо предыдущее значение http://autoit-script.ru/autoit3_docs/functions/HotKeySet.htm

Код:
HotKeySet("{F" & $Key1 & "}", "FuncKey")
While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit
	 Case $Button2
		 HotKeySet("{F" & $Key1 & "}") ; <-----
         $Read1 = GUICtrlRead($Checkbox1)
         $Read2 = GUICtrlRead($Combo1)
         $Key1 = StringTrimLeft($Read2, 1)
         If $Read1 = 1 Then IniWrite($Dir_ini1, "Settings - Ackey", "Key", $Key1)
         GUICtrlSetData($Label4, "Текущая: F" & $Key1)
		 HotKeySet("{F" & $Key1 & "}", "FuncKey")
   EndSwitch
WEnd
 
Верх