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)
#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")