joncom Posted April 22, 2013 Posted April 22, 2013 (edited) I need to scroll a window both horizontally and vertically.I have already achieved vertical scrolling using the following code:$MainWindowTitle = "Example" $controlID = "[CLASSNN:Window8]" $windowPos = ControlGetPos ( $MainWindowTitle, "", controlID ) WinActivate ( $MainWindowTitle ) ; Position the mouse over the scrollable area. MouseMove( $windowPos[0] + 10, $windowPos[1] + 10, 0 ) ; Scroll MouseWheel ( "down" )The problem with using similar code to scroll horizontally, is that it appears AutoIt has zero support for horizontal mousewheel.So then I tried using arrow keys:ControlSend ( $MainWindowTitle, "", $controlID, "{RIGHT}" )But this has no effect. In fact, the window appears to not respond to arrows from my actually keyboard either, but I thought it was worth a shot.Just to be clear, the window does indeed have a scroll bar and can be interacted with using the mouse.Is my only option to send MouseClick's to the little arrows on the sides of this scrollbar?Or is there some AutoIt method (crosses fingers) that I've not yet discovered that will make this job very simple? Edited April 22, 2013 by joncom
PhoenixXL Posted April 22, 2013 Posted April 22, 2013 use _GUIScrollBars_ScrollWindow or use directly the ScrollWindow function of User32.dll My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
joncom Posted April 22, 2013 Author Posted April 22, 2013 (edited) Does not seem to work.My bad, perhaps I was not as clear as I should have been.The "window" that I'm trying to scroll is an instance of the Window class, within the window that is the app itself.Isn't it true that you cannot get a "handle" for a window class?The WinGetHandle method seems to only accept the variety of window that has a title, which does not apply here.I have managed to solve the problem by using MouseClick to click on the scrollbar arrows.It feels sloppy, but it does work.However, for the sake of interest, I still would love to know if there's a more elegant approach.*Edit*I was wrong. Looks like all controls also have a handle. I got the handle for the scrollable window using AutoIt Window Info. The following was a quick test to see if I could scroll right._GUIScrollBars_ScrollWindow("0x000000000004079E", 22, 0)No effect Edited April 22, 2013 by joncom
PhoenixXL Posted April 22, 2013 Posted April 22, 2013 (edited) Isn't it true that you cannot get a "handle" for a window class? The WinGetHandle method seems to only accept the variety of window that has a title, which does not apply here.Nah! it's not true. Check this out; Identify the Notepad window that contains the text "this one" and get a handle to it Run("notepad.exe") WinWait("[CLASS:Notepad]") ; Get the handle of a notepad window that contains "this one" Local $handle = WinGetHandle("[CLASS:Notepad]") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else ; Send some text directly to this window's edit control ControlSend($handle, "", "Edit1", "AbCdE") EndIfThe Example is directly through the HelpFile. Check the HelpFile for WinGetHandle. Classes could be used inplace of Titles _GUIScrollBars_ScrollWindow("0x000000000004079E", 22, 0)You are passing a string to the function instead of a hWnd. Ask if more help is needed The HANDLE itself is just an integral type. Usually, but not necessarily, it is a pointer to some underlying type or memory location. For example, the HANDLE returned by GetModuleHandle is actually a pointer to the base virtual memory address of the module. But there is no rule stating that handles must be pointers. A handle could also just be a simple integer (which could possibly be used by some Win32 API as an index into an array). Source Regards Edited April 22, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now