找回密码
 加入
搜索
查看: 1733|回复: 7

[AU3基础] 探测结果为button实际上是单选的怎么自动发送点击?

  [复制链接]
发表于 2018-6-27 12:46:37 | 显示全部楼层 |阅读模式
试过用模拟点击却不行,貌似没定到焦点,controlclick是无效的。就是product is registered to里面两个点选框

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2018-6-27 12:56:43 | 显示全部楼层
有的控件會被別的控件蓋住
要去list all control
再去看空件的文本比對
[mw_shl_code=actionscript3,false]#include <Array.au3>
#include <WinAPI.au3>

ConsoleWrite("Make your window active!" & @CRLF)
Sleep(5000)

GetAllWindowsControls(WinGetHandle("[ACTIVE]"))

Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default)
    If Not IsHWnd($hCallersWindow) Then
        ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF)
        Return False
    EndIf
    ; Get all list of controls
    If $bOnlyVisible = Default Then $bOnlyVisible = False
    If $sStringIncludes = Default Then $sStringIncludes = ""
    If $sClass = Default Then $sClass = ""
    $sClassList = WinGetClassList($hCallersWindow)

    ; Create array
    $aClassList = StringSplit($sClassList, @CRLF, 2)

    ; Sort array
    _ArraySort($aClassList)
    _ArrayDelete($aClassList, 0)

    ; Loop
    $iCurrentClass = ""
    $iCurrentCount = 1
    $iTotalCounter = 1

    If StringLen($sClass)>0 Then
        For $i = UBound($aClassList)-1 To 0 Step - 1
            If $aClassList[$i]<>$sClass Then
                _ArrayDelete($aClassList,$i)
            EndIf
        Next
    EndIf

    For $i = 0 To UBound($aClassList) - 1
        If $aClassList[$i] = $iCurrentClass Then
            $iCurrentCount += 1
        Else
            $iCurrentClass = $aClassList[$i]
            $iCurrentCount = 1
        EndIf

        $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
        $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
        $aPos = ControlGetPos($hCallersWindow, "", $hControl)
        $sControlID = _WinAPI_GetDlgCtrlID($hControl)
        $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible")
        If $bOnlyVisible And Not $bIsVisible Then
            $iTotalCounter += 1
            ContinueLoop
        EndIf

        If StringLen($sStringIncludes) > 0 Then
            If Not StringInStr($text, $sStringIncludes) Then
                $iTotalCounter += 1
                ContinueLoop
            EndIf
        EndIf

        If IsArray($aPos) Then
            ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF)
        Else
            ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
        EndIf

        If Not WinExists($hCallersWindow) Then ExitLoop
        $iTotalCounter += 1
    Next
EndFunc   ;==>GetAllWindowsControls[/mw_shl_code]
 楼主| 发表于 2018-6-27 16:01:38 | 显示全部楼层
mars0916 发表于 2018-6-27 12:56
有的控件會被別的控件蓋住
要去list all control
再去看空件的文本比對

朋友这个怎么调用,func是用includ调用吗?
发表于 2018-6-27 16:11:36 | 显示全部楼层
本帖最后由 mars0916 于 2018-6-27 16:16 编辑
friendtasy 发表于 2018-6-27 16:01
朋友这个怎么调用,func是用includ调用吗?

我有貼代碼
要再SCITE裡執行
結果會在console裡
直接用他來列出所有的控件按下F5 會有5秒等待時間
這時把要列出控件的視窗用在最上層
他就會列出來了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2018-6-27 20:07:44 | 显示全部楼层
mars0916 发表于 2018-6-27 16:11
我有貼代碼
要再SCITE裡執行
結果會在console裡

不知为什么马上就结束了,提示如下。

C:\Documents  Settings\Administrator\??\?? AutoIt3 ??.au3 (14) : ==> ????????.:
?
^ ERROR
->20:07:08 AutoIt3.exe 结束.rc: 1
+>20:07:08 AutoIt3Wrapper 完成脚本处理.
>Exit code: 1    Time: 0.5901
 楼主| 发表于 2018-6-27 20:10:11 | 显示全部楼层
噢,可以了,可能复制的方式有问题,再研究一下了,非常感谢朋友的无私帮助。
 楼主| 发表于 2018-6-27 20:17:00 | 显示全部楼层
果然可以的,再次感谢
发表于 2018-7-1 17:07:41 | 显示全部楼层
我一般模拟键盘TAB键盘来选择
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 10:41 , Processed in 0.074950 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表