高分求一段代码,在线等
要求:
1.列举所有已经提前开启的程序,找到名称为a.exe的文件(这个文件的标题是随时在改变的).
2.a.exe有N个edit,我需要得到最后一个edit(内容未知),输入文本:hello,然后Enter发送
请为我提供详细的vb源码,谢谢!
受限于等级只能提供100分悬赏,如果分数不够我可以开新帖子追加100分.
[最优解释]
列举所有已经提前开启的程序,找到名称为a.exe的文件-----这个简单
后边这个……这个要钩子……
[其他解释]
对,思路我知道,但我不是vb程序员,,我只需要源码
[其他解释]
我写了一段代码,但是不知道为何,如果产生出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 Session
Private 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 = 12
Public 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) + "