首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

请教怎么才能捕获其他软件的弹出消息框(选择是、否的消息框),并且回应是/否

2012-03-16 
请问如何才能捕获其他软件的弹出消息框(选择是、否的消息框),并且回应是/否?比如别的软件弹出是否退出,我用

请问如何才能捕获其他软件的弹出消息框(选择是、否的消息框),并且回应是/否?
比如别的软件弹出是否退出,我用VB想回是。

[解决办法]
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
Private Declare Function FindWindow Lib "user32 " Alias "FindWindowA " (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32 " Alias "SendMessageA " (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const BM_CLICK = &HF5

Private Sub Command1_Click()
Dim h As Long
h = FindWindow( "#32770 ", "工程1 ") '工程1 是哪个对话框的标题
Debug.Print Hex(h)
h = FindWindowEx(h, 0, "button ", "确定 ") '确定 是哪个对话框上的按钮的文字
Debug.Print Hex(h)
SendMessage h, BM_CLICK, 0, ByVal 0&
SendMessage h, BM_CLICK, 0, ByVal 0&

End Sub

热点排行