Last active
August 3, 2024 21:35
-
-
Save llinfeng/c09d6c1de0d0646dd2d11a5fa15382e1 to your computer and use it in GitHub Desktop.
AHK - scroll with middle-mouse-key + trackpoint for Thinkpad keyboards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Midbutton down for scrolling {{{ | |
; Feature: with acceleration as intended. | |
; Source: http://forum.notebookreview.com/threads/ultranav-middle-click-button-scroll.423415/ | |
; Linking source: https://superuser.com/questions/91074/thinkpad-trackpoint-scrolling-and-middle-click-possible | |
; Working version {{{ | |
$*MButton:: | |
Hotkey, $*MButton Up, MButtonup, off | |
KeyWait, MButton, T0.2 | |
If ErrorLevel = 1 | |
{ | |
Hotkey, $*MButton Up, MButtonup, on | |
MouseGetPos, ox, oy | |
SetTimer, WatchTheMouse, 5 | |
SystemCursor("Toggle") | |
} | |
Else | |
Send {MButton} | |
return | |
MButtonup: | |
Hotkey, $*MButton Up, MButtonup, off | |
SetTimer, WatchTheMouse, off | |
SystemCursor("Toggle") | |
return | |
WatchTheMouse: | |
MouseGetPos, nx, ny | |
dy := ny-oy | |
dx := nx-ox | |
If (dx**2 > 0 and dx**2>dy**2) ;edit 4 for sensitivity (changes sensitivity to movement) | |
{ | |
times := Abs(dy)/1 ;edit 1 for sensitivity (changes frequency of scroll signal) | |
Loop, %times% | |
{ | |
If (dx > 0) | |
Click WheelRight | |
Else | |
Click WheelLeft | |
} | |
} | |
If (dy**2 > 0 and dy**2>dx**2) ;edit 0 for sensitivity (changes sensitivity to movement) | |
{ | |
times := Abs(dy)/1 ;edit 1 for sensitivity (changes frequency of scroll signal) | |
Loop, %times% | |
{ | |
If (dy > 0) | |
Click WheelDown | |
Else | |
Click WheelUp | |
} | |
} | |
MouseMove ox, oy | |
return | |
SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others | |
{ | |
static AndMask, XorMask, $, h_cursor | |
,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors | |
, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors | |
, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors | |
if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call | |
{ | |
$ = h ; active default cursors | |
VarSetCapacity( h_cursor,4444, 1 ) | |
VarSetCapacity( AndMask, 32*4, 0xFF ) | |
VarSetCapacity( XorMask, 32*4, 0 ) | |
system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650 | |
StringSplit c, system_cursors, `, | |
Loop %c0% | |
{ | |
h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% ) | |
h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 ) | |
b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0 | |
, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask ) | |
} | |
} | |
if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T")) | |
$ = b ; use blank cursors | |
else | |
$ = h ; use the saved cursors | |
Loop %c0% | |
{ | |
h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 ) | |
DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% ) | |
} | |
} | |
; }}} | |
; }}} | |
@wanderseeme 上面的脚本也是从 source 抄来的,蓝牙键盘是支持的。下面是独立文件需要的“抬头”,放在最前面就好了。原贴该是也给出了需要添加的内容呀。
#InstallKeybdHook
#UseHook,On
#SingleInstance ; Allow only one instance of this script to be running.
#Persistent ; To stop the script from exiting.
大神,请问怎么修改,也能左右滚动?
@theheart2012 我试了下,左右滚动是支持的,至少在OneNote里面(用的是T480笔记本上的小红点)。
另,安利一波TEX Shinobi键盘,它左右上下的滚动都是支持的,也支持独立的中键点击
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
大神您好,我下载了ahk文件直接双击运行发现中键还是不能用,我的键盘是这一款ThinkPad Compact Bluetooth Keyboard with TrackPointhttps://support.lenovo.com/us/en/solutions/pd026744,请问这个AHK脚本支持吗?
看到您在帖子https://www.autohotkey.com/boards/viewtopic.php?t=74283里提到如果要放在单独文件里的话需要加几行代码,这几行该怎么加呢?您有没有可能提供纯独立的ahk文件呢?