Horizontal scrolling shortcut in Windows

65

9

In Os X, I can hold Shift while using the scroll wheel on the mouse to scroll horizontally instead of vertically. Is there a way to do something similar in Windows?

Matthew Shanley

Posted 2009-07-27T16:24:40.250

Reputation: 883

1scrolling in what application? explorer? a web browser? It's dependent on how the creator wanted to implement it so if it's a browser it will be different. – John T – 2009-07-27T16:31:00.940

12I was hoping for a system-wide solution. – Matthew Shanley – 2009-07-27T17:15:26.857

I don't think there's a system-wide shortcut for that on windows by default. – chills42 – 2009-07-27T16:32:18.550

Answers

16

You could simulate it with AutoHotKey

If I find the script I'll let you know: From these posts:

You should find some scripts

#Persistent mhook := > DllCall("SetWindowsHookEx", "int", 14 > ; WH_MOUSE_LL
    , "uint", RegisterCallback("WheelHorzHook"), > "uint", 0, "uint", 0) return

WheelLeft:
    MsgBox WheelLeft return

WheelRight:
    MsgBox WheelRight return

WheelHorzHook(nCode, wParam, lParam) {
    global mhook
    Critical
    if (wParam = 0x020E)  ; WM_MOUSEHWHEEL (Vista-only)
    {
        if (delta := NumGet(lParam+0,10,"Short"))
        {
            if (delta<0) {
                SetTimer, WheelLeft, -1
                return true
            } else {
                SetTimer, WheelRight, -1
                return true
            }
        }
    }
    return DllCall("CallNextHookEx", "uint", mhook, "int", nCode, "uint",
wParam, "uint", lParam) }

Ivo Flipse

Posted 2009-07-27T16:24:40.250

Reputation: 24 054

Ah you got it to work? Awesome! – Ivo Flipse – 2009-07-29T13:19:21.273

23

Here's an AutoHotKey script to do it using shift and (presumably) native mouse wheel scroll commands:

; Shift + Wheel for horizontal scrolling
+WheelDown::WheelRight
+WheelUp::WheelLeft

This is taken directly from https://gist.github.com/cheeaun/160999.

Keep in mind that a lot of applications, including Microsoft applications, don't support horizontal mouse wheel scrolling. (I believe the feature was only introduced in Windows Vista.)

Sam

Posted 2009-07-27T16:24:40.250

Reputation: 1 171

2

Perfect! This is the best answer here, simple and easy.

For those who are new to AutoHotKey, here are the steps:

  1. Download and install AutoHotKey from http://www.autohotkey.com/
  2. Right click on your desktop -> New -> Text Document -> Make a file called "myscript.ahk"
  3. Copy-paste the script from the above -> Save the file
  4. Right-click on the file -> Run Script
  5. Small H-icon should appear to your taskbar notification area, and now "Shift+Mouse Wheel" should produce horizontal scrolling
– np8 – 2014-10-13T11:57:55.463

@np8 it didn't work for me.. i tried exactly as that. i am using a normal hp mouse with scroll wheel. chrome browser works shift + scroll horizontally.. it always did even before ahk. now with ahk install.. i was hoping ms office will work.. but it doesn't. – ihightower – 2019-02-05T05:27:37.583

@ihightower There is a solution for the Excel, too. I will add it to this answer. – np8 – 2019-02-05T09:51:09.717

@np8 hi have you found the solution for excel.. is it added? it is important that horizontal scrolling can work across all applications if possible. – ihightower – 2019-11-06T10:17:24.487

@ihightower Perhaps the Feb 2019 addition did not pass the peer review process. I try to have it accepted again. – np8 – 2019-11-06T12:35:47.167

@ihightower Nope, it did not go though peer review this time, either. Added my own answer. Hope it helps! – np8 – 2019-11-06T14:23:49.933

Thank you, works great in Visual Studio! Too bad it doesn't work in Excel 2013 and Google Chrome. – cheesus says stop firing mods – 2014-01-23T09:23:59.047

3@cheeesus, for me, in Windows, Google Chrome actually has built-in support for horizontal scrolling. Even without the above script, I can hold down Shift and scroll the mouse wheel to scroll horizontally. – Sam – 2014-01-23T21:56:13.710

8

From http://www.autohotkey.com/docs/Hotkeys.htm

Some of the most useful hotkeys for the mouse wheel involve alternate modes of scrolling a window's text. For example, the following pair of hotkeys scrolls horizontally instead of vertically when you turn the wheel while holding down the left Control key:

