CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2008
    Posts
    16

    Navigation within a webpage

    Hi Gurus,

    My application (coded in C#) navigates to a webpage which contains a drop down box.

    Can I code it to repeat certain keystrokes from here ... for example, 7 DOWN, TAB, ENTER, 5 TAB, 3 DOWN, TAB, etc. ... basically to maybe run a macro to replay certain predefined keystrokes.

    Is this possible in C#?

    Your expert comments are eagerly awaited.

    Thks

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Navigation within a webpage

    It is possible; however, if you don't own the webpage, it can be unreliable (because the owners of the webpage can change the content and break the macro).

  3. #3
    Join Date
    Aug 2008
    Posts
    16

    Re: Navigation within a webpage

    Thanks Arjay.

    I agree it is not the ideal way to do it .... but operationally passing the values to the webpage is not working. Hence the macro concept.

    Any leads on how to actually get this coded?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Navigation within a webpage

    If you have a relationship with the webpage authors, the simplest way would be to get them to fix the issue (or let you know the proper parameters).

    Doing this automatically can be done leveraging UI Automation and Active Accessibility.

    I must warn you: Active Accessibility has a fairly steep learning curve.

  5. #5
    Join Date
    Aug 2008
    Posts
    16

    Re: Navigation within a webpage

    Thanks Arjay.

    Unfortunately the website is a third party website and hence I am not able to make much progress on that front.

    Will try and learn about UI automation and see if I can work out something simple for this.

    If you can help in guiding me, it would be great.

    My actual requirement has been posted under http://www.codeguru.com/forum/showthread.php?t=458899

    where I have an attachment detailing my requirement.

    If you can suggest any alternatives, I am eager to hear them.

    Thanks once again for your response.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Navigation within a webpage

    Read up on the UI Automation and Active Accessibility (AA) link I sent you.

    You'll also want to download the Active Accessibility 2.0 SDK Tools.

    The tools include a AccExplorer tool which is the Active Accessibility equivalent of Spy++.

    The reason I suggest using AA is because an html control doesn't show up as a regular Windows window (just like individual items in a tree or list control do not as well). Active Accessibility (AA) has the ability to manipulate these controls that don't show up as regular windows.

    What you need to do is retrieve the parent AA hierarchy of the control that you wish to manipulate. You'll use the AccExplorer tool to retrieve this. You'll want to start at the control and record the AA hierarchy until you run into a 'real' window. Once you find a real window, you follow it's hierarchy until you reach the top level application window of the browser. This will be different for different browsers.

    For example, if I want to log into hotmail. I need to first click on the hotmail link on http://www.msn.com before it takes me to the actual log on page.

    In order to click on the link with AA, I need to grab it's hierarchy. So I use the AccExplorer32.exe tool:

    Code:
    http://www.msn.com/    Top level of AA hierarchy (this node has real window parent)
     L MSN.com
      L Hotmail                      Link we want to click on

    Window hierarchy ( windows classes listed )
    Code:
    IEFrame
     L TabWindowClass
      L Shell DocObject View
       L Internet Explorer_Server
    So now that we have this information, we would use a combination of Windows api's such as EnumChildWindows and FindWindowEx to locate the top level window of IExplore and then walk the hierarchy down to locate the lowest window (class Internet Explorer_Server).

    Once we have the lowest class, then we start using the Active Accessibility api's to walk the AA hierarchy until we reach the 'Hotmail' node.

    From there we can use AA to click on the node.

    We'd repeat the same process on the logon page to locate the email and password edit boxes and the submit button.

    As I said, it's a bit of a learning curve.

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

Featured