How to make Middle Click Continuous Scroll for Notepad++

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gopikrish2000
Posts: 3
Joined: 28 Nov 2013, 11:46

How to make Middle Click Continuous Scroll for Notepad++

Post by gopikrish2000 » 14 Dec 2013, 11:30

In Browsers when we do middle Click and without releasing move down ill scroll continuously the contents down with some pace. Is there a way I can implement that in other applications like notepad++, windows explorer etc .

User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by emmanuel d » 14 Dec 2013, 14:01

with a hotkey

Code: Select all

#IfWinActive,ahk_exe Notepad++.exe
mbutton::
a

Code: Select all

while GetKeyState(KeyName [, "P" or "T"])
and a

Code: Select all

sendinput
and a

Code: Select all

sleep
folow the links, learn, and post the results

gopikrish2000
Posts: 3
Joined: 28 Nov 2013, 11:46

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by gopikrish2000 » 15 Dec 2013, 06:55

Thanks , Scrolling is working perfectly fine , might not be as perfect as browser Continuous scroll though . One more thing i'm current doing paste for middle double click , so after this script paste is not working , Any idea how to detect middle double click in below code n do paste action instead ?

Code: Select all

#IfWinActive,ahk_exe Notepad++.exe
~mbutton::
MouseGetPos, orginalX, originalY 
while GetKeyState("MButton",[ "P" or "T"])
{
MouseGetPos, curX, curY 
if ( curY < originalY){
SendInput, {WheelUp 8}
} else {
SendInput, {WheelDown 8}
}
Sleep 200
}
#IfWinActive

User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by emmanuel d » 15 Dec 2013, 08:11

Something in the way of:

Code: Select all

if (A_ThisHotkey=A_PriorHotkey and A_TimeSincePriorHotkey>200)
    msgbox,doubleclicked
Ps it schould be

Code: Select all

while GetKeyState("MButton", "P")

User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by emmanuel d » 15 Dec 2013, 08:21

Untested, i have no midlebutton :lol:

Code: Select all

#IfWinActive,ahk_exe Notepad++.exe
~mbutton::
	if (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200) { ; if doubleclick
		SendInput,^v   ; paste
		Return    ; exit the sub
		}
	MouseGetPos, orginalX, originalY
	while GetKeyState("MButton","P") {
		MouseGetPos, curX, curY
		if ( curY < originalY)
			SendInput, {WheelUp 8}
		else SendInput, {WheelDown 8}
		Sleep 200
		}
	Return ; you need a return at the end a sub
#IfWinActive

Guest

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by Guest » 15 Jan 2015, 05:49

Hi,

I've modified gopikrish2000's script to include more fluid scrolling dependent on cursor vertical deviation from the point of initial middle-click position. Also, there is an image file (25x25 pixels) which shows up while middle button is pressed. The image file should be copied to the same folder as the script file, and is available at:

https://onedrive.live.com/redir?resid=C ... hoto%2cgif

The script looks like:

Code: Select all

#IfWinActive,ahk_exe Notepad++.exe
~mbutton::
CoordMode, Mouse, Screen
MouseGetPos, originalX, originalY, ActiveWin
imageX := originalX - 25
imageY := originalY - 50
SplashImage, image.gif
WinSet, TransColor, White, notepad++.ahk
WinSet, Region, 3-26 W25 H25, notepad++.ahk
WinMove, notepad++.ahk, , %imageX%, %imageY%
while GetKeyState("MButton", "P")
{
MouseGetPos, curX, curY 
if ( curY < originalY){
diffY := (originalY - curY) / 25
moveY := Round(diffY)
SendInput, {WheelUp %moveY%}
} else {
diffY := (curY - originalY) / 25
moveY := Round(diffY)
SendInput, {WheelDown %moveY%}
}
Sleep 50
}
SplashImage, Off
#IfWinActive
Please note that there are some hardcoded stuff in here, e.g. I named the script file "notepad++.ahk" and that's the window title which is matched in WinSet and WinMove commands. Furthermore, you might need to modify the region parameters in "WinSet, Region, 3-26 W25 H25, notepad++.ahk" line which clears off the image window borders.

Regards,
bperkic

Inserio

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by Inserio » 28 Oct 2015, 11:39

I hadn't seen yours, above, but I made one that's vastly different, yet allows for larger amounts of acceleration and a couple other benefits by using postmessage. This does mean you need the control that responds to mousewheel for the program, but if you have that then it's fine. By default it works for Notepad++ and WinFlex

I also put a tiny gui with a double arrow symbol about where you click (if you move it to under the exact mouse point then it doesn't work for some reason).

Code: Select all

#If WinActive("ahk_exe Notepad++.exe") ; Programs that respond to mouse wheel but not middle mouse button
~$mbutton::
#If WinActive("ahk_exe WinFlex6.exe") ; Programs that respond to middle button but you want more control
mbutton::
	Acceleration = 4
	SleepMod = 1
	
	MouseGetPos, originalX, originalY, point_id, point_control
	
	If WinActive("ahk_exe Notepad++.exe") ; Programs that respond to mouse wheel but not middle mouse button
		If (point_control != "Scintilla1")
			Exit
	Else If WinActive("ahk_exe WinFlex6.exe") ; Programs that respond to middle button but you want more control
		If (point_control != "Ter32Class1" || "SysTabControl321")
			Exit
		If (point_control == "SysTabControl321")
			point_control := "Ter32Class1" ; control that responds to mousewheel
			
	xGui := originalX - 31
	yGui := originalY - 22
	Gui -Caption +ToolWindow
	Gui, Add, Text,, ↕ ; alternate symbols - ⇕ , ↕ , ↨ , ♦ , ♢
	Gui, Show, NoActivate x%xGui% y%yGui%, New Title
	
	while GetKeyState("MButton","P") {
		MouseGetPos, curX, curY
		VertDifference := originalY - curY
		Movement := VertDifference
		LoopAmount := abs(Movement / (1000/Acceleration))
		If (LoopAmount < 1)
			LoopAmount = 1
		SleepTime := round(1 / abs(VertDifference * (1000/SleepMod)))
		If (abs(Movement) > 0)
			Loop %LoopAmount% {
				PostMessage 0x20A, Movement<<16, (originalY<<16)|originalX, %point_control%, ahk_id %point_id% ; shifts Movement 16bits and sends to control
			}
		If (SleepTime > 0)
			Sleep %SleepTime%
		Else
			Sleep 20
	}
	Gui, Destroy
Return
#If

mjklin

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by mjklin » 23 Jul 2016, 08:11

Inserio, this code works great!

One question: is there a way to modify it so that one click on the mouse button initiates scrolling, rather than continuous press?

Kyo
Posts: 1
Joined: 14 Jan 2023, 15:15
Contact:

Re: How to make Middle Click Continuous Scroll for Notepad++

Post by Kyo » 28 Jan 2023, 10:15

Inserio's script doesn't work on second monitor unlike Guest/bperkic's script. It would be great if someone modified the first one to work on multi-monitor setup.

Post Reply

Return to “Ask for Help (v1)”