Iris Classon
Iris Classon - In Love with Code

Horizontal scroll in Visual Studio (or other programs) with AutoHotKey

I was certain that there was a hotkey/keyboard shortcut for horizontal scrolling in VS, Shift + Scroll or Alt + Scroll, but I just can’t get that to work. However, while reading up on AHK I noticed a scroll example and decided to give it a try, and it worked. I had no idea (but I’m not surprised) we have this low level access abstracted in such a nice way with the SendMessage command. Brilliant, just brilliant.

So I don’t take credit for somebody else’s work, this script is found at the bottom of the hotkeys documentation, I’ve only refactored it slightly.

To use this, save in a text file with a .ahk extension after downloading AutoHotKey, and double click to run. Holding down Alt and scrolling gives you horizontal scroll without interfering with zoom or vertical scroll as you can see in the gif.

Kill the script from the task bar tray, or using your favorite command line tool or the task manager. The code I’m scrolling through is the AHK source code, I’m having fun reading it- it’s a good read.

[sourcecode language=“text”]’
~Alt & WheelUp::
scroll(0)
return

~Alt & WheelDown::
scroll(1)
return

scroll(direction)
{
SetTitleMatchMode, 2
ControlGetFocus, fcontrol, Visual Studio
Loop 5
SendMessage, 0x114, %direction%, 0, %fcontrol%, Visual Studio
}
[/sourcecode]

Comments

Leave a comment below, or by email.
Sergey Vlasov
2/26/2017 10:30:16 PM
Another option is to use the following two commands Scroll the current text editor horizontally for my Visual Commander extension and assign to them shortcuts like Ctrl+Right Arrow and Ctrl+Left Arrow. 


Last modified on 2015-02-17

comments powered by Disqus