Thinkpad键盘是非常好用的一款键盘,体验和传统的Thinkpad笔记本键盘一样,而且还支持小红帽(Trackpoint,指点杆)。
小红帽在使用上双手不需要离开键盘,甚至不用移动手掌位置就可以控制鼠标,比起触摸板和普通鼠标来说,使用效率提高得非常多,而且不容易累和不容易鼠标手。小红帽中键上下滚屏功能更是方便至极。
不过Thinkpad USB键盘上面的小红帽,有个很大的问题:部分程序不能支持中键上下滚屏,尤其是基于Java的桌面程序,像Netbeans,Evennote等等。
之前找了非常多的方法,替换了几次官网上的驱动程序,而且国外的许多网站有很多人提出此问题,不过看情况官方是没兴趣解决这个问题。所以只能避免使用不支持的软件,也放弃了许多优秀的软件。
今天在研究idea软件的时候,意外找到了最好的解决方法,用AutoHotkey将小红帽的鼠标中键映射成滚屏。 原文出自这里。
AutoHotkey的使用可以Google一下,是功能极其强大的自动化操作辅助软件。
Autohotkey可以支持直接将脚本转换成exe,让不安装Autohotkey的电脑也可以用其功能,
这里我的将小红帽鼠标中键滚动的脚本做成了exe供下载:32位,64位
下载后直接运行就可以成功让小红帽支持中键滚屏。
以下是让Thinkpad USB键盘支持小红帽中键滚轮的Autohotkey脚本:
;;
;; Trackpoint.ahk
;; Author: Chiyuan Zhang <pluskid@gmail.com>
;; Version: 1.0 (Sep. 03, 2009)
;;
;; Thinkpad trackpoint driver on Windows doesn't allow
;; to use both middle-click and scrolling simultaneously.
;; If you enable the scrolling, you'll not be able to
;; click the middle button (e.g. to open a link in the
;; background in Firefox).
;;
;; However, on Linux, one can get a good behavior where
;; both middle-click and scrolling behaves well (see
;; www.thinkwiki.org/wiki/How_to_configure_the_TrackPoint).
;;
;; This script trys to make it behave similarly. When you
;; press the middle button and release in a short time, it
;; will be a regular middle-click. However, if you hold it
;; and move the cursor, it will do scrolling.
;;
;; Configuration
;#NoTrayIcon
; Milliseconds threshold, hold the middle button for some time
; exceeding this will start to detect scrolling.
tp_StartScrollTThreshold = 70
; Pixels threshold, for both X and Y. Only when the mouse movement
; exceed this threshold will we start scrolling.
tp_StartScrollXThreshold = 7
tp_StartScrollYThreshold = 4
; Milliseconds interval to check further scrolling. Set this to a
; smaller value will make scrolling more fast, and vice versa.
tp_ScrollCheckInterval = 45
;; This key/Button activates scrolling
tp_TriggerKey = MButton
;; End of configuration
#Persistent
CoordMode, Mouse, Screen
Hotkey, %tp_TriggerKey%, tp_TriggerKeyDown
HotKey, %tp_TriggerKey% Up, tp_TriggerKeyUp
return
tp_TriggerKeyDown:
tp_Scroll = n
MouseGetPos, tp_OrigX, tp_OrigY
SetTimer, tp_CheckForScrollEventAndExecute, %tp_StartScrollTThreshold%
return
tp_TriggerKeyUp:
SetTimer, tp_CheckForScrollEventAndExecute, Off
;; Send a middle-click if we did not scroll
if tp_Scroll = n
MouseClick, Middle
return
tp_CheckForScrollEventAndExecute:
tp_Scroll = y
SetTimer, tp_CheckForScrollEventAndExecute, %tp_ScrollCheckInterval%
MouseGetPos, tp_NewX, tp_NewY
tp_DistanceX := tp_NewX - tp_OrigX
tp_DistanceY := tp_NewY - tp_OrigY
if tp_DistanceY > %tp_StartScrollYThreshold%
MouseClick, WheelDown
else if tp_DistanceY < -%tp_StartScrollYThreshold%
MouseClick, WheelUp
; 0x114 is WM_HSCROLL
if tp_DistanceX > %tp_StartScrollXThreshold%
{
ControlGetFocus, FocusedControl, A
SendMessage, 0x114, 1, 0, %FocusedControl%, A
}
else if tp_DistanceX < -%tp_StartScrollXThreshold%
{
ControlGetFocus, FocusedControl, A
SendMessage, 0x114, 0, 0, %FocusedControl%, A
}
return