~LControl & WheelUp::  ; Scroll left.
ControlGetFocus, fcontrol, A
Loop 2  ; <-- Increase this value to scroll faster.
    SendMessage, 0x114, 0, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 0 after it is SB_LINELEFT.
return

~LControl & WheelDown::  ; Scroll right.
ControlGetFocus, fcontrol, A
Loop 2  ; <-- Increase this value to scroll faster.
    SendMessage, 0x114, 1, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 1 after it is SB_LINERIGHT.
return

Matthew Lock

Posted 2009-07-27T16:24:40.250

Reputation: 4 254

5

There is a way to do this in windows with the right mouse. I have a mouse with a scroll wheel that has a jog left/jog right button integrated right into it. Simply pushing the scroll wheel left or right will move the contents in the desired direction. I have the Logitech VX and I have been very happy with it.

The VX also allows you to configure the buttons differently for every single application if you were so inclined. This level of customization is very nice to have!

Axxmasterr

Posted 2009-07-27T16:24:40.250

Reputation: 7 584

The Microsoft Wireless Laser Mouse 5000 ( http://www.microsoft.com/hardware/mouseandkeyboard/ProductDetails.aspx?pid=068 ) has this functionality.

– Travis – 2009-07-27T17:36:15.877

You are correct! I used to have that mouse before I upgraded to the VX. The VX has two very nice features which is why I upgraded. It has a flywheel on the scroll-wheel that spins for 7 seconds. The other nice feature is the USB dongle for the mouse actually fits fully inside the device, so it is very difficult to lose the dongle. – Axxmasterr – 2009-07-27T17:51:03.897

4

In some Windows programs shift does scroll horizontally (eg Windows Explorer).

In other programs such as Internet Explorer, Firefox and Excel holding down the scroll wheel button and moving from left to right will scroll horizontally.

Matthew Lock

Posted 2009-07-27T16:24:40.250

Reputation: 4 254

3Chrome seems to have built-in Shift horizontal scrolling, too. – Sam – 2014-10-23T02:10:37.343

Looks like it does work in VS as well, what I basically needed! Thank you! – Shimmy – 2016-10-20T02:50:27.017

2

Here's a hacky solution for Word (only) requiring both AutoHotKey and Word macros. It only works on the main document view in Word (which is good enough for me).

First, use AutoHotKey to send a custom keystroke to Word in response to the mouse action. I'm using Alt-M RightArrow and Alt-M LeftArrow. (I also have mappings for the WheelLeft and WheelRight events below because my mouse sends them just fine; I just need Word to do something useful with them.)

#If WinActive("ahk_class OpusApp")
+WheelUp::SendInput !+M{Left}
WheelLeft::SendInput !+M{Left}
WheelRight::SendInput !+M{Right}
+WheelDown::SendInput !+M{Right}
#If

Set up Word key bindings (you may alternatively use the keyboard customization dialog to do this):

' Alt-Shift-M Right (keycode 39)
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyM, wdKeyShift, wdKeyAlt), _
    KeyCode2:=BuildKeyCode(39), _
    KeyCategory:=wdKeyCategoryMacro, Command:="Normal.NewMacros.ScrollRight"

' Alt-Shift-M Left (keycode 37)
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyM, wdKeyShift, wdKeyAlt), _
    KeyCode2:=BuildKeyCode(37), _
    KeyCategory:=wdKeyCategoryMacro, Command:="Normal.NewMacros.ScrollLeft"

FInally, define the Word macros in your Normal template (or adjust the references to them above):

Sub ScrollRight()
    ActiveWindow.SmallScroll ToRight:=1
End Sub
Sub ScrollLeft()
    ActiveWindow.SmallScroll ToLeft:=1
End Sub

iagrapefruit

Posted 2009-07-27T16:24:40.250

Reputation: 21

2

Not exactly a keyboard shortcut, but you can always click down the mouse wheel. This brings up a 4-way icon in most applications that you can use to scroll

Blaine

Posted 2009-07-27T16:24:40.250

Reputation: 1 477

1

From Sam solution, I developed my own solution which has configurable scrolling speed:

https://gist.github.com/envil/d21a24744b68fda626b4444784f71c32

; Shift + Wheel for horizontal scrolling
+WheelUp::
    ; Scroll to the left
    MouseGetPos,,,id, fcontrol,1
    Loop 8 ; <-- Increase for faster scrolling
        SendMessage, 0x114, 0, 0, %fcontrol%, ahk_id %id% ; 0x114 is WM_HSCROLL and the 0 after it is SB_LINERIGHT.
