控件类名变化,能用正则吗?【已解决】
本帖最后由 fybhwsx 于 2018-2-28 17:42 编辑不是窗口类名,这个控件类名ATL:后面部分会变化,导致控件点击失败。。ControlClick("", "同意并继续(&A)", "") ;点击同意并继续 对于无法获取控件ID或者控件变化这种问题,用窗口坐标应该能解决,改成下面这样很顺利的完成这个程序安装。强迫症,总是想通过控件点击它,求助!;安装NVIDIA显卡驱动
Local $NVIDIA = 'D:\NVIDIA显卡驱动\390.77-notebook-win10-64bit-international-whql\setup.exe'
If FileExists("C:\Program Files\NVIDIA Corporation\Control Panel Client\nvcplui.exe") = 0 and FileExists($NVIDIA) Then ;若安装文件存在但默认(或指定)路径未发现安装
ShellExecute(_WinAPI_PathFindFileName($NVIDIA), "", _WinAPI_PathRemoveFileSpec($NVIDIA), "open", @SW_SHOWNORMAL) ;运行安装程序
WinWait("", "同意并继续(&A)")
Sleep(250)
Local $aPos = WinGetPos("")
Sleep(250)
MouseClick("", $aPos + 418, $aPos + 413, 1, 1) ;ControlClick("", "同意并继续(&A)", "") ;点击同意并继续
WinWait("", "精简(&E)(推荐)")
Sleep(250)
MouseClick("", $aPos + 429, $aPos + 412, 1, 1) ;ControlClick("", "精简(&E)(推荐)", "") ;点击下一步
WinWait("", "关闭(&C)") ;等待安装完毕
Sleep(250)
MouseClick("", $aPos + 192, $aPos + 156, 1, 1) ;ControlClick("", "关闭(&C)", "", 'left', 1, 10, 10) ;点击取消勾选创建桌面快捷方式
Sleep(250)
MouseClick("", $aPos + 192, $aPos + 182, 1, 1) ;ControlClick("", "关闭(&C)", "", 'left', 1, 10, 35) ;点击取消勾选启动Experience
Sleep(250)
MouseClick("", $aPos + 533, $aPos + 412, 1, 1) ;ControlClick("", "关闭(&C)", "") ;点击关闭
WinWaitClose("", "关闭(&C)")
EndIf 直接 alt + a 简单粗暴 本帖最后由 fybhwsx 于 2018-2-28 17:40 编辑
经过测试,控件类名其实就是子窗口类名,不能用正则,只能枚举。每一步的子窗口数量也不一样。下面是简单按照枚举子窗口的排列顺序提取类名实现点击,先偷懒用着。如果下次安装这个顺序也不固定的话,再处理。。Local $NVIDIA = 'D:\NVIDIA显卡驱动\390.77-notebook-win10-64bit-international-whql\setup.exe'
;安装NVIDIA显卡驱动
If FileExists("C:\Program Files\NVIDIA Corporation\Control Panel Client\nvcplui.exe") = 0 and FileExists($NVIDIA) Then ;若安装文件存在但默认(或指定)路径未发现安装
ShellExecute(_WinAPI_PathFindFileName($NVIDIA), "", _WinAPI_PathRemoveFileSpec($NVIDIA), "open", @SW_SHOWNORMAL) ;运行安装程序
Local $NVIDIA_ckjb = WinWait("", "同意并继续(&A)")
If $NVIDIA_ckjb Then
Local $aData = _WinAPI_EnumChildWindows($NVIDIA_ckjb2)
ControlClick("", "同意并继续(&A)", $aData[$aData] & "2") ;点击同意并继续
WinWait("", "精简(&E)(推荐)")
Sleep(250)
ControlClick("", "精简(&E)(推荐)", $aData[$aData] & "2") ;点击下一步
Local $NVIDIA_ckjb2 = WinWait("", "关闭(&C)") ;等待安装完毕
Sleep(250)
If $NVIDIA_ckjb2 Then
Local $aData2 = _WinAPI_EnumChildWindows($NVIDIA_ckjb)
ControlClick("", "关闭(&C)", $aData2 & "1", 'left', 1, 10, 10) ;点击取消勾选创建桌面快捷方式
Sleep(250)
ControlClick("", "关闭(&C)", $aData2 & "1", 'left', 1, 10, 35) ;点击取消勾选启动Experience
Sleep(250)
ControlClick("", "关闭(&C)", $aData[$aData] & "2") ;点击关闭
WinWaitClose("", "关闭(&C)")
EndIf
EndIf
EndIf 晕死,ControlClick一直都是用控件类名加接口点击,居然能这样用!!赶紧补上,别把大家带沟里了啊。。。Local $NVIDIA = 'D:\NVIDIA显卡驱动\390.77-notebook-win10-64bit-international-whql\setup.exe'
ShellExecute(_WinAPI_PathFindFileName($NVIDIA), "", _WinAPI_PathRemoveFileSpec($NVIDIA), "open", @SW_SHOWNORMAL) ;运行安装程序
WinWait("", "同意并继续(&A)")
ControlClick("", "", "同意并继续(&A)") ;点击同意并继续
WinWait("", "自定义(&C)(高级)")
ControlClick("", "", "自定义(&C)(高级)") ;点击自定义(&C)(高级)
ControlClick("", "", "下一步(&N)") ;点击下一步(&N)
WinWait("", "组件列表")
ControlClick("", "", "组件列表", 'left', 1, 13, 50) ;点击取消勾选NVIDIA GeForce Experience(不安装)
ControlClick("", "", "组件列表", 'left', 1, 13, 70) ;点击取消勾选PhysX 系统软件(不安装)
ControlClick("", "", "执行清洁安装(&P)") ;点击执行清洁安装(&P)
ControlClick("", "", "下一步(&N)") ;点击下一步(&N)
WinWait("", "关闭(&C)")
ControlClick("", "", "关闭(&C)") ;点击关闭(&C)
页:
[1]