找回密码
 加入
搜索
查看: 12003|回复: 32

[AU3基础] 如何根据控件句柄实现控件单击

 火.. [复制链接]
发表于 2010-12-13 13:06:07 | 显示全部楼层 |阅读模式
如何根据控件句柄实现控件单击
麻烦好心人给个例子,谢谢
 楼主| 发表于 2010-12-13 14:08:18 | 显示全部楼层
没人知道吗
发表于 2010-12-13 14:16:06 | 显示全部楼层
用 控件ID 不行吗,非要 控件句柄
发表于 2010-12-13 14:26:50 | 显示全部楼层
ControlClick("[CLASS:Notepad]", "", "MDIClient1")
 楼主| 发表于 2010-12-13 14:30:53 | 显示全部楼层
谢谢两位,由于一些原因我想用句柄来单击控件
 楼主| 发表于 2010-12-13 14:33:55 | 显示全部楼层
听说_WinAPI_PostMessage函数可以实现用句柄单击控件,可是不会用
 楼主| 发表于 2010-12-13 14:35:26 | 显示全部楼层
#Include <WinAPI.au3>
_WinAPI_PostMessage("0x00050722(控件句柄)", "", "Click", "1")
这代码不行
发表于 2010-12-13 14:48:48 | 显示全部楼层
#Include <WinAPI.au3>

$hWid = 控件句柄
$CtrlID = _WinAPI_GetDlgCtrlID($hWid)
ControlClick("窗口标题", "窗口文本", '[ID:' & $CtrlID & "]")
 楼主| 发表于 2010-12-13 14:58:51 | 显示全部楼层
谢谢8楼我试试
 楼主| 发表于 2010-12-13 15:05:49 | 显示全部楼层
ControlClick("窗口标题", "",_WinAPI_GetDlgCtrlID("0x00050722"))
也不行
发表于 2010-12-13 15:20:02 | 显示全部楼层
ControlClick("窗口标题", "", "[ID:" & _WinAPI_GetDlgCtrlID(控件ID) & "]")
 楼主| 发表于 2010-12-13 15:27:53 | 显示全部楼层
ControlClick("窗口标题", "", "[ID:" & _WinAPI_GetDlgCtrlID(控件ID) & "]")
用ID也不行,用类别名可以,但是我想用句柄来单击控件
 楼主| 发表于 2010-12-13 15:29:26 | 显示全部楼层
请问11楼WinAPI_GetDlgCtrlID这个函数是什么用的
 楼主| 发表于 2010-12-13 15:33:29 | 显示全部楼层
GetDlgCtrlID accepts child window handles as well as handles of controls in dialog boxes. An application sets
the identifier for a child window when it creates the window by assigning the identifier value to the hmenu
parameter when calling the CreateWindow or CreateWindowEx function. Although GetDlgCtrlID may return a value
if $hWnd identifies a top-level window, top-level windows cannot have identifiers and such a return value is
never valid.
英文看不懂不知道啥意思
发表于 2010-12-13 16:40:24 | 显示全部楼层
楼主试试运行下面这个脚本,看有没有效果
#Include <WinAPI.au3>

Run("Notepad.EXE")
WinActivate("[CLASS:SciTEWindow]", "")
MsgBox(48,"已激活脚本编辑窗口","单击确定后将向记事本编辑框发送鼠标点击命令" & @CRLF & "注意看记事本编辑窗口是否有光标")
$HWND = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")                                                        ;取得记事本窗口 Edit1 控件的控件句柄
ControlClick("[CLASS:Notepad]", "", "[ID:" & _WinAPI_GetDlgCtrlID($HWND) & "]")
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-3 15:40 , Processed in 0.082133 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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