Сварганил интерфейс с настройками:
#SingleInstance Force ;16.05.2021 http://forum.script-coding.com/viewtopic.php?id=16354
#NoEnv
SetBatchLines -1
;-----------
Global Info, Info := {}
;-----------
Gui +Caption +LastFound +SysMenu +ToolWindow +AlwaysOnTop
Gui Color, 0x997799
Gui Add, Button, vBT gSW x115 y40 w70 h23, Запуск
Gui Add, Edit, vKeys x64 y8 w120 h21, Все
Gui Add, Text, x8 y8 w50 h23 +0x200, Клавиши:
Gui Add, Edit, vDelay x72 y40 w40 h21 +Number, 2000
Gui Add, Text, x8 y40 w55 h23, Задержка:
Gui Show, w191 h66, [Авто-нажатие клавиш]
Return
;-----------
GuiEscape:
GuiClose:
ExitApp
;-----------
SW:
Gui, Submit, NoHide
If (SW := !SW){
Info["Delay"] := Delay
Hook := InputHook("V")
If (Keys = "Все")
Keys = {All}
Hook.KeyOpt(Keys, "N")
Hook.OnKeyDown := Func("OnKeyDown")
Hook.OnKeyUp := Func("OnKeyUp")
Hook.Start()
GuiControl,, BT, Стоп
GuiControl, Disable, Keys
GuiControl, Disable, Delay
}
Else{
Hook.Stop()
GuiControl,, BT, Запуск
GuiControl, Enable, Keys
GuiControl, Enable, Delay
}
Return
;-----------
OnKeyDown(Hook, vk, sc) {
if !Info[vk . sc]
Info[vk . sc] := A_TickCount
else if (!Info.timer && A_TickCount - Info[vk . sc] > Info.delay) {
Timer := Info.timer := Func("SendKey").Bind( Format("vk{:x}sc{:x}", vk, sc) )
SetTimer, % Timer, 30
SoundBeep
}
}
OnKeyUp(Hook, vk, sc) {
if !Info.timer
Info[vk . sc] := ""
else {
if !Info.once
Info.once := true
else {
Timer := Info.timer
SetTimer, % Timer, Delete
Info[vk . sc] := Info.once := Info.timer := ""
Sleep, 30
Send % "{" . Format("vk{:x}sc{:x}", vk, sc) . " Up}"
}
}
}
SendKey(key){
Send {%key% Down}
}
;-----------
F4:: ExitApp
F6:: Reload
Win10x64, AHK v1.1.37.01 (Unicode 64-bit) |
AHK-Wiki |
Переменные и выражения |
RegEx101