AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Enable scrolling in VBA editor window

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
wOxxOm



Joined: 09 Feb 2006
Posts: 319

PostPosted: Sat May 27, 2006 10:45 am    Post subject: Enable scrolling in VBA editor window Reply with quote

Use most recent version as this code works only in 1.0.43 and above
This code uses winapi messages and works like a charm!!!

Hold Shift to scroll by page

Code:
#ifwinactive ahk_class wndclass_desked_gsk
~*WheelDown::ScrollVBA(1)
~*WheelUp::ScrollVBA(0)
ScrollVBA(scrollCode) ;; 0=up, 1=down
{  ControlGetFocus,vbaCtl
   ControlGet,hwndVBActl,HWND,,%vbaCtl%
   winGetTitle,vbaTitle,ahk_id %hwndVBActl%
   if (inStr(vbaTitle,"(Code)"))
   {  ControlGet,hwndScroll,HWND,,ScrollBar2
      goto Scroll
   }
   ControlGetPos,cx,cy,cw,,%vbaCtl%
   loop,15
   {  ControlGetPos,sx,sy,,,ScrollBar%A_Index%
      if (abs(sx-cx-cw)<30) and (abs(sy-cy)<30)
      {  ControlGet,hwndScroll,HWND,,ScrollBar%A_Index%
         break
      }
   }
   ifEqual,hwndScroll,,return
Scroll:
   if (GetKeyState("Shift"))
      sendmessage,277,% 2+ScrollCode,%hwndScroll%,%vbaCtl%
   else
      loop,4
         sendmessage,277,%ScrollCode%,%hwndScroll%,%vbaCtl%
}
#ifWinActive


updated: doesn't use index to determine current control but vbaWindow's title instead
updated2: enumeration of scrollbars>2 for more robust catching of correct scrollbar


Last edited by wOxxOm on Sat May 27, 2006 5:08 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Levin
Guest





PostPosted: Sat May 27, 2006 2:07 pm    Post subject: Reply with quote

Useful and Educational.

Wonder why Microsoft didnt think of enabling wheelmouse scrolling in VBA editor.
Back to top
Winkie



Joined: 11 Apr 2006
Posts: 8
Location: The Netherlands

PostPosted: Sat May 27, 2006 10:04 pm    Post subject: Reply with quote

Thanx for this script, I can pull a task of my todo-list now!

And thanks to your second update I don't have to localize the script...
I didn't to find out yet when the title contains "Watches", so I could translate it properly. I was planning to ask that now Razz

Bye
_________________
Winkie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group