return
+WheelDown::
    ;Scroll to the right
    MouseGetPos,,,id, fcontrol,1
    Loop 8 ; <-- Increase for faster scrolling
        SendMessage, 0x114, 1, 0, %fcontrol%, ahk_id %id% ;  0x114 is WM_HSCROLL and the 1 after it is SB_LINELEFT.
return

Envil

Posted 2009-07-27T16:24:40.250

Reputation: 148

Great script. This works really well. – Nick Painter – 2018-01-26T19:22:26.197

Only application that this does not seem to work on is Windows explorer. – Nick Painter – 2018-01-26T19:42:29.220

1

After some looking around, eventually found a way (using AutoHotKey) that works in Excel and everywhere else, without obviously breaking anything (adapted from a couple of different solutions on the AutoHotKey forums, though I didn't record sources so can't give appropriate credit sorry).

MS Excel seems to have some strange ways of handling it's user interface (though somehow, after many years of seeing what the MS Office developers have given us, I'm not that surprised). This script seems to work pretty much everywhere except MS Word - if anyone can solve that, then let me know! It's probably something like finding out the window class for Word and coding for it specifically like was done with Excel (just with a different set of key bindings).

#Singleinstance Force
#IfWinActive ahk_class XLMAIN
+WheelUp::
SetScrollLockState, On
SendInput {Left}
SetScrollLockState, Off
Return
+WheelDown::
SetScrollLockState, On
SendInput {Right}
SetScrollLockState, Off
Return

; Everything except Excel.
#IfWinNotActive ahk_class XLMAIN
+WheelUp::  ; Scroll left.
ControlGetFocus, fcontrol, A
Loop 4  ; <-- Increase this value to scroll faster.
    SendMessage, 0x114, 0, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 0 after it is SB_LINELEFT.
return

+WheelDown::  ; Scroll right.
ControlGetFocus, fcontrol, A
Loop 4  ; <-- Increase this value to scroll faster.
    SendMessage, 0x114, 1, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 1 after it is SB_LINERIGHT.
return
#IfWinActive

BevanFindlay

Posted 2009-07-27T16:24:40.250

Reputation: 116

0

Adding my Autohotkey scipts on separate answer since editing the accepted answer was rejected twice

Setting up Autohotkey

For those who are new to AutoHotKey, here are the steps:

1) Download and install AutoHotKey from autohotkey.com 
2) Right click on your desktop (or any other folder) -> New 
   -> Text Document -> Make a file called "myscript.ahk" 
3) Copy-paste the script from below -> Save the file 
4) Right-click on the file -> Run Script 
5) Small H-icon should appear to your taskbar notification area

Hint: You might want to make the script run automatically at Windows startup.

Autohotkey script

; Default solution (for all other programs)
; Shift + Wheel for horizontal scrolling
+WheelDown::WheelRight
+WheelUp::WheelLeft

; MS Excel
#IfWinActive, ahk_exe EXCEL.EXE

; Shift + Wheel for horizontal scrolling (left)
~LShift & WheelUp::
    {
        SetScrollLockState, on
        send,{left}
        SetScrollLockState, off
    }
return

; Shift + Wheel for horizontal scrolling (right)
~LShift & WheelDown:: 
    {
        SetScrollLockState, on
        send,{right}
        SetScrollLockState, off
    }
return

#IfWinActive

np8

Posted 2009-07-27T16:24:40.250

Reputation: 679

0

Tried a number of these scripts with mixed success to get horiz scroll working across all applications while retaining various functions of other modifiers (such as ctrl+scroll zoom).

u/np8 AHK script above works perfectly for me where the selected best answer does not.

logitech interface

I am using a Logitech G500s with various scripts and macros active in the Logitech Gaming Interface and this script has no compatibility/clash issues.

In Logitech Interface I re-bound scroll up / scroll down to scroll left / scroll right on the wheel, launched the script, restarted programmes and success in all the apps i tried:

  • word
  • excel
  • browsers
  • adobe apps (varied, some have special app-functions which >)

1358436

Posted 2009-07-27T16:24:40.250

Reputation: 1

I’m not sure I understand.  Did you destroy the scroll up / down capability and replace it with scroll left / right? – G-Man Says 'Reinstate Monica' – 2020-01-20T02:36:48.787

I don't believe i destroyed anything but by default i was unable to horizontal scroll with my g500s on a windows 10 laptop across windows apps, microsoft apps and browsers. Although the above script worked for me i found a bug in windows apps that have horiz and vert scroll - it won't work there :( I might look at a complete default setting across board and start fresh – 1358436 – 2020-01-21T03:50:50.870