PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Using SendMessage with Internet Explorer-VBForums
Results 1 to 17 of 17

Thread: Using SendMessage with Internet Explorer

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Using SendMessage with Internet Explorer

    I'm trying to use the send message function with Internet Explorer to fill in a form for me automatically. Basically, I want to auto login to my credit card account.

    What I have so far. I substituted the standard VK_TAB for it's equivalent. But for some reason this code is not sending any tabs to the browser window. There are no error messages popping up though. Right now I'm at a loss and don't want to use SendKeys since it too does not work very well.


    VB Code:
    1. 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
    2.  
    3. Function Decide()
    4. Select Case varBank
    5.  
    6. Case "Merrill":
    7.  
    8. window1 = FindWindow(vbNullString, "Merrill Lynch Credit Card Access: Log In - Microsoft Internet Explorer")
    9.        
    10. SendMessage window1, &H100, &H9, 0&
    11. SendMessage window1, &H101, &H9, 0&
    12. SendMessage window1, &H100, &H9, 0&
    13. SendMessage window1, &H101, &H9, 0&
    14. SendMessage window1, &H100, &H9, 0&
    15. SendMessage window1, &H101, &H9, 0&
    16.  
    17. End Select
    18.  
    19. End Function

    Can anyone figure this out for me or write me a short snippet that will work?
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  2. #2
    Hyperactive Member
    Join Date
    Nov 2002
    Location
    Someplace 'ore the rainbow
    Posts
    392
    Why not embed the IE control in a project and just directly fill in the form?

    cjqp
    When your answer is the Arc Sin of 1.015, you should check your Pythagorean triple.

  3. #3
    Member
    Join Date
    Mar 2004
    Location
    Texas
    Posts
    53
    I'd try this, send the commands to the web page view instead of IE. Using spy++ i found that the class of IE is: "IEFrame". But it has the page view component, class name "Shell DocObject View" with no caption, then from that it has a class, "Internet Explorer_Server".

    Pseudo Code:
    *Get Desktop Handle using FindWindow

    *Get IE Handle using FindWindowEx (class name "IEFrame")

    *Get IE Handle component using FindWindowEx (class name "Shell DocObject View")

    *Get IE Handle sub componentusing FindWindowEx (class name "Internet Explorer_Server")

    *Then send a message to that last handle, and see if it works.

    Please let me know, I'll try this later and see if it'll work, I'll use VBForums as my guiene pig
    Good programming site:
    *http://www.planet-source-code.com

    Our CS Clan Page:
    *http://h2p.inter-gamer.com/index.html

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    You can also go to patorjk.com and download the API Spy. It's a good tool for getting handles...


    Has someone helped you? Then you can Rate their helpful post.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    Originally posted by Insane_Magician
    I'd try this, send the commands to the web page view instead of IE. Using spy++ i found that the class of IE is: "IEFrame". But it has the page view component, class name "Shell DocObject View" with no caption, then from that it has a class, "Internet Explorer_Server".

    Pseudo Code:
    *Get Desktop Handle using FindWindow

    *Get IE Handle using FindWindowEx (class name "IEFrame")

    *Get IE Handle component using FindWindowEx (class name "Shell DocObject View")

    *Get IE Handle sub componentusing FindWindowEx (class name "Internet Explorer_Server")

    *Then send a message to that last handle, and see if it works.

    Please let me know, I'll try this later and see if it'll work, I'll use VBForums as my guiene pig
    Unfortunately, that's way over my head. If you get it working post some code up if you would, I'd probably understand it then.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  6. #6

    Re: Using SendMessage with Internet Explorer

    can someone tell me if this works as i am trying to do the same

  7. #7
    Member
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    44

    Re: Using SendMessage with Internet Explorer

    This will get you one instance of Internet Explorer_Server Class.

    Module :
    VB Code:
    1. Option Explicit
    2.  
    3. Public lhwnd As Long 'holds target hWnd
    4. 'Window Caption:
    5. 'Window Class:   Internet Explorer_Server
    6. 'Parent Caption:
    7.  
    8. Private Declare Function GetDesktopWindow Lib "user32" () As Long
    9.  
    10. Private Declare Function GetWindow Lib "user32" _
    11.   (ByVal hwnd As Long, _
    12.    ByVal wCmd As Long) As Long
    13.  
    14. Private Declare Function GetWindowText Lib "user32" _
    15.    Alias "GetWindowTextA" _
    16.   (ByVal hwnd As Long, _
    17.    ByVal lpString As String, _
    18.    ByVal cch As Long) As Long
    19.  
    20. Private Declare Function GetClassName Lib "user32" _
    21.    Alias "GetClassNameA" _
    22.   (ByVal hwnd As Long, _
    23.    ByVal lpClassName As String, _
    24.    ByVal nMaxCount As Long) As Long
    25.  
    26. Private Declare Function GetParent Lib "user32" _
    27.     (ByVal hwnd As Long) As Long
    28.  
    29. Private Const GW_HWNDNEXT = 2
    30. Private Const GW_CHILD = 5
    31.  
    32. Public Sub FindWindowLike(ByVal hWndStart As Long, _
    33.                                 ParentText As String, _
    34.                                 ClassName As String)
    35.  
    36.     Dim hwnd As Long
    37.     Dim lhWndParent As Long
    38.     Dim sClassName As String
    39.     Dim sParentTitle As String
    40.     Static level As Integer
    41.  
    42.         ' Initialize if necessary.
    43.         If level = 0 Then
    44.             If hWndStart = 0 Then hWndStart = GetDesktopWindow()
    45.         End If
    46.  
    47.         ' Increase recursion counter
    48.         level = level + 1
    49.        
    50.         ' Get first child window
    51.         hwnd = GetWindow(hWndStart, GW_CHILD)
    52.  
    53.         Do Until hwnd = 0
    54.             ' Search children by recursion
    55.             Call FindWindowLike(hwnd, ParentText, ClassName)
    56.             sClassName = Space$(255)
    57.             Call GetClassName(hwnd, sClassName, 255)
    58.             sClassName = Left(sClassName, 24)
    59.             ' Get window parent
    60.             lhWndParent = GetParent(hwnd)
    61.             ' Get parent window caption
    62.             Call GetWindowText(lhWndParent, sParentTitle, 255)
    63.             ' Check if window found matches the correct class
    64.             If sClassName Like ClassName Then
    65.             ' Check if parent window caption matches
    66.             If sParentTitle = ParentText Then
    67.                     lhwnd = hwnd
    68.                 End If
    69.                 Exit Do
    70.             End If
    71.             ' Get next child window
    72.             hwnd = GetWindow(hwnd, GW_HWNDNEXT)
    73. Loop
    74. ' Reduce the recursion counter
    75. level = level - 1
    76. End Sub
    Form:
    VB Code:
    1. Private Sub Cmd_Click()
    2.     Dim sParentText As String, sClassToFind As String
    3.         ' Set parent caption to find
    4.         sParentText = ""
    5.         ' Set window class to find
    6.         sClassToFind = "Internet Explorer_Server"
    7.         Call FindWindowLike(0, sParentText, sClassToFind)
    8.         '***lhwnd now = Target Class hWnd****
    9.                
    10. End Sub

    Hope that helps

    $hep
    Last edited by $hep; Apr 29th, 2005 at 10:30 PM.

  8. #8

    Re: Using SendMessage with Internet Explorer

    thank you but it doesnt like
    VB Code:
    1. Public Declare Function GetDesktopWindow Lib "user32" () As Long
    and
    VB Code:
    1. Public Const GW_HWNDNEXT = 2
    2. Public Const GW_CHILD = 5

    and what is the variable i would postmessage to?

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Using SendMessage with Internet Explorer

    Look at this example. It fills in a textbox and clicks a button.

    http://www.vbforums.com/attachment.p...chmentid=35693

  10. #10
    Member
    Join Date
    Mar 2004
    Location
    Florida
    Posts
    44

    Re: Using SendMessage with Internet Explorer

    Sorry I didn't make it clear..
    See above code again I modified it.
    And the hWnd variable for SendMessage\PostMessage = lhwnd ,
    after calling FindWindowLike(0, sParentText, sClassToFind)

    $hep

  11. #11

    re:Using SendMessage with Internet Explorer

    Quote Originally Posted by dglienna
    Look at this example. It fills in a textbox and clicks a button.

    http://www.vbforums.com/attachment.p...chmentid=35693
    u are a genius!!!!!!!!!! worked like a champ

    thx for yalls help
    Last edited by PaPPy; Apr 30th, 2005 at 01:17 AM.

  12. #12

    Re: Using SendMessage with Internet Explorer

    i retract my last post sorry i spoke too soon
    dglienna code helped until i relized it used sendkeys which i cant cause send keys needs program to be active window
    $hep this is what i have and it doesnt seem to work
    i use spy++ to see the messages being passed and no luck

    VB Code:
    1. Dim sParentText As String, sClassToFind As String
    2.         ' Set parent caption to find
    3.         sParentText = "Vernier Secure Logon - Microsoft Internet Explorer"
    4.         ' Set window class to find
    5.         sClassToFind = "Internet Explorer_Server"
    6.         Call FindWindowLike(0, sParentText, sClassToFind)
    7.         '***lhwnd now = Target Class hWnd****
    8.         Call SendMessage(lhwnd, WM_KEYDOWN, VK_RETURN, 0&) 'Enter
    9.         'Call PostMessage(lhwnd, WM_KEYDOWN, VK_RETURN, 0&) 'Enter

    im sorry again any more help will be grateful

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Using SendMessage with Internet Explorer

    It used DOM, not sendkeys.

  14. #14

    Re: Using SendMessage with Internet Explorer

    DOM? this is the line that pushes enter. in the code you posted

    VB Code:
    1. SendKeys "{ENTER}", True

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Using SendMessage with Internet Explorer

    Oops. Gave you the old version.. Try this one. It doesn't use sendkeys.
    Attached Files Attached Files

  16. #16

    Re: Using SendMessage with Internet Explorer

    question what if there are 2 forms on the page
    VB Code:
    1. 'Submit the first (and only) form in the page
    2. WebBrowser1.Document.Forms.Item(0).submit

    and i need to submit the second form on the page
    i tried changing the value to 1 but that iddnt work i tried changing it to the name of the form but no luck either

  17. #17
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Using SendMessage with Internet Explorer

    Not too sure. TheVader is the resident expert on DOM, but I have a link to this website that catalogs all the information. Hope it's sufficient

    http://msdn.microsoft.com/workshop/a...ence_entry.asp

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width