AutoHotkey Community

It is currently May 27th, 2012, 12:23 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: December 4th, 2008, 6:38 pm 
Offline

Joined: August 25th, 2006, 5:45 pm
Posts: 12
I tried the following code found in the AHK help file so that I could scroll left and right in Excel with the mouse scroll wheel. It works in all programs I've tried it in, except Excel 2007. Does anybody know how to make it work there as well? That's where I am wanting to use it. Thanks!

Code:
~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_LINERIGHT.
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_LINELEFT.
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2009, 7:26 pm 
Offline

Joined: January 25th, 2009, 9:18 pm
Posts: 34
I don't have Microsoft Excel 2007 in front of me at the moment so I can't write a new script for you

However, if you click the scroll wheel you can then move the mouse to scroll in all directions.

_________________
Go to http://www.lingokite.com to find out about Lingokite, the revolution in language learning technology


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2011, 9:16 am 
Offline

Joined: June 3rd, 2008, 6:44 pm
Posts: 27
I came here to ask the exact same question. Hopefully a solution has been found in the two and a half years since the first post was made :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2011, 2:36 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Here's a simple Com based solution. This example requires AutoHotkey_L & the ComUtils Acc Library:
Code:
#IfWinActive, ahk_class XLMAIN
~LControl & WheelUp::
~LControl & WheelDown::
   n := InStr(A_ThisHotkey,"Up") ? 1:-1
   ControlGet, hwnd, hwnd, , Excel71, ahk_class XLMAIN
   ComObjError(false) ; disable any Com Error Message
   Acc_ObjectFromWindow(hwnd, -16).ScrollColumn += 1*n
   ComObjError(true) ; enable Com Error
   return
#IfWinActive

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2011, 2:52 pm 
Offline
User avatar

Joined: April 4th, 2009, 8:19 pm
Posts: 1143
Location: Croatia
Here is mine :mrgreen: Requires just AutoHotkey_L
Code:
#IfWinActive, ahk_class ahk_class XLMAIN
LControl & WheelUp::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,0,1)  ; Scroll left.
LControl & WheelDown::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,1)  ; Scroll right.
#IfWinActive
To increase scroll rate, increase last parameters (1)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2011, 3:06 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Very nice - though I'd recommend Not using ComObjActive for 2 reasons:
  1. If there is more than 1 running Excel process, it will get the first on registered on the ROT.
  2. If the Excel process hasn't been registered on the ROT (if it was just opened), you will get a Com Error.
That being said, I did take inspiration from your example:
Code:
#IfWinActive, ahk_class XLMAIN
~LControl & WheelUp::
~LControl & WheelDown::
   ControlGet, hwnd, hwnd, , Excel71, ahk_class XLMAIN
   Acc_ObjectFromWindow(hwnd, -16).SmallScroll(0,0,InStr(A_ThisHotkey,"Up")? -1:1)
   return
#IfWinActive

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2011, 3:23 pm 
Offline
User avatar

Joined: April 4th, 2009, 8:19 pm
Posts: 1143
Location: Croatia
@jethrow: :D btw, this one is mine OK? :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2011, 3:25 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
*ducks*

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2011, 7:08 pm 
Offline

Joined: June 3rd, 2008, 6:44 pm
Posts: 27
Thanks people. jethrow's script works great!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2011, 9:27 am 
Offline

Joined: October 29th, 2011, 9:17 am
Posts: 8
deleted


Last edited by longtth on October 29th, 2011, 10:21 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2011, 10:21 am 
Offline

Joined: October 29th, 2011, 9:17 am
Posts: 8
Learning one wrote:
Here is mine :mrgreen: Requires just AutoHotkey_L
Code:
#IfWinActive, ahk_class ahk_class XLMAIN
LControl & WheelUp::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,0,1)  ; Scroll left.
LControl & WheelDown::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,1)  ; Scroll right.
#IfWinActive
To increase scroll rate, increase last parameters (1)

Thanks so much!
Your code work awesome on my Excel 2010:
but it still don't affect on Microsoft Word 2007 & 2010.
would you please modify your code a bit for working on Word 2010?
It will be a pleasure,
Many thanks!
-
Sorry for my bad English!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2012, 6:48 pm 
This seems very helpful but unfortunately I'm so bad with computers, I have no idea what to do with this code to activate it.
Could someone please tell me what I do with this code to use it?
Thanks in advance!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2012, 10:53 am 
Offline

Joined: October 29th, 2011, 9:17 am
Posts: 8
clueless wrote:
This seems very helpful but unfortunately I'm so bad with computers, I have no idea what to do with this code to activate it.
Could someone please tell me what I do with this code to use it?
Thanks in advance!

open notepad
copy & paste the script given by jethrow or lamboe80
save with .ahk extension (note that you must `save as type` = `All types`
right click on that file and choose `run script`


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2012, 5:33 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
longtth wrote:
would you please modify your code a bit for working on Word 2010?

Code:
SetTitleMatchMode, RegEx
#IfWinActive ahk_class (XLMAIN|OpusApp)
<^WheelUp::ComObjActive((ActiveWinClass()="XLMAIN"? "Excel":"Word") ".Application").ActiveWindow.SmallScroll(0,0,0,1)  ; Scroll left.
<^WheelDown::ComObjActive((ActiveWinClass()="XLMAIN"? "Excel":"Word") ".Application").ActiveWindow.SmallScroll(0,0,1)  ; Scroll right.
#IfWinActive


ActiveWinClass() {
   WinGetClass, c, A
   return c
}

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], chaosad, Exabot [Bot], jrav and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group