I have created two simple Autohotkey scripts.
The first one lets me scroll by moving the mouse while the middle mouse button is held down. This is very useful on my TrackPoint-enabled laptop:
MyScroll:
MouseGetPos, xnew, ynew
If ((xold<>xnew) or (yold<>ynew)) {
MouseMove, xold, yold
}
if (ynew>yold) {
Send {WheelDown}
}
if (ynew<yold) {
Send {WheelUp}
}
if (xnew>xold) {
Send {WheelRight}
}
if (xnew<xold) {
Send {WheelLeft}
}
return
MButton::
MouseGetPos, xold, yold
settimer, MyScroll, 20
return
MButton Up::settimer, MyScroll, off
The second script reassigns a lot of keys while the middle mouse button is held down. This gives me access to auxillary keys such as arrows without having to move my wrists and then search for the home row keys:
#if GetKeyState("MButton", "P")
j::Left
+j::+Left
^j::^Left
+^j::+^Left
!j::!Left
!^j::!^Left
!+j::!+Left
!^+j::!^+Left
k::Down
+k::+Down
^k::^Down
+^k::+^Down
!k::!Down
!^k::!^Down
!+k::!+Down
!^+k::!^+Down
; ...
These two scripts work really well separately, they do exactly what I need.
But when I put both into the same script, something really weird happens. Typically, they work fine for a short while, but then:
- The mouse is stuck in scroll mode. In order to recover from this, I need to press and release the middle mouse button.
- The taskbar freezes.
- Sometimes it can be solved by reloading the Autohotkey script (which is hard to do when the icon in the system tray is inaccessible).
- Sometimes killing Autohotkey helps.
- Sometimes killing Explorer helps.
- Sometimes nothing helps, and the only way to recover from frozen taskbar is to reboot. 🙁
This happens quite often, typically multipe times per hour.
Please help me figure out why the two scripts don’t work together and how to prevent the issue.
PS Here’s the header of my script file:
#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.
Here’s full script file: https://gist.github.com/lolmaus/a2fde78040e2451411178061816b5882