要求:
1.列举所有已经提前开启的程序,找到名称为a.exe的文件(这个文件的标题是随时在改变的).
2.a.exe有N个edit,我需要得到最后一个edit(内容未知),输入文本:hello,然后Enter发送请为我提供详细的vb源码,谢谢!受限于等级只能提供100分悬赏,如果分数不够我可以开新帖子追加100分.

解决方案 »

  1.   

    列举所有已经提前开启的程序,找到名称为a.exe的文件-----这个简单后边这个……这个要钩子……
      

  2.   

    我写了一段代码,但是不知道为何,如果产生出exe文件就一切正常,但是如果封装成dll文件用B/S语言调用的时候就是不成功!
    Option Explicit
    Private MyScriptingContext As ScriptingContext
    Private MyApplication As Application
    Private MyRequest As Request
    Private MyResponse As Response
    Private MyServer As Server
    Private MySession As SessionPrivate Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) 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
    Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
                    
    Private Const GW_CHILD = &H5
    Private Const GW_HWNDNEXT = &H2
    Private Const WM_SETTEXT = 12Public Function Outuser(user As String) As Boolean
        Dim tmp As String
        Dim wHwnd As Long
        Dim lngProcID As Long
        Dim strTitle As String * 255 '用来存储窗口的标题
        Dim hwnd As Long
       
        wHwnd = GetDesktopWindow() '取得桌面窗口句柄
        wHwnd = GetWindow(wHwnd, GW_CHILD) '取得桌面窗口的第一个子窗口
        '通过循环来枚举所有的窗口
        Do While wHwnd <> 0&
            Call GetWindowText(wHwnd, strTitle, Len(strTitle)) '取得下一个窗口的标题
            If Left$(strTitle, 1&) <> vbNullChar Then
                tmp = Left$(strTitle, InStr(1&, strTitle, vbNullChar))
                If IsWindowVisible(wHwnd) > 0& And Left(tmp, 5) = "user:" Then
                    hwnd = wHwnd
                    'Form1.List1.AddItem "句柄:" + Trim(Str(wHwnd)) + " | 左4:" + Left(tmp, 4) + " | 标题:" + tmp
                    Exit Do
                End If
            End If
            wHwnd = GetWindow(wHwnd, GW_HWNDNEXT) '继续取得下一个窗口
        Loop
       
        If hwnd <> 0 Then
            Dim i, hnd, lngLength
            hnd = FindWindowEx(hwnd, hnd, "edit", vbNullString)
            Call SendMessageStr(hnd, WM_SETTEXT, 0, ByVal "取得桌面窗口的第一个子窗口取得桌面窗口的第一个子窗口")
            Call PostMessage(hwnd, &H100, 13, 0)  'enter
            'Call SendMessageStr(hnd, WM_SETTEXT, 0, ByVal "")
            Outuser = True
        Else
            Outuser = False
        End If
    End Function
     
    Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
        Set MyScriptingContext = PassedScriptingContext
        Set MyApplication = MyScriptingContext.Application
        Set MyRequest = MyScriptingContext.Request
        Set MyResponse = MyScriptingContext.Response
        Set MyServer = MyScriptingContext.Server
        Set MySession = MyScriptingContext.Session
    End SubPublic Sub OnEndPage()
        Set MyScriptingContext = Nothing
        Set MyApplication = Nothing
        Set MyRequest = Nothing
        Set MyResponse = Nothing
        Set MyServer = Nothing
        Set MySession = Nothing
    End Sub
      

  3.   

    regsvr32注册之后,用B/S语言调用Outuser这个方法输出的结果永远都是false
    另外那个exe的edit里也没有被输入或发送任何内容
    我怀疑是枚举句柄的时候就失败了.