PDA

Click to See Complete Forum and Search --> : Sendmessage help needed please ?


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


;)

alex_read
Nov 19th, 2001, 02:54 AM
you've done this before ;)
Cheers - I was tearing my hear ouit at that one, I really should learn this API stuff properly :D

crispin
Nov 19th, 2001, 03:43 AM
No worries mate...

VBShipWreck
Nov 19th, 2001, 07:46 PM
get the hwnd of the edit control and send WM_SETTEXT to set the password. you could make it also login automatically, find the button hwnd and send WM_LBUTTONDOWN or whatever

da_silvy
Nov 20th, 2001, 02:14 AM
He's already solved it :rolleyes: