Page 2 of 2 FirstFirst 12
Results 41 to 53 of 53

Thread: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

  1. #41

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Fazi that works great.

    Can you help me make a function for this program? its a lot easier. I can already submit the button "Check email"

    Here is a screenshot:
    http://img370.imageshack.us/img370/4572/lastph2.jpg

    you have to access the group container that it is in.

    This is the code im using to press the "check email" button:

    Private Declare
    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
    Private Const BM_CLICK As Long = &HF5&
    
    Private Const WM_SETTEXT = &HC
    
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) 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 SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    The function
    Code:
    Private Sub SendSubmit()
    On Error Resume Next
     Dim WinWnd As Long
        Dim Ret As Long
        Dim ErrNum As Integer
        
        'Find window Handle
        WinWnd = FindWindow(vbNullString, "email poster")
        
        If WinWnd <> 0 Then
            'Show the form
            'AppActivate "email poster"
            'Find button handle by going through every child control in the form
            EnumChildWindows WinWnd, AddressOf EnumChildProc, ByVal 0&
            
            If BtnHwnd <> 0 Then
                'Send the Message
                Ret = SendMessage(BtnHwnd, BM_CLICK, 0, 0&)
            Else
                ErrNum = 2  'Button was not found
            End If
        Else
            ErrNum = 1  'Window was not found
        End If
        
        'Errors
        Select Case ErrNum
            Case 1
                Me.Caption = "Window handle could not be found"
            Case 2
                Me.Caption = "Button was not found on form"
        End Select
    End Sub
    and the module:
    Code:
    Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Public BtnHwnd As Long
    Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
        Dim sSave As String
        'Get the windowtext length
        sSave = Space$(GetWindowTextLength(hwnd) + 1)
        'get the window text
        GetWindowText hwnd, sSave, Len(sSave)
        'remove the last Chr$(0)
        sSave = Left$(sSave, Len(sSave) - 1)
        
        If sSave = "Check email" Then
            BtnHwnd = hwnd
            Exit Function
        End If
        'continue enumeration
        EnumChildProc = 1
    End Function

    Right now it just hits the "check email" button. can you make it send the email/popserver/password text that is located on another form/program?

  2. #42
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    you want to grab the email/pop../pass etc located in an external program and past in to this programs relevant box's?

  3. #43

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Quote Originally Posted by Fazi
    you want to grab the email/pop../pass etc located in an external program and past in to this programs relevant box's?
    Correct!

  4. #44
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    you need to use the WM_GETTEXT AND WM_SETTEXT Messages with SendMessage(). give a try

  5. #45

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Quote Originally Posted by Fazi
    you need to use the WM_GETTEXT AND WM_SETTEXT Messages with SendMessage(). give a try
    I have tried, believe me. LOL

    For over a week!
    Last edited by penagate; Sep 24th, 2007 at 04:12 AM. Reason: removed offer of payment

  6. #46
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    thud,
    ill post you the codes. but i need little time as i am busy out here.
    ok

  7. #47

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Quote Originally Posted by Fazi
    thud,
    ill post you the codes. but i need little time as i am busy out here.
    ok
    No problem, I don't mean to sound like I'm rushing you.

    I very much appreciate your help.

  8. #48

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Just let me know

  9. #49
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Thud, making a complete project is imposible dear,
    this is the code you requir to Get the text from a control and then Set it to another control. you no how to ritriv the handle of the window that contain the text.

    Code:
    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 Const WM_SETTEXT = &HC
    Private Const WM_GETTEXT = &HD
    
    
    Private Sub Command1_Click()
    'this code will retrive the text from a text box in to the StrBuff variable
    Dim StrBuff As String * 255
    SendMessage hwnd, WM_GETTEXT, 255, StrBuff
    'strbuffer is the buffer where the text ritrived will be copied
    '255 is the number of charactors to copy in to the strbuffer.
    
    'This code will set the text in to a text box
    SendMessage hwnd, WM_SETTEXT, 0, ByVal StrBuff
    
    End Sub

  10. #50

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Quote Originally Posted by Fazi
    Thud, making a complete project is imposible dear,
    this is the code you requir to Get the text from a control and then Set it to another control. you no how to ritriv the handle of the window that contain the text.

    Code:
    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 Const WM_SETTEXT = &HC
    Private Const WM_GETTEXT = &HD
    
    
    Private Sub Command1_Click()
    'this code will retrive the text from a text box in to the StrBuff variable
    Dim StrBuff As String * 255
    SendMessage hwnd, WM_GETTEXT, 255, StrBuff
    'strbuffer is the buffer where the text ritrived will be copied
    '255 is the number of charactors to copy in to the strbuffer.
    
    'This code will set the text in to a text box
    SendMessage hwnd, WM_SETTEXT, 0, ByVal StrBuff
    
    End Sub
    Fazi, can I send you the program.

  11. #51
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    thud,
    what is the trouble now?

  12. #52

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    Quote Originally Posted by Fazi
    thud,
    what is the trouble now?
    The trouble is that I don't know what I'm doing.

    LOL

  13. #53
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"

    I thinkg you really solved that connection issue which is the topic of this thread. is it? if it so, i recommend you to make this thread Resolved and create a new fresh thread and clearly explain your next problem.

Page 2 of 2 FirstFirst 12

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