Теперь во вкладке "мышь" не получается назначить на исполняемые кнопки("LButton","RButton" итд.) нажатые клавиши из поля "ListBox",потомучто там в "DllCall("mouse_event")" идут не VK коды, ссылка.
#NoEnv
#UseHook
#HotkeyInterval 1
#MaxHotkeysPerInterval 999
#SingleInstance Force
List=Нет||LButton|RButton|MButton|WheelUp|WheelDown|XButton1|XButton2|Записать макрос
OnExit("GuiClose")
Hotkey_Option("MLRES")
Gui, Font, s10 Bold, Cambria
Gui, Add, Tab, +0x400 w250 h600 cRed HwndtabID, Клавиатура| Мышь
Gui, Add, Text,cBlue ,Клавиша управления:
Gui, Add, Edit, w100 cRed vKY hwndh2, % Hotkey_Set("B2")
Gui, Add, Text, cBlue,Нажмите клавишу :
Gui, Add, Edit, w100 cRed vKl gkeys hwndh1, % Hotkey_Set("B1")
Gui, Add, Text, cBlue,Задержка милесекундах :
Gui, Add, Edit, w100 cRed vSleep, 65
Gui, Add, Button, x130 y167 w70 h20 gSleepr, Добавить
Gui, Add, Button,x20 y200 w100 h20 gOpen, открыть
Gui, Add, Button, x20 y230 w100 h20 gSaves, сохранить
Gui, Add, ListBox, x300 y100 w490 h480 cBlue Multi vText
Gui, Tab, 2
Gui, Add, Text, x20 y30 w100 h20 cBlue,LButton
Gui, Add, Button, x90 y30 w80 h15 vB1 , Назначить
Gui, Add, Text, x20 y60 w100 h20 cBlue,RButton
Gui, Add, Button, x90 y60 w80 h15 , Назначить
Gui, Add, Text, x20 y90 w100 h20 cBlue,MButton
Gui, Add, Button, x90 y90 w80 h15 , Назначить
Gui, Add, Text, x20 y120 w100 h20 cBlue,WheelUp
Gui, Add, Button, x90 y120 w80 h15 , Назначить
Gui, Add, Text, x10 y150 w100 h20 cBlue,WheelDown
Gui, Add, Button, x90 y150 w80 h15 , Назначить
Gui, Add, Text, x20 y180 w100 h20 cBlue,XButton1
Gui, Add, Button, x90 y180 w80 h15 , Назначить
Gui, Add, Text, x20 y210 w100 h20 cBlue,XButton2
Gui, Add, Button, x90 y210 w80 h15 , Назначить
Gui, Add, Text, x20 y240 w200 h20 cBlue,Клавиши для записи :
Gui, Add, Edit, x20 y260 w100 cRed vMb gMous hwndh3, % Hotkey_Set("B1")
Gui, Add, Text,x20 y290 w200 h20 cBlue,Задержка милесекундах :
Gui, Add, Edit, x20 y310 w100 cRed vSleep2 , 65
Gui, Add, Button,x20 y340 w70 h20 gSleepr2, Добавить
Gui, Add, ListBox, x300 y100 w490 h480 cBlue Multi vText2
GuiControl, Focus, Text
Hotkey_Register({"B1":h1, "B2":h2})
Hotkey_Register({"B1":h3})
Gui, Show
Return
~vk79::
Suspend, Off
ExitApp
return
Saves:
Gui Submit, NoHide
FileSelectFile, SelectedFile, S24, , Сохранить макрос, *.ini
IniWrite, %Text%, %SelectedFile%.ini, directory, dir
IniWrite, %KY%, %SelectedFile%.ini, directory1, dir1
IniWrite, %Sleep%, %SelectedFile%.ini, directory2, dir2
FileDelete, .ini
Return
Open:
Gui Submit, NoHide
FileSelectFile, SelectedFile, 24, , Загрузить макрос, *.ini
IniRead, OutputVar3, %SelectedFile%, directory, dir, %A_Space%
IniRead, OutputVar2, %SelectedFile%, directory1, dir1, %A_Space%
IniRead, OutputVar1, %SelectedFile%, directory2, dir2, %A_Space%
GuiControl,, Text, % OutputVar3
GuiControl,, KY, % OutputVar2
GuiControl,, Sleep, % OutputVar1
Return
keys:
Gui Submit, NoHide
GuiControl,, Text, % "НАЖАТА КЛАВИША : " Kl " `n"
GuiControl,, Text, % "ЗАДЕРЖКА : " Sleep " `n"
GuiControl,, Text, % "КЛАВИША ОТПУЩЕНА : " Kl " `n"
GuiControl,, Text, % "ЗАДЕРЖКА : " Sleep " `n"
Hotkey, % "$" Hotkey, HKLabel, Off UseErrorLevel
Hotkey := Hotkey_ValueFromName("B2")
Hotkey, % "$" Hotkey, HKLabel, On
VK := Format("{:#x}", GetKeyVK(Hotkey_ValueFromName("B1")))
;GuiControl, , Text, % "`nVK: " VK "`n`nHotkey: " Hotkey
Return
Mous:
Gui Submit, NoHide
GuiControl,, Text2, % "НАЖАТА КЛАВИША : " Mb " `n"
GuiControl,, Text2, % "ЗАДЕРЖКА : " Sleep2 " `n"
GuiControl,, Text2, % "КЛАВИША ОТПУЩЕНА : " Mb " `n"
GuiControl,, Text2, % "ЗАДЕРЖКА : " Sleep2 " `n"
Return
Sleepr:
Gui Submit, NoHide
GuiControl,, Text, % "ЗАДЕРЖКА : " Sleep " `n"
Return
Sleepr2:
Gui Submit, NoHide
GuiControl,, Text2, % "ЗАДЕРЖКА : " Sleep2 " `n"WheelUp
Return
B1:
vkDown := {"Нет":"","LButton":"0x02","RButton":"0x0008","MButton":"0x0020","X1Button":"0x0001","X2Button":"0x0002","WheelUp":"0x0800","WheelDown":"0x01000"}
vkUp := {"Нет":"","LButton":"0x04","RButton":"0x0010","MButton":"0x0040","X1Button":"0","X2Button":"0","WheelUp":"0","WheelDown":"0"}
VK := Format("{:#x}", GetKeyVK(Hotkey_ValueFromName("B1")))
Return
HKLabel:
While GetKeyState(Hotkey,"P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep
}
Return
~LButton::
While GetKeyState("$LButton","P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep2
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
DllCall("mouse_event", UInt, 0x02, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать левую кнопку мыши
Sleep, Sleep2
DllCall("mouse_event", UInt, 0x04, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
}
Return
~RButton::
While GetKeyState("$RButton","P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep2
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
DllCall("mouse_event", UInt, vkDown1, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать левую кнопку мыши
Sleep, Sleep2
DllCall("mouse_event", UInt, vkUp1, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
}
Return
~MButton::
While GetKeyState("$MButton","P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep2
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
DllCall("mouse_event", UInt, vkDown2, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать левую кнопку мыши
Sleep, Sleep2
DllCall("mouse_event", UInt, vkUp2, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
}
Return
~WheelUp::
While GetKeyState("$WheelUp","P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep2
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
DllCall("mouse_event", UInt, vkDown2, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать левую кнопку мыши
Sleep, Sleep2
DllCall("mouse_event", UInt, vkUp2, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
}
Return
~WheelDown::
While GetKeyState("$WheelDown","P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep2
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
DllCall("mouse_event", UInt, vkDown3, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать левую кнопку мыши
Sleep, Sleep2
DllCall("mouse_event", UInt, vkUp3, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
}
Return
~XButton1::
While GetKeyState("$XButton1","P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep2
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
DllCall("mouse_event", UInt, vkDown4, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать левую кнопку мыши
Sleep, Sleep2
DllCall("mouse_event", UInt, vkUp4, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
}
Return
~XButton2::
While GetKeyState("$XButton2","P")
{
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать клавишу по vk коду
Sleep, Sleep2
DllCall("keybd_event", UInt, VK, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
DllCall("mouse_event", UInt, vkDown5, Int, 0, Int, 0x0001, UInt, 0, Int, 0) ; нажать левую кнопку мыши
Sleep, Sleep2
DllCall("mouse_event", UInt, vkUp5, Int, 0, Int, 0x0002, UInt, 0, Int, 0)
Sleep, Sleep2
}
Return
Sav:
Gui Submit, NoHide
vkDown := vkodDown
vkUp := vkodUp
Return
GuiClose() {
Hotkey_Exit()
ExitApp
}
; http://forum.script-coding.com/viewtopic.php?pid=72549#p72549
Hotkey_Register(Controls) {
Static IsStart
Local Name, Handle
For Name, Handle in Controls
{
Hotkey_Controls("Name", Handle, Name)
Hotkey_Controls("HwndFromName", Name, Handle)
GuiControl, +ReadOnly, % Handle
}
If IsStart
Return
#HotkeyInterval 0
Hotkey_SetWinEventHook(0x8005, 0x8005, 0, RegisterCallback("Hotkey_WinEvent", "F"), 0, 0, 0) ; EVENT_OBJECT_FOCUS := 0x8005
Hotkey_Arr("hHook", Hotkey_SetWindowsHookEx()), Hotkey_RButton()
Return IsStart := 1
}
Hotkey_Main(Param1, Param2=0) {
Static OnlyMods, ControlHandle, Hotkey, KeyName, K := {}
, Prefix := {"LAlt":"<!","LCtrl":"<^","LShift":"<+","LWin":"<#"
,"RAlt":">!","RCtrl":">^","RShift":">+","RWin":">#"
,"Alt":"!","Ctrl":"^","Shift":"+","Win":"#"}
, Symbols := "|vkBA|vkBB|vkBC|vkBD|vkBE|vkBF|vkC0|vkDB|vkDC|vkDD|vkDE|vk41|vk42|"
. "vk43|vk44|vk45|vk46|vk47|vk48|vk49|vk4A|vk4B|vk4C|vk4D|vk4E|"
. "vk4F|vk50|vk51|vk52|vk53|vk54|vk55|vk56|vk57|vk58|vk59|vk5A|"
, EngSym := {"vkBB":"=","vkBC":",","vkBD":"-","vkBE":".","vkBF":"/","vkC0":"``","vkBA":"`;"
,"vkDB":"[","vkDC":"\","vkDD":"]","vkDE":"'","vk41":"A","vk42":"B","vk43":"C"
,"vk44":"D","vk45":"E","vk46":"F","vk47":"G","vk48":"H","vk49":"I","vk4A":"J"
,"vk4B":"K","vk4C":"L","vk4D":"M","vk4E":"N","vk4F":"O","vk50":"P","vk51":"Q"
,"vk52":"R","vk53":"S","vk54":"T","vk55":"U","vk56":"V","vk57":"W","vk58":"X"
,"vk59":"Y","vk5A":"Z"}
Local IsMod, Text
If Param1 = GetMod
Return K.MLCtrl K.MRCtrl K.MLAlt K.MRAlt K.MLShift K.MRShift K.MLWin K.MRWin K.MCtrl K.MAlt K.MShift K.MWin
If Param1 = Control
{
If Param2
{
If OnlyMods
{
SendMessage, 0xC, 0, "" Hotkey_Arr("Empty"), , ahk_id %ControlHandle%
OnlyMods := 0, K := {}
}
ControlHandle := Param2
If !Hotkey_Arr("Hook")
Hotkey_Arr("Hook", 1)
PostMessage, 0x00B1, -1, -1, , ahk_id %ControlHandle% ; EM_SETSEL
}
Else If Hotkey_Arr("Hook")
{
Hotkey_Arr("Hook", 0), K := {}
If OnlyMods
SendMessage, 0xC, 0, "" Hotkey_Arr("Empty"), , ahk_id %ControlHandle%
SetTimer, Hotkey_IsRegFocus, -200
}
Return 1
}
If Param1 = Mod
{
IsMod := Hotkey_Arr("LRMods") ? Param2 : SubStr(Param2, 2)
If (K["M" IsMod] != "")
Return 1
K["M" IsMod] := IsMod "+", K["P" IsMod] := Prefix[IsMod]
}
Else If Param1 = ModUp
{
IsMod := Hotkey_Arr("LRMods") ? Param2 : SubStr(Param2, 2)
K["M" IsMod] := "", K["P" IsMod] := ""
If (Hotkey != "")
Return 1
}
(IsMod) ? (KeyName := Hotkey := K.Prefix := "", OnlyMods := 1)
: (KeyName := GetKeyName(Param1 Param2), OnlyMods := 0
, (StrLen(KeyName) = 1 ? (KeyName := Format("{:U}", KeyName)) : 0)
, Hotkey := InStr(Symbols, "|" Param1 "|") ? Param1 : KeyName
, KeyName := Hotkey = "vkBF" ? "/" : KeyName
, (Hotkey_Arr("OnlyEngSym") && Hotkey != KeyName ? (KeyName := EngSym[Param1]) : 0)
, K.Prefix := K.PLCtrl K.PRCtrl K.PLAlt K.PRAlt K.PLShift K.PRShift K.PLWin K.PRWin K.PCtrl K.PAlt K.PShift K.PWin)
Hotkey_Controls("ValueFromName", Hotkey_Name(ControlHandle), K.Prefix Hotkey)
Hotkey_Controls("Value", ControlHandle, K.Prefix Hotkey)
K.Mods := K.MLCtrl K.MRCtrl K.MLAlt K.MRAlt K.MLShift K.MRShift K.MLWin K.MRWin K.MCtrl K.MAlt K.MShift K.MWin
Text := K.Mods KeyName = "" ? Hotkey_Arr("Empty") : K.Mods KeyName
SendMessage, 0xC, 0, &Text, , ahk_id %ControlHandle%
Return 1
Hotkey_PressName:
KeyName := Hotkey := A_ThisHotkey, OnlyMods := 0
K.Prefix := K.PLCtrl K.PRCtrl K.PLAlt K.PRAlt K.PLShift K.PRShift K.PLWin K.PRWin K.PCtrl K.PAlt K.PShift K.PWin
Hotkey_Controls("ValueFromName", Hotkey_Name(ControlHandle), K.Prefix Hotkey)
Hotkey_Controls("Value", ControlHandle, K.Prefix Hotkey)
K.Mods := K.MLCtrl K.MRCtrl K.MLAlt K.MRAlt K.MLShift K.MRShift K.MLWin K.MRWin K.MCtrl K.MAlt K.MShift K.MWin
Text := K.Mods KeyName
SendMessage, 0xC, 0, &Text, , ahk_id %ControlHandle%
Return
}
Hotkey_LowLevelKeyboardProc(nCode, wParam, lParam) {
Static Mods := {"vkA4":"LAlt","vkA5":"RAlt","vkA2":"LCtrl","vkA3":"RCtrl"
,"vkA0":"LShift","vkA1":"RShift","vk5B":"LWin","vk5C":"RWin"}
, oMem := [], HEAP_ZERO_MEMORY := 0x8, Size := 16, hHeap := DllCall("GetProcessHeap", "Ptr")
Local pHeap, Wp, Lp, Ext, VK, SC, IsMod
Critical
If !Hotkey_Arr("Hook")
Return DllCall("CallNextHookEx", "Ptr", 0, "Int", nCode, "UInt", wParam, "UInt", lParam)
pHeap := DllCall("HeapAlloc", "Ptr", hHeap, "UInt", HEAP_ZERO_MEMORY, "Ptr", Size, "Ptr")
DllCall("RtlMoveMemory", "Ptr", pHeap, "Ptr", lParam, "Ptr", Size), oMem.Push([wParam, pHeap])
SetTimer, Hotkey_LLKPWork, -10
Return nCode < 0 ? DllCall("CallNextHookEx", "Ptr", 0, "Int", nCode, "UInt", wParam, "UInt", lParam) : 1
Hotkey_LLKPWork:
While (oMem[1] != "")
{
IF Hotkey_Arr("Hook")
{
Wp := oMem[1][1], Lp := oMem[1][2]
VK := Format("vk{:X}", NumGet(Lp + 0, "UInt"))
Ext := NumGet(Lp + 0, 8, "UInt")
SC := Format("sc{:X}", (Ext & 1) << 8 | NumGet(Lp + 0, 4, "UInt"))
If !Hotkey_Arr("SingleKey")
IsMod := Mods[VK]
If (Wp = 0x100 || Wp = 0x104) ; WM_KEYDOWN := 0x100, WM_SYSKEYDOWN := 0x104
IsMod ? Hotkey_Main("Mod", IsMod) : Hotkey_Main(VK, SC)
Else IF ((Wp = 0x101 || Wp = 0x105) && VK != "vk5D") ; WM_KEYUP := 0x101, WM_SYSKEYUP := 0x105, AppsKey = "vk5D"
IsMod ? Hotkey_Main("ModUp", IsMod) : 0
}
DllCall("HeapFree", "Ptr", hHeap, "UInt", 0, "Ptr", Lp)
oMem.RemoveAt(1)
}
Return
}
Hotkey_Option(Options) {
Local S_FormatInteger, MouseKey
#IF Hotkey_Arr("Hook")
#IF Hotkey_Arr("Hook") && !Hotkey_Main("GetMod")
#IF Hotkey_Arr("Hook") && (Hotkey_GetKeyState("RButton") || Hotkey_Main("GetMod"))
#IF Hotkey_Arr("Hook") && Hotkey_GetKeyState("RButton")
#IF
IfInString, Options, M
{
MouseKey := "MButton|WheelDown|WheelUp|WheelRight|WheelLeft|XButton1|XButton2"
Hotkey, IF, Hotkey_Arr("Hook")
Loop, Parse, MouseKey, |
Hotkey, %A_LoopField%, Hotkey_PressName
}
IfInString, Options, L
{
IfInString, Options, S
Hotkey, IF, Hotkey_Arr("Hook") && Hotkey_GetKeyState("RButton")
Else
Hotkey, IF, Hotkey_Arr("Hook") && (Hotkey_GetKeyState("RButton") || Hotkey_Main("GetMod"))
Hotkey, LButton, Hotkey_PressName
}
IfInString, Options, R
{
Hotkey, IF, Hotkey_Arr("Hook")
Hotkey, RButton, Hotkey_PressName
Hotkey_Arr("SetRButton", 1)
}
IfInString, Options, J
{
S_FormatInteger := A_FormatInteger
SetFormat, IntegerFast, D
Hotkey, IF, Hotkey_Arr("Hook") && !Hotkey_Main("GetMod")
Loop, 128
Hotkey % Ceil(A_Index/32) "Joy" Mod(A_Index-1,32)+1, Hotkey_PressName
SetFormat, IntegerFast, %S_FormatInteger%
}
IfInString, Options, S
Hotkey_Arr("SingleKey", 1)
IfInString, Options, H
Hotkey_Arr("LRMods", 1)
IfInString, Options, E
Hotkey_Arr("OnlyEngSym", 1)
Hotkey, IF
}
Hotkey_RButton() {
#IF Hotkey_IsRegControl()
#IF
Hotkey, IF, Hotkey_IsRegControl()
Hotkey, RButton Up, Hotkey_RButton
Hotkey, IF
Return
Hotkey_RButton:
Return
}
Hotkey_GetKeyState(Button) {
Return GetKeyState(Button, "P")
}
Hotkey_IsRegControl() {
Local Control
MouseGetPos,,,, Control, 2
Return Hotkey_Name(Control) != ""
}
Hotkey_IsRegFocus() {
Local ControlNN, hFocus
WinExist("A")
ControlGetFocus, ControlNN
ControlGet, hFocus, Hwnd, , %ControlNN%
Hotkey_Name(hFocus) != "" ? Hotkey_Arr("Hook", 1) : 0
}
Hotkey_WinEvent(hWinEventHook, event, hwnd) {
Hotkey_Name(hwnd) != "" ? Hotkey_Main("Control", hwnd) : Hotkey_Main("Control")
}
Hotkey_SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags) {
Return DllCall("SetWinEventHook" , "UInt", eventMin, "UInt", eventMax, "Ptr", hmodWinEventProc
, "Ptr", lpfnWinEventProc, "UInt", idProcess, "UInt", idThread, "UInt", dwFlags, "Ptr")
}
Hotkey_SetWindowsHookEx() {
Return DllCall("SetWindowsHookEx" . (A_IsUnicode ? "W" : "A")
, "Int", 13 ; WH_KEYBOARD_LL := 13
, "Ptr", RegisterCallback("Hotkey_LowLevelKeyboardProc", "Fast")
, "Ptr", DllCall("GetModuleHandle", "UInt", 0, "Ptr")
, "UInt", 0, "Ptr")
}
Hotkey_Exit() {
DllCall("UnhookWindowsHookEx", "Ptr", Hotkey_Arr("hHook"))
}
; -------------------------------------- Save and get variables --------------------------------------
Hotkey_Arr(P*) {
Static Arr := {Empty:"Нет"}
Return P.MaxIndex() = 1 ? Arr[P[1]] : (Arr[P[1]] := P[2])
}
Hotkey_Controls(Type, P*) {
Static ArrName := [], ArrValue := [], ArrValueFromName := {}, ArrHwndFromName := []
Return P.MaxIndex() = 1 ? Arr%Type%[P[1]] : (Arr%Type%[P[1]] := P[2])
}
Hotkey_Name(Hwnd) {
Return Hotkey_Controls("Name", Hwnd)
}
Hotkey_Value(Hwnd) {
Return Hotkey_Controls("Value", Hwnd)
}
Hotkey_ValueFromName(Name) {
Return Hotkey_Controls("ValueFromName", Name)
}
Hotkey_HwndFromName(Name) {
Return Hotkey_Controls("HwndFromName", Name)
}
Hotkey_IniPath(Path = "") {
Return Path = "" ? Hotkey_Arr("IniPath") : Hotkey_Arr("IniPath", Path)
}
Hotkey_IniSection(Section = "") {
Return Section = "" ? Hotkey_Arr("IniSection") : Hotkey_Arr("IniSection", Section)
}
Hotkey_Set(Name, Value="") {
Hotkey_Controls("ValueFromName", Name, Value)
Return Hotkey_HKToStr(Value)
}
Hotkey_IniWrite(Hwnd, Section = "", FilePath = "") {
IniWrite, % Hotkey_Value(Hwnd), % FilePath = "" ? Hotkey_IniPath() : FilePath, % Section = "" ? Hotkey_IniSection() : Section, % Hotkey_Name(Hwnd)
}
; -------------------------------------- Read and format --------------------------------------
Hotkey_Read(Key, Section = "", FilePath = "") {
Local Data
IniRead, Data, % FilePath = "" ? Hotkey_IniPath() : FilePath, % Section = "" ? Hotkey_IniSection() : Section, % Key, % A_Space
Return Hotkey_HKToStr(Data), Hotkey_Controls("ValueFromName", Key, Data)
}
Hotkey_IniRead(Key, Section = "", FilePath = "") {
Local Data
IniRead, Data, % FilePath = "" ? Hotkey_IniPath() : FilePath, % Section = "" ? Hotkey_IniSection() : Section, % Key, % A_Space
Return Data
}
Hotkey_HKToStr(Key) {
Static LRPrefix := [["<^","LCtrl"],[">^","RCtrl"],["<!","LAlt"],[">!","RAlt"]
,["<+","LShift"],[">+","RShift"],["<#","LWin"],[">#","RWin"]]
, Prefix := [["^","Ctrl"],["!","Alt"],["+","Shift"],["#","Win"]]
, EngSym := {"vkBB":"=","vkBC":",","vkBD":"-","vkBE":".","vkBF":"/","vkC0":"``","vkBA":"`;"
,"vkDB":"[","vkDC":"\","vkDD":"]","vkDE":"'","vk41":"A","vk42":"B","vk43":"C"
,"vk44":"D","vk45":"E","vk46":"F","vk47":"G","vk48":"H","vk49":"I","vk4A":"J"
,"vk4B":"K","vk4C":"L","vk4D":"M","vk4E":"N","vk4F":"O","vk50":"P","vk51":"Q"
,"vk52":"R","vk53":"S","vk54":"T","vk55":"U","vk56":"V","vk57":"W","vk58":"X"
,"vk59":"Y","vk5A":"Z"}
Local K, K1, K2, I, V, M, R
RegExMatch(Key, "S)^([\^\+!#<>]*)\{?(.*?)}?$", K)
If (K2 = "")
Return "" Hotkey_Arr("Empty")
If K2 ~= "^vk"
K2 := K2 = "vkBF" ? "/" : (Hotkey_Arr("OnlyEngSym") && EngSym.HasKey(K2) ? EngSym[K2] : Format("{:U}", GetKeyName(K2)))
If (K1 != "")
For I, V in K1 ~= "[<>]" ? LRPrefix : Prefix
K1 := RegExReplace(K1, "\Q" V[1] "\E", "", R)
, R ? (M .= V[2] "+") : 0
Return M . K2
}
Hotkey_HKToSend(Key, Section = "", FilePath = "") {
Static LRPrefix := [["<^","LCtrl"],[">^","RCtrl"],["<!","LAlt"],[">!","RAlt"]
,["<+","LShift"],[">+","RShift"],["<#","LWin"],[">#","RWin"]]
, Prefix := [["^","LCtrl"],["!","LAlt"],["+","LShift"],["#","LWin"]]
Local K, K1, K2, I, V, M1, M2, R
If (Section != "")
IniRead, Key, % FilePath = "" ? Hotkey_IniPath() : FilePath, % Section = "" ? Hotkey_IniSection() : Section, % Key, % A_Space
If (Key = "")
Return
RegExMatch(Key, "S)^([\^\+!#<>]*)\{?(.*?)}?$", K)
If (K1 != "")
For I, V in K1 ~= "[<>]" ? LRPrefix : Prefix
K1 := RegExReplace(K1, "\Q" V[1] "\E", "", R)
, R ? (M1 .= "{" V[2] " Down}", M2 .= "{" V[2] " Up}") : 0
Return M1 . "{" K2 "}" . M2
}