You are on the right track. Does it work? If you write sample values of your variables, you can quickly determine what to change. Another approach is below, though it might not do what you want. The main difference between the scripts is in when the
V will be sent. The timer period here has been increased but might be too high or too low.
Code: Select all
#Requires AutoHotkey v1.1.33
#InstallMouseHook
idleReset := 400
minDist := 10
SetTimer Check, 100
Check:
CoordMode Mouse
last := y
MouseGetPos,, y
Switch
{
Case last = "": Return
Case A_TimeIdleMouse > idleReset: last := key := ""
Case y < last: key := "c" ; Moving up
Case y > last: key := "x" ; Moving down
}
Return
#If key
v::Send % Abs(y - last) < minDist ? "" : key
#If
You now know how to edit your script and test the revision. Enjoy!
As you test, you can consider the following contributors to the results.
- The timer period
- The previous y-value
- The current y-value
- The value of "key"
- Conditions that change the value of "key"
- Conditions that change whether the hotkey is triggered
There are various ways to learn these things. You can display values. You can use AHK to list or examine the values. You can use a debugging tool. You can also create your own simulated scenarios to see what would happen in each of them.
Another approach is writing all of the rules in your own (plain) language. You would then translate the rules into AHK code. The main barrier to your success so far has been that you have not decided what you want the rules to be. Nonetheless, you are the person to define them.