Access newly created tab

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 3 months ago.

  • Author
    Posts
  • #5588

    by perryworld at 2013-02-25 03:03:44

    Hi All,

    As part of our process we open a new tab which contains a printer friendly version of our report but then when we try to print the page it still has focus on the originating page and not the newly created page. How would we get a handle on the new page so we can print it and then close it.

    Any help appreciated

    Thanks
    Richard

    by poshoholic at 2013-02-25 11:03:57

    Hi Richard,

    Could you provide some more detail? The question seems to be missing context as is (open a new tab in what application? what are you automating?).

    Thanks,

    by perryworld at 2013-02-25 12:35:36

    Sorry Kirk,

    We are using Internet explorer and when we open our web site we navigate to one of our reports, the next step is to select the print button and click it.
    This opens the printer friendly version of the report. I've read somewhere in google that you can use navigate2 but we open the page by clicking the print button.
    Once the printer friendly page is open in the new tab we need to access that tab so we can print it and then close it. This is a process that loops through several reports so we need to automate it.

    Hope that makes it a bit clearer

    Thanks
    Richard

    by poshoholic at 2013-02-25 19:36:52

    Hi Richard,

    That helps. I haven't figured out all of the pieces, but I did get part way there. You were looking for the handle for the new page. Here is how you can get that:
    # Create an IE instance
    $ie = New-Object -ComObject InternetExplorer.Application
    # Open a tab
    $ie.Navigate('www.microsoft.com')
    # Show IE
    $ie.Visible = $true
    # Now open another tab (this is in the background)
    $ie.Navigate2('www.powershell.org',0x1000)
    # To get the information for the second tab, do this:
    $sa = New-Object -ComObject Shell.Application
    $secondTab = $sa.Windows() | Where-Object {$_.LocationUrl -match 'powershell\.org'}
    # Here is the handle for that tab
    $secondTab.HWND
    # And all properties
    $secondTab

    I'm at a loss right now on where to go from here, and I don't have time to dig in deeper. Does this get you closer to what you need?

    by perryworld at 2013-02-26 05:18:03

    Thanks Kirk

    I will give it a try and let you know.

    Thanks for your help,
    Richard

You must be logged in to reply to this topic.