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?
13 Answers
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.)
- 1,476
You could simulate it with AutoHotKey
If I find the script I'll let you know: From these posts:
- http://www.autohotkey.com/forum/topic5903.html
- http://www.autohotkey.com/forum/viewtopic.php?t=3640
- http://www.autohotkey.com/forum/topic27141.html
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) }
- 30,396
- 15
- 136
- 260
- 24,894
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
- 4,757
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
- 195
- 1
- 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!
- 7,966
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.
- 4,757
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
- 30,396
- 15
- 136
- 260
- 21
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,697
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
- 148
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
}
- 3
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
- 1,616
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.
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 >)
- 1
With the ; Shift + Wheel for horizontal scrolling script, it will disable your up and down scroll unless the last two lines are as follows.
; Shift + Wheel for horizontal scrolling
+WheelDown::WheelRight
+WheelUp::WheelLeft
WheelDown::WheelDown
WheelUp::WheelUp
- 472