Foxtable(狐表)用户栏目专家坐堂 → 按钮模拟点击问题


  共有2352人关注过本帖平板打印复制链接

主题:按钮模拟点击问题

帅哥,在线噢!
bobolan521
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:637 积分:7332 威望:0 精华:1 注册:2013/11/26 7:49:00
按钮模拟点击问题  发帖心情 Post By: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编辑过]

 回到顶部