crispin
Nov 16th, 2001, 11:17 AM
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const ES_PASSWORD = &H20&
Private Const WM_SETTEXT As Long = &HC
Private Const BM_CLICK = &HF5
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) 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 ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
Dim hTxtWnd&
Dim lWndStyle&
Dim bFound As Boolean
Dim lngSIapp As Long, RetVal As Long, lpClassName As String
lngSIapp = FindWindow(vbNullString, "Connect to APS")
hTxtWnd = FindWindowEx(lngSIapp, 0&, "Edit", vbNullString)
Do While Not bFound
hTxtWnd = FindWindowEx(lngSIapp, hTxtWnd, "Edit", vbNullString)
lWndStyle = GetWindowLong(hTxtWnd, GWL_STYLE)
If lWndStyle And ES_PASSWORD Then
MsgBox "found password WIndow"
SendMessageString hTxtWnd, WM_SETTEXT, 0, "password"
bFound = True
lngSIapp = FindWindowEx(lngSIapp, 0&, "Button", "OK")
SendMessage lngSIapp, BM_CLICK, 0, 0
Exit Do
End If
Loop
End Sub
;)
Private Const GWL_STYLE = (-16)
Private Const ES_PASSWORD = &H20&
Private Const WM_SETTEXT As Long = &HC
Private Const BM_CLICK = &HF5
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) 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 ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
Dim hTxtWnd&
Dim lWndStyle&
Dim bFound As Boolean
Dim lngSIapp As Long, RetVal As Long, lpClassName As String
lngSIapp = FindWindow(vbNullString, "Connect to APS")
hTxtWnd = FindWindowEx(lngSIapp, 0&, "Edit", vbNullString)
Do While Not bFound
hTxtWnd = FindWindowEx(lngSIapp, hTxtWnd, "Edit", vbNullString)
lWndStyle = GetWindowLong(hTxtWnd, GWL_STYLE)
If lWndStyle And ES_PASSWORD Then
MsgBox "found password WIndow"
SendMessageString hTxtWnd, WM_SETTEXT, 0, "password"
bFound = True
lngSIapp = FindWindowEx(lngSIapp, 0&, "Button", "OK")
SendMessage lngSIapp, BM_CLICK, 0, 0
Exit Do
End If
Loop
End Sub
;)