My question is in the subject, how to accomplish that.
I will use this to navigate in flying (3D)
current setup: when character already move, to change direction is to move mouse cursor + hold press "a".
I want to automatic the hold press "a", so only move the cursor equal to change direction.
Mouse movement => send "a" hold press And mouse stop move => send release "a" press.
-
- Posts: 2
- Joined: 26 Jan 2024, 23:23
Re: Mouse movement => send "a" hold press And mouse stop move => send release "a" press.
Hallo,
try:
try:
Code: Select all
q Up:: ; ADown while Mouse movement (on/off)
ADown?(DllCall("UnhookWindowsHookEx", "Ptr", ADown), ADown := "")
:ADown := DllCall("SetWindowsHookEx", "UInt", 14, "Ptr"
, RegisterCallback("LowLevelMouseProc"), "Ptr", 0, "UInt", 0, "Ptr")
LowLevelMouseProc(nCode, wParam, lParam) {
If (wParam = 0x0200) { ; WM_MOUSEMOVE
SendEvent,% ["{Blind}{a Down}"][!GetKeyState("a")]
SetTimer, AUp, -50 ; release 50 ms after the last Mouse movement
}} AUp() {
SendEvent, {Blind}{a Up}
} Return
-
- Posts: 2
- Joined: 26 Jan 2024, 23:23
Re: Mouse movement => send "a" hold press And mouse stop move => send release "a" press.
Hi, thanks for the answer.
Tested it.
It partially working, need tweaking something.
But why it continous sending {a up} after toggle the hotkey off?
Tested it.
It partially working, need tweaking something.
But why it continous sending {a up} after toggle the hotkey off?
Re: Mouse movement => send "a" hold press And mouse stop move => send release "a" press.
Definitely not happens here!
With {a Down} and {a Up} Tooltips:
With {a Down} and {a Up} Tooltips:
Code: Select all
q Up:: ; ADown while Mouse movement (on/off)
ADown?(DllCall("UnhookWindowsHookEx", "Ptr", ADown), ADown := "")
:ADown := DllCall("SetWindowsHookEx", "UInt", 14, "Ptr"
, RegisterCallback("LowLevelMouseProc"), "Ptr", 0, "UInt", 0, "Ptr")
LowLevelMouseProc(nCode, wParam, lParam) {
If (wParam = 0x0200) { ; WM_MOUSEMOVE
SendEvent,% ["{Blind}{a Down}"][Now:=!GetKeyState("a")]
Now?ToolTip(A_TickCount ": {a Down}",100,100,1):""
SetTimer, AUp, -50 ; release 50 ms after the last Mouse movement
}} AUp() {
SendEvent, {Blind}{a Up}
ToolTip(A_TickCount ": {a Up}",100,130,2)
} Return
ToolTip(Text:="", X:="", Y:="", WhichToolTip:=1) {
ToolTip,% Text,% X,% Y,% WhichToolTip
}