Script for scrolling without loosing the middle button click

Performance, hardware, software, general buying and gaming discussion..
Post Reply
Message
Author
jhonyl
Sophomore Member
Posts: 171
Joined: Sun Feb 27, 2005 9:13 pm

Script for scrolling without loosing the middle button click

#1 Post by jhonyl » Tue Nov 01, 2005 1:28 pm

Hi,

I have just made a script for scrolling without loosing the middle button clickability. I did it using AutoHotKey. If you want to try it set the middle button from scrolling to "Neither" in the control panel->Mouse->UltraNav->TrackPoint Setting, and just download AutoHotKey, and put this (embarrassing code :oops: ) into the AutoHotKey.ini file:

Code: Select all

~MButton::
XSum:=0
YSum:=0
XThreshOld:=1
YThreshOld:=1
MouseGetPos, OldX, OldY, WinID
MouseGetPos, X, Y, WinID
MButtonState= D
Loop
{
	
	;MsgBox, Move the mouse.
	MouseGetPos, X, Y, WinID
	XSum:= XSum + X - OldX
	YSum:= YSum + Y - OldY
	
	;MsgBox, Iteration number is %A_Index% and MButton state is %MButtonState%. XSum= %XSum% YSum= %

YSum%  X= %X% Y=%Y% OldX=%OldX% OldY=%OldY%

	if (XSum > XThreshOld)
	{
		Send, {Right}
		XSum:= 0
	}
	else if (XSum < -XThreshOld)
	{
		Send, {Left}
		XSum:= 0
	}	
	if ( -YSum > YThreshOld )
	{
		NTimes:=1
		if (-YSum > 5)   
		NTimes := (-YSum - 5)/2 
		Loop, %NTimes%
			Send, {WheelUp}
		
		YSum:= 0
	}
	else if ( -YSum < -YThreshOld )
	{
		NTimes:=1
		if (YSum > 5)   
			NTimes := (YSum -5)/2
		Loop, %NTimes%
			Send, {WheelDown}
		YSum:= 0
	}
	MouseMove, %OldX%, %OldY%
	GetKeyState, MButtonState, MButton, P
	if (MButtonState = "U")
	 	break
	
	;sleep, 10
}
return
Edit:
Maybe the following two lines are important, I have them at the top of the file.

Code: Select all

#InstallKeybdHook
#InstallMouseHook
Some programs like Mozilla are scrolled good with it. Others like Acrobat don't. It seems that some programs need different scroll command posted at them like shown in this thread http://www.autohotkey.com/forum/viewtopic.php?t=5903 .I will modify the script accordingly.
T42 2378FVU Pentium M 735(1.7Ghz), 768MB, 14.1" SXGA+, 40GB, ATI Mobility Radeon 9600

sub_ubi
Posts: 2
Joined: Fri Dec 30, 2005 2:34 am

#2 Post by sub_ubi » Fri Dec 30, 2005 3:18 am

This is exactly what I came here for, thank you so much!

Paul Unger
Senior Member
Senior Member
Posts: 551
Joined: Mon Jun 14, 2004 8:18 am
Location: Solomon Islands / Canada

#3 Post by Paul Unger » Fri Dec 30, 2005 5:05 am

Would this work for the OpenOffice family of programs? I kind of enjoy the OOo stuff, but it bugs me that I can't use 'middle button scrolling' in them . . .

jhonyl
Sophomore Member
Posts: 171
Joined: Sun Feb 27, 2005 9:13 pm

#4 Post by jhonyl » Wed Feb 01, 2006 2:01 pm

sub_ubi wrote:This is exactly what I came here for, thank you so much!
I am glad you liked it. Here is a little update: On Microsoft programs, for some odd reason, pressing the middle button opens an application that scroll by draging the mouse. This interfere a little with that script. I looked how to disable that program, but I didn't find yet how to disable it. But I did find a modification to that script that helps a bit in that case.

Code: Select all

;Add a $ to MButton:: on the top:

$MButton::

;Right after this line, I have added the following line
CoordMode, Mouse , Screen
;Though this is optional, since it is not related to this problem.


;and add these lines before the return at the end:

MouseClick, Middle      , %OldX%, %OldY%,  1, 0, D, 
MouseClick, Middle      , %OldX%, %OldY%,  1, 0, U, 
MouseClick, Left      , %OldX%, %OldY%,  1, 0, U, 
return
Paul - I don't have OpenOffice installed yet, so I can't tell if this exact script would work, but - If keys on the keyboard, like for example left, right, up and down, or some other keys combinations are able to scroll in OpenOffice, then it is possible to send via similar script the same keys, and to scroll. It is also possible if OpenOffice behaves in a different way then other apps, to take one action if the current application is OpenOffice, and an other if it is an other app.

PS
T42 2378FVU Pentium M 735(1.7Ghz), 768MB, 14.1" SXGA+, 40GB, ATI Mobility Radeon 9600

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Thinkpad - General HARDWARE/SOFTWARE questions”

Who is online

Users browsing this forum: No registered users and 2 guests