lxwlxwayy 发表于 2010-12-13 13:06:07

如何根据控件句柄实现控件单击

如何根据控件句柄实现控件单击
麻烦好心人给个例子,谢谢{:face (197):}

lxwlxwayy 发表于 2010-12-13 14:08:18

没人知道吗

yhxhappy 发表于 2010-12-13 14:16:06

用 控件ID 不行吗,非要 控件句柄

menfan1 发表于 2010-12-13 14:26:50

ControlClick("", "", "MDIClient1")

lxwlxwayy 发表于 2010-12-13 14:30:53

谢谢两位,由于一些原因我想用句柄来单击控件

lxwlxwayy 发表于 2010-12-13 14:33:55

听说_WinAPI_PostMessage函数可以实现用句柄单击控件,可是不会用

lxwlxwayy 发表于 2010-12-13 14:35:26

#Include <WinAPI.au3>
_WinAPI_PostMessage("0x00050722(控件句柄)", "", "Click", "1")
这代码不行

yhxhappy 发表于 2010-12-13 14:48:48

#Include <WinAPI.au3>

$hWid = 控件句柄
$CtrlID = _WinAPI_GetDlgCtrlID($hWid)
ControlClick("窗口标题", "窗口文本", '")

lxwlxwayy 发表于 2010-12-13 14:58:51

谢谢8楼我试试

lxwlxwayy 发表于 2010-12-13 15:05:49

ControlClick("窗口标题", "",_WinAPI_GetDlgCtrlID("0x00050722"))
也不行

yhxhappy 发表于 2010-12-13 15:20:02

ControlClick("窗口标题", "", "控件ID) & "]")

lxwlxwayy 发表于 2010-12-13 15:27:53

ControlClick("窗口标题", "", "")
用ID也不行,用类别名可以,但是我想用句柄来单击控件

lxwlxwayy 发表于 2010-12-13 15:29:26

请问11楼WinAPI_GetDlgCtrlID这个函数是什么用的

lxwlxwayy 发表于 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.
英文看不懂不知道啥意思

yhxhappy 发表于 2010-12-13 16:40:24

楼主试试运行下面这个脚本,看有没有效果#Include <WinAPI.au3>

Run("Notepad.EXE")
WinActivate("", "")
MsgBox(48,"已激活脚本编辑窗口","单击确定后将向记事本编辑框发送鼠标点击命令" & @CRLF & "注意看记事本编辑窗口是否有光标")
$HWND = ControlGetHandle("", "", "Edit1")                                                        ;取得记事本窗口 Edit1 控件的控件句柄
ControlClick("", "", "")
页: [1] 2 3
查看完整版本: 如何根据控件句柄实现控件单击