VB出发其他程序中的某个按钮
3个回答
展开全部
哈哈,这个简单:
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Private Public Const BM_CLICK = &HF5
Private Sub Command1_Click()
SendMessage Text1.Text, &HF5, 0, ByVal 0
End Sub
TEXT里写句柄,然后就OK拉!
找按妞句柄用Findow函数,子窗口用FindWindowEx
声明如下:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
然后根据窗口标题、类名什么的一层层找!
比如查找一个默认标题的txt文本框
Dim h1 As Long
Dim h2 As Long
h1 = FindWindow(vbNullString, "无标题 - 记事本") 'vbNullString 是类名,"无标题 - 记事本" 是窗体名
h2 = FindWindowEx(h1, 0&, "edit", vbNullString) '父窗口句柄 子窗口句柄,如果为NULL就从第一个开始找(0& 表示无) 类名 窗体名
h1是TXT的句柄,h2是TXT编辑区域的句柄!
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Private Public Const BM_CLICK = &HF5
Private Sub Command1_Click()
SendMessage Text1.Text, &HF5, 0, ByVal 0
End Sub
TEXT里写句柄,然后就OK拉!
找按妞句柄用Findow函数,子窗口用FindWindowEx
声明如下:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
然后根据窗口标题、类名什么的一层层找!
比如查找一个默认标题的txt文本框
Dim h1 As Long
Dim h2 As Long
h1 = FindWindow(vbNullString, "无标题 - 记事本") 'vbNullString 是类名,"无标题 - 记事本" 是窗体名
h2 = FindWindowEx(h1, 0&, "edit", vbNullString) '父窗口句柄 子窗口句柄,如果为NULL就从第一个开始找(0& 表示无) 类名 窗体名
h1是TXT的句柄,h2是TXT编辑区域的句柄!
展开全部
在该窗体中寻找你要触发的按钮的句柄
然后模拟鼠标点击,给它sendmessage
然后模拟鼠标点击,给它sendmessage
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
找到那个程序按钮的句柄 可用spy++ 查出来
然后用sendmassage发送一个点击命令
然后用sendmassage发送一个点击命令
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询