以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 按钮模拟点击问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=129321) |
-- 作者:bobolan521 -- 发布时间:2018/12/26 10:04:00 -- 按钮模拟点击问题 老师请问一下,代码要怎么修改,才可以模拟点击代码窗口中的退出按钮 现在只可以弹出指到窗口,但按钮找不到
Dim hwnd As IntPtr = FindWindow(Nothing, "代码窗口") If hwnd <> IntPtr.Zero Then msgbox("找到窗口") Dim btn = FindWindowEx(hwnd, 0, "WindowsForms10.BUTTON.app.0.378734a", "退出") If btn <> IntPtr.Zero Then msgbox("找到按钮") \'SendMessage(btn, &Hf5, 0, 0) End If End If 全局代码 <DllImport("user32.dll", EntryPoint := "FindWindow", SetLastError := True)> _ Public Function FindWindow(lpClassName As String, lpWindowName As String) As IntPtr End Function <DllImport("user32.dll", EntryPoint := "FindWindowEx", SetLastError := True)> _ Public Function FindWindowEx(hwndParent As IntPtr, hwndChildAfter As UInteger, lpszClass As String, lpszWindow As String) As IntPtr End Function <DllImport("user32.dll", EntryPoint := "SendMessage", SetLastError := True, CharSet := CharSet.Auto)> _ Public Function SendMessage(hwnd As IntPtr, wMsg As UInteger, wParam As IntPtr, lParam As String) As Integer End Function [此贴子已经被作者于2018/12/26 13:13:33编辑过]
|
-- 作者:有点蓝 -- 发布时间:2018/12/26 10:21:00 -- 上传具体实例测试 |
-- 作者:有点甜 -- 发布时间:2018/12/26 15:35:00 -- 看看是否你红色地方写错了?有没有英文快捷键的?
Dim btn = FindWindowEx(hwnd, 0, "WindowsForms10.BUTTON.app.0.378734a", "退出") |
-- 作者:bobolan521 -- 发布时间:2018/12/26 15:39:00 -- 甜老师,麻烦你看一下该如何写代码才能实现模拟点击另一个项目的按钮 |
-- 作者:有点甜 -- 发布时间:2018/12/26 20:32:00 --
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=129332&skin=0
|