等有空了,先出个手动版的。。 作者: 西红柿炒番茄。 时间: 2012-11-27 17:14
技术帖作者: 华灯初上。 时间: 2012-11-27 17:16 作者: shinshen 时间: 2012-11-27 17:18 作者: 发烧30度 时间: 2012-11-27 17:20
又见大神新作,,,作者: CHAN.S 时间: 2012-11-27 17:20
代码:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) 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, _
ByVal lParam As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam 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 GetDlgItem Lib "user32" ( _
ByVal hDlg As Long, _
ByVal nIDDlgItem As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" ( _
ByVal dwMilliseconds As Long)
Public Const KEY_ENTER = 13
Public Const TEXT_STATE = "状态:"
Private Function OpenNetKeeper() As Boolean
Dim sysdrive As String
Dim path As String
Dim state As Long
Dim location As String
sysdrive = Environ("SYSTEMDRIVE")
path = sysdrive & "\ChinaNetSn\bin\Netkeeper.exe"
location = sysdrive & "\ChinaNetSn\bin\"
state = IIf(Dir(path) <> "", ShellExecute(vbNull, "open", path, vbNullString, location, SW_SHOWNORMAL), 0)
If state < NUM_ERROR Then OpenNetKeeper = False: Exit Function
Do
mhandle = FindWindow("#32770_nkDialog_{6E1C7E0B-9380-4f69-A8D8-393F70589DE1}", vbNullString) '闪讯
DoEvents
Loop Until mhandle <> 0
Call PostMessage(mhandle, WM_SYSCOMMAND, SC_MINIMIZE, vbNull)
OpenNetKeeper = True
End Function
Private Function SendPassword() As Boolean
Dim phandle As Long
Dim password As String
Sleep (100) '等待
DoEvents
chandle = FindWindowEx(mhandle, 0&, "#32770", vbNullString)
phandle = GetDlgItem(chandle, &H412)
password = Fmain.Tpass.Text
If password = vbNullString Then SendPassword = True: Exit Function '静态密码
If phandle <> 0 Then Call PostMessage(phandle, WM_SETTEXT, 0, ByVal password) Else SendPassword = False: Exit Function
SendPassword = True
End Function
Private Function Login() As Boolean
Dim bhandle As Long
bhandle = GetDlgItem(chandle, &H3F2)
If bhandle <> 0 Then
PostMessage bhandle, WM_LBUTTONDOWN, ByVal 0&, ByVal 0&
PostMessage bhandle, WM_LBUTTONUP, ByVal 0&, ByVal 0&
Else
Login = False: Exit Function
End If
Login = True
End Function
Private Sub Minimize()
Dim ahandle As Long
Do
ahandle = FindWindowEx(mhandle, 0&, "AfxWnd42", vbNullString)
DoEvents
Loop Until ahandle <> 0
SendMessage mhandle, WM_CLOSE, ByVal 0&, ByVal 0&
End Sub
Public Function OperateNetKeeper() As Boolean
If Not OpenNetKeeper() Then OperateNetKeeper = False: Exit Function
If Not SendPassword() Then OperateNetKeeper = False: Exit Function
If Not Login() Then OperateNetKeeper = False: Exit Function
Call Minimize
'MsgBox "Finished!", , ""
OperateNetKeeper = True
End Function作者: wjk2002 时间: 2012-11-27 17:22
不是说动态密码么作者: CHAN.S 时间: 2012-11-27 17:24