Тема: AHK: Loop залип*
Здравствуйте, не подскажите в чем может быть проблема(?)
Есть вроде бы простой скрипт:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#UseHook
#NoEnv
#Persistent
#KeyHistory, 0
#HotKeyInterval -1
#MaxHotkeysPerInterval 200
#InstallKeybdHook
#SingleInstance, Force
SetKeyDelay, -1
SetMouseDelay, -1
#InstallMouseHook
SetBatchLines, -1
SetTimer, CheckKey, On
SetTimer, CheckKey, 1
*~LButton::
Loop ; Цикл
{
Sleep, 5
Send, {LButton}
moveAmount := (moveAmount = 2) ? 3 : 0
mouseXY(moveAmount,4.7)
GetKeyState, state, LButton, P
if state = U ; Клавиша отпущена, поэтому выйти из цикла.
break
}
mouseXY(x,y)
{
DllCall("mouse_event",int,1,int,x,int,y,uint,0,uint,0)
}
KeyWait, LButton
Return
Беда в том что при нажатие LButton ИНОГДА скрипт не выходит из циклы и думает что LButton до сих пор в статусе "Нажата". Хотя кнопка мыши уже давно отпущена.
Есть еще один код написанный за долго до первого и в нем данной проблемы вроде бы нет. Вот он:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoEnv
SendMode Input
~F5::Suspend
~End::ExitApp
*~LButton::
Loop ; Цикл
{
Sleep, 5
moveAmount := (moveAmount = 2) ? 3 : 0
mouseXY(moveAmount,4.5)
GetKeyState, state, LButton, P
if state = U ; Клавиша отпущена, поэтому выйти из цикла.
break
}
mouseXY(x,y)
{
DllCall("mouse_event",int,1,int,x,int,y,uint,0,uint,0)
}
Структура вроде одна, но второй/этот скрипт не залипает в цикле...
В первом коде SetTimer не помог решить данную проблему. Не подскажите может быть в первом коде что-то лишнее имеется(?)
Спасибо!