单击按钮直到进度条为100%

时间:2017-11-24 12:33:41

标签: autoit

我正在使用AutoIt在程序上打开的所有窗口上点击Sim(葡萄牙语为是),代码如下:

#requireAdmin
ShellExecute("...\Desktop\test.xrt")

While True
    $win = WinWait("XP-Remote", "Sim")
    ControlClick($win, "", "[CLASS:Button; INSTANCE:1]")
    WinWaitClose($win)
Wend

但是,我想在进度条100%时停止。

自动信息

以下是条形码的数据:

progress bar

可见文字只显示:

visible text

>>>> 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 <<<<

使用计时器

我正在使用计时器,因为我无法弄清楚我是如何做到的。

#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

但是,使用进度条更容易出错。

如何检查进度条或Do直到&lt; 100%?

编辑:尝试使用:

  • GUICtrlRead()
  • $handle = ControlGetHandle ("Communicating...", "", "[CLASS:msctls_progress32; INSTANCE:1]")

    $msg = _SendMessage($handle,$PBM_GETPOS,0,0)
    

也许不正确......

编辑:

使用此代码:

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

结果是无限的:

Progress bar handle: 0x00000000
Position: 0%

1 个答案:

答案 0 :(得分:1)

_SendMessage($handle,$PBM_GETPOS,0,0)是正确的。

这应该有效:

#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