I am using AutoIt to click on Sim (Yes in Portuguese) on all windows that opens on the program with the code below:
#requireAdmin
ShellExecute("...\Desktop\test.xrt")
While True
$win = WinWait("XP-Remote", "Sim")
ControlClick($win, "", "[CLASS:Button; INSTANCE:1]")
WinWaitClose($win)
Wend
However, I want to stop when the progress bar is on 100%.
Here is the data of the bar:
And the visible text just show this:
>>>> Window <<<<
Title: Communicating...
Class: #32770
Position: 623, 338
Size: 429, 135
Style: 0x94C800CC
ExStyle: 0x00010101
Handle: 0x00000000000B08CE
>>>> Control <<<<
Class: msctls_progress32
Instance: 1
ClassnameNN: msctls_progress321
Name:
Advanced (Class): [CLASS:msctls_progress32; INSTANCE:1]
ID: 1012
Text:
Position: 11, 52
Size: 402, 29
ControlClick Coords: 151, 22
Style: 0x50000000
ExStyle: 0x00000004
Handle: 0x00000000003306DC
>>>> Mouse <<<<
Position: 788, 437
Cursor ID: 0
Color: 0xFFFFFF
>>>> StatusBar <<<<
>>>> ToolsBar <<<<
>>>> Visible Text <<<<
Elasped time:
00:14
Reading project files...
>>>> Hidden Text <<<<
I am using a Timer, because i can't figure out how i can do this.
#requireAdmin
ShellExecute("...\Desktop\test.xrt")
$Timer = TimerInit ()
Do
$win = WinWait("XP-Remote", "Sim")
ControlClick($win, "", "[CLASS:Button; INSTANCE:1]")
WinWaitClose($win)
until TimerDiff($Timer)>=5000
However, using the progress bar is more error proof.
Edit: Tried to use:
GUICtrlRead()
$handle = ControlGetHandle ("Communicating...", "", "[CLASS:msctls_progress32; INSTANCE:1]")
$msg = _SendMessage($handle,$PBM_GETPOS,0,0)
Maybe not correctly...
Using this code:
ShellExecute("...\Desktop\test.xrt")
While True
$handle = ControlGetHandle ("Communicating...", "", "[CLASS:msctls_progress32; INSTANCE:1]")
ConsoleWrite("Progress bar handle: " & $handle & @CRLF)
$msg = _SendMessage($handle,$PBM_GETPOS,0,0)
ConsoleWrite("Position: " & $msg & "%" & @CRLF)
WEnd
The Result is infinite:
Progress bar handle: 0x00000000
Position: 0%
_SendMessage($handle,$PBM_GETPOS,0,0)
is correct.
This should work:
#include <SendMessage.au3>
#include <ProgressConstants.au3>
$hWnd = WinWait("Communicating...")
$hWnd_Progress = ControlGetHandle($hWnd,"","msctls_progress321")
While _SendMessage($hWnd_Progress,$PBM_GETPOS,0,0) < 100
$win = WinWait("XP-Remote", "Sim")
ControlClick($win, "", "[CLASS:Button; INSTANCE:1]")
WinWaitClose($win)
WEnd