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

[AU3基础] 求助: 请问为什么controlclick不能根据文本点击?

  [复制链接]
发表于 2017-9-20 11:16:48 | 显示全部楼层 |阅读模式
Local $e = WinGetHandle ("[class:#32770]", "")
;MsgBox($MB_SYSTEMMODAL, "", $e)
Local $button = ControlGetHandle ($e, "", "[CLASS:Button; INSTANCE:1]")
;MsgBox($MB_SYSTEMMODAL, "", $button)
ControlClick ("Confirm Uninstall", "", "[CLASS:Button; TEXT:OK]")


本帖子中包含更多资源

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

×
发表于 2017-9-20 12:32:25 | 显示全部楼层
应该是可以的,你看看是否可以获取控件的句柄
 楼主| 发表于 2017-9-20 16:01:57 | 显示全部楼层
能获取控件句柄,不知道是不是窗口没被激活?
如果改成Cancel, 运行后cancel button并不会被选中
ControlClick ($e, "Confirm Uninstall","[CLASS:Button; TEXT:Cancel]")
 楼主| 发表于 2017-9-20 17:48:13 | 显示全部楼层
Local $e = WinGetHandle ("[CLASS:#32770]", "")
Local $button = ControlGetHandle ($e, "", "[CLASS:Button;INSTANCE:1]")
MsgBox($MB_SYSTEMMODAL, "", $button)
Local $position = ControlGetPos($button, "", "")
MsgBox($MB_SYSTEMMODAL, "", "Position: " &  $position[0] & ", " &  $position[1] & @CRLF & "Size: " &  $position[2] & ", " & $position[3])
Local $move =ControlMove($e, "OK", "[CLASS:Button; INSTANCE:1]", "$position[0]", "$position[1]", "$position[2]", "$position[3]")
MsgBox($MB_SYSTEMMODAL, "", $move)
Send ("!a")
使光标移到button上面直接关闭也不行,请问这到底什么原因?
发表于 2017-9-20 19:21:54 | 显示全部楼层
有窗口,有控件,应该能控制吧。似乎是你函数参数没用对?比如
Local $position = ControlGetPos($button, "", "这里应该有控件才对吧?")
发表于 2017-9-20 19:24:17 | 显示全部楼层
如一楼所说点击OK
这样应该就行了,我都是这么用的。ControlClick ("Confirm Uninstall", "", "Button1")
 楼主| 发表于 2017-9-21 17:54:01 | 显示全部楼层
回复 5# fybhwsx

Local $e = WinGetHandle ("[CLASS:#32770]")
;MsgBox($MB_SYSTEMMODAL, "", $e)
  WinWait("[CLASS:#32770]","",10)
  If WinExists("Confirm Uninstall", "OK") Then
        MsgBox($MB_SYSTEMMODAL, "", "Window exists")
   Else
        MsgBox($MB_SYSTEMMODAL, "", "Window does not exist")
   EndIf
   Local $button = ControlGetHandle ($e, "OK", "[CLASS:Button;INSTANCE:1]")
   MsgBox($MB_SYSTEMMODAL, "", $button)
   Local $position = ControlGetPos($e, "OK", "[CLASS:Button;INSTANCE:1]")
   MsgBox($MB_SYSTEMMODAL, "", "Position: " &  $position[0] & ", " &  $position[1] & @CRLF & "Size: " &  $position[2] & ", " & $position[3])
   Local $R = ControlClick ("Confirm Uninstall", "OK", "[CLASS:Button;INSTANCE:1]", "left", 2, $position[3]-60, 10)
   MsgBox($MB_SYSTEMMODAL, "", $R)
   
controlclick返回值也是1, 请教一下,怎么知道click在哪里呢?感谢
发表于 2017-9-24 08:49:29 | 显示全部楼层
学习 学习  正好遇到此类问题
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-27 02:04 , Processed in 0.071702 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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