I am glad to hear it. Your script had the right idea. I did reproduce the problem that you experienced. My hunch is that, as AHK was rapidly managing all of the
Shift up & down sequences with every scroll of the wheel-- and doing it multiple times in quick succession-- there are some imperfections there at times, in what the system is able to handle, and how quickly. If you look at the
KeyHistory, it may shed light on this in some instances. This may not be an AHK issue as much as a system issue, though I am uncertain (others here know more). In some cases, using SendInput or text mode can "improve reliability", though this term is a bit vague. The documentation contains some explanations about how they may help reliability or avoid interruptions in sequences. I do not recall whether I tried SendInput with your script. The wheel is perhaps unique in that it can generate such a large number of manually triggered events very quickly; this may have created some of the challenge with the intermingled
Shift sequences. Thus, one or two "clicks" of the wheel are not a problem, but 10 or 20 via one prolonged spin might yield the problem. That's just a guess, as I did not study the issue very carefully.
The issue of the "stuck modifier" is well known and reported by multiple users. It is said to be caused by conflicting software. Again in your case, this issue may be exacerbated by use of the wheel in some way. In some instances, sending the modifier key up (e.g.,
Send {Shift up}) at some point
might help. I successfully use that approach myself, but it does not seem to work in all situations. I have never discovered what software on my system conflicts with AHK, so I just deal with the occasional issues by having a "KBreset" script that does these things upon triggering a hotkey.
In terms of "neat":
1. If your hotkey subroutine has one command, or something that can be written on one line, you can put it on the same line as the hotkey. It will have an implicit Return.
2. You can stack hotkeys as shown. Each hotkey in the stack will execute the routine at the bottom of the stack.
As your script shows, these techniques are not required. They mostly serve to condense the script. In some cases, they are a convenience that can avoid duplications in code and so also sometimes decrease the risk of a bug, or increase the ease of modifying the script.