83

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?

2
  • 12
    I was hoping for a system-wide solution. Jul 27, 2009 at 17:15
  • In some specific cases just left/right keys on the keyboard can do
    – golimar
    Jul 27, 2021 at 10:13

12 Answers 12

20

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) }
0
31

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.)

0
10

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
7

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
1
  • 2
    I figured out how to do it in Word. +WheelUp::ComObjActive("Word.application").ActiveWindow.SmallScroll(0,0,0,1) ; +WheelDown::ComObjActive("Word.application").ActiveWindow.SmallScroll(0,0,1,0) Credit to Datapoint on the AutoHotkey Forums. Turns out SmallScroll is a VBA API.
    – Brad Turek
    Feb 19, 2021 at 4:16
6

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!

2
  • The Microsoft Wireless Laser Mouse 5000 ( microsoft.com/hardware/mouseandkeyboard/… ) has this functionality.
    – Travis
    Jul 27, 2009 at 17:36
  • 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
    Jul 27, 2009 at 17:51
5

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.

3
  • 4
    Chrome seems to have built-in Shift horizontal scrolling, too.
    – Sam
    Oct 23, 2014 at 2:10
  • 1
    Looks like it does work in VS as well, what I basically needed! Thank you! Oct 20, 2016 at 2:50
  • 1
    Firefox does both (Shift + scroll and middle click + moving mouse left or right)
    – golimar
    Jul 27, 2021 at 10:10
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
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

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
1
  • Only application that this does not seem to work on is Windows explorer. Jan 26, 2018 at 19:42
1

By combining previous answers and scripts on the Internet. Here is the script that works in Word, PowerPoint, Excel, and OneNote.

; Scroll speed parameter
ScrollSpeed:=4

; OneNote horizontal scroll
#HotIf WinActive("ahk_exe ONENOTE.EXE")
+WheelUp::WheelLeft
+WheelDown::WheelRight

; PowerPoint horizontal scroll
#HotIf WinActive("ahk_exe POWERPNT.EXE")
+WheelUp::ComObjActive("PowerPoint.Application").ActiveWindow.SmallScroll(0,0,0,ScrollSpeed)
+WheelDown::ComObjActive("PowerPoint.Application").ActiveWindow.SmallScroll(0,0,ScrollSpeed,0)

; Word horizontal scroll
#HotIf WinActive("ahk_exe WINWORD.EXE")
+WheelUp::ComObjActive("Word.application").ActiveWindow.SmallScroll(0,0,0,ScrollSpeed) 
+WheelDown::ComObjActive("Word.application").ActiveWindow.SmallScroll(0,0,ScrollSpeed,0)


; Excel horizontal scroll
#HotIf WinActive("ahk_exe EXCEL.EXE")
+WheelUp::{
  SetScrollLockState true
  SendInput "{Left}"
  SetScrollLockState false
  Return
}
+WheelDown::{
  SetScrollLockState true
  SendInput "{Right}"
  SetScrollLockState false
  Return
}
0
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
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 >)
2
  • I’m not sure I understand.  Did you destroy the scroll up / down capability and replace it with scroll left / right? Jan 20, 2020 at 2:36
  • 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
    Jan 21, 2020 at 3:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .