Results 1 to 5 of 5

Thread: Sendmessage help needed please ?

  1. #1

    Thread Starter
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Code:
    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
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    you've done this before
    Cheers - I was tearing my hear ouit at that one, I really should learn this API stuff properly

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    No worries mate...
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4
    VBShipWreck
    Guest
    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

  5. #5
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    He's already solved it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width