Comments (8)
Sorry for not seeing your comment in #1. It seems that the notification mail was sent when I was absent.
According to my test, it is caused by keyboard hook. #IfWinActive will make AHK to install keyboard hook. And when keyboard hook turned on, KeyWait will ignore non-physically releasing and pressing. If you use #InstallKeybdHook instead, you will get the same result.
I'm now finding a way to solve this.
from iblogisoftext.
Luckily, I found that AHK has an internal flag to consider the key to be physical. And using it solves this bug on my computer.
Please test it: winmm.zip
from iblogisoftext.
By the way, I also found the code won't work when you open the script's main window. But it's the same when you use others keys (such as F12) rather than G-keys. Perhaps it's a feature or bug of AHK.
from iblogisoftext.
Luckily, I found that AHK has an internal flag to consider the key to be physical. And using it solves this bug on my computer.
Please test it: winmm.zip
Thanks for your reply, new winmm.dll
works, and I can catch long-press, double click, etc., however, combined hotkey cannot work, the hotkeys are not triggered:
A. ok:
vkC5
, ^vkC5
, !vkC5
, +vkC5
, #vkC5
,
+^#!vkC5
B. failed:
Ctrl & vkC5
, LCtrl & vkC5
, RCtrl & vkC5
,
Alt & vkC5
, LAlt & vkC5
, RAlt & vkC5
,
Shift & vkC5
, LShift & vkC5
, RShift & vkC5
,
LWin & vkC5
,
~vkC5
,
$vkC5
,
*vkC5
,
CapsLock & vkC5
,
*^vkC5
,
*!vkC5
,
*+vkC5
,
*#vkC5
~CapsLock & vkC5
,
from iblogisoftext.
Thanks for your test. I noticed the combination hotkeys don't work yesterday, but I didn't find the reason. Then I decided to use Logitech's driver to send keys. This method can not only solve the problem of AHK, but also can be used to enhance AHK's game operation ability (as Logitech's driver is both low-level and official).
from iblogisoftext.
I'm now working on it with my friend. It may be basically finished today or tomorrow.
from iblogisoftext.
Oh...I've just read AHK's source code again, and found that in fact this bug can be fixed by changing your code.
Just add 'L' after every KeyWait, so that it won't check the key's physical state, but logical. In this way, you can still use v0.3 and be able to detect double-presses and define custom combination hotkeys. And here's the code:
Ctrl & vkC6::ToolTip, Ctrl+G6
vkC6 & vkC9::ToolTip, G6+G9
vkC9 & vkC6::ToolTip, G9+G6
; Another way:
/*
#if GetKeyState("vkC9") ; No "P"
vkC6::ToolTip, G9+G6
#if
*/
vkC7::
p := Morse(300)
If (p = "0")
ToolTip, Short press
Else If (p = "00")
ToolTip, Double short presses
Else If (p = "000")
ToolTip, Triple short presses
Else If (p = "0000")
ToolTip, Quadruple short presses
Else If (p = "01")
ToolTip, Short+Long press
Else If (p = "1")
ToolTip, Long press
Else
ToolTip, Press pattern %p%
Sleep 500
ToolTip ; Turn off the tip.
Return
;#InstallKeybdHook
#IfWinActive ahk_exe notepad.exe
vkC7::
tooltip, OK
return
#IfWinActive
^#r::
Reload ; Assign Ctrl-Alt-R as a hotkey to restart the script.
Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
IfMsgBox, Yes, Edit
Return
Morse(timeout = 400) {
tout := timeout/1000
key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
Loop {
t := A_TickCount
KeyWait %key%,L ; Must "L"
Pattern .= A_TickCount - t > timeout
KeyWait %key%,DLT%tout%
If (ErrorLevel)
Return Pattern
}
}
from iblogisoftext.
I just notice the L shows in KeyWait %key%,DLT%tout%
and now it perfectly works, thank you!!
from iblogisoftext.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iblogisoftext.