Merckie Posted March 5, 2009 Share Posted March 5, 2009 I'm a newb to AutoIt and coding in general. I have been working with AutoIt for a few months now and have already had lots of success, but I've hit a wall. A few years ago we contracted out to a group to automate a Windows app for us using QTP (Quick Test Professional)...the code sucks and I'm constantly having to restart the automation scripts. I've been re-coding the QTP automation into AutoIt and am stuck when it comes to controlling a scroll bar. I can get the scroll bar to move but the actual window doesn't refresh. I have tried many different methods of moving the scroll bar (except for actually moving it with the mouse), but none refresh the window. I have also tried sending keyboard commands, Arrow-down, Page-down, etc., and refresh commands (_WinAPI) but those don't work either. In QTP, the scroll bar and window act normally with the command: "WinObject("AfxWnd42").VScroll micPageNext, 2", but I can't seem to find anything in AutoIt that acts similarily. Thanks for any help! (I apologize for the sloppyness of my code, but it's a result of trying lots of variations) expandcollapse popup#include-once #include <GuiTab.au3> #Include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GUIListBox.au3> #include <_XMLDomWrapper.au3> #Include <GuiComboBoxEx.au3> #Include <GuiScrollBars.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <ScrollBarConstants.au3> #include <GuiEdit.au3> #include <GuiStatusBar.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <ScrollBarConstants.au3> #Include <GuiScroll.au3> #Include <WinAPI.au3> AutoItSetOption("MustDeclareVars", 0) Local $Max, $yPos, $Page, $Pos WinActivate("Somnologica - [","") Sleep(2000) Local $hWnd = ControlGetHandle("Somnologica - [","","[CLASS:AfxWnd42; INSTANCE:8]") Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $Pos = DllStructGetData($tSCROLLINFO, "nPos") DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO, True) ;_GUIScrollBars_ScrollWindow($hWnd, 0, $Pos + $Page) ;Scrollbar_Scroll($hWnd, $SB_VERT, $Max) ;WM_VSCROLL($hWnd, $SB_PAGEDOWN) Sleep(2000) ;Local $hWnd2 = ControlGetHandle("Somnologica - [","","[CLASS:Afx:400000:0]") Local $hWnd2 = WinGetHandle ("Somnologica - [","") ConsoleWrite("hWnd2: " & $hWnd2 & @CRLF) ;Local $return = _WinAPI_UpdateWindow($hWnd2) Local $return = _WinAPI_RedrawWindow($hWnd2,0,0,$RDW_ERASE) ConsoleWrite("Update: " & $return & @CRLF) Sleep(2000) MouseMove ((0.5*@DesktopWidth), (0.75*@DesktopHeight)) ConsoleWrite((0.5*@DesktopWidth) & " " & (0.75*@DesktopHeight) & @CRLF) MouseClick("right",MouseGetPos(0),MouseGetPos(1),1,10) ConsoleWrite("Completed") Link to comment Share on other sites More sharing options...
Authenticity Posted March 5, 2009 Share Posted March 5, 2009 As I see, it's not in any part child of your window so it's completely different process with different address space so passing your own pointer of structure to get or set data on that control probably is the root of the problem (correct me if I'm wrong). You need to use VirtualAllocEx, WriteProcessMemory, ReadProcessMemory and the like to use inter-process pointers. Look at the function _GUICtrlListView_GetItemEx() for example for doing this. Usually this is done by the _GUI* functions but not in this case. Link to comment Share on other sites More sharing options...
Ascend4nt Posted March 5, 2009 Share Posted March 5, 2009 One method I've used to send linescroll messages is to send this message: GUICtrlSendMsg($hControlIDToLink,0x00B6,0,$iVerticalDelta); EM_LINESCROLL [SEND] My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
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