header1   header
header
header : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
IMPORTANT: PowerShellCommunity.org is moving! - Wednesday, August 15, 2012

PowerShellCommunity.org is moving!  This community software, and the hardware that it sits on, are no longer serving the purposes of this community.  As a result, we have decided to move this community to a new home at PowerShell.org.  PowerShell.org is already up and running with the new community software and in its new location, so please post any new questions that you have on the forums over there instead of posting them on this site.  We've already started getting some great questions from members of the community over there so please, come on over and join us!

While we are going through this transition, this site will remain up for the short term.  New posts may no longer be created on these forums, however replies to existing posts are allowed so that users who posted questions don't have to re-post the same question on the new site.

[UPDATE 28/02/2013] New user registration has been disabled and forums have now been switched to read-only, including for existing posts since all threads that were started should now be completed. If you have a question about content on this site or about PowerShell in general, head over to PowerShell.org and ask it there where there are people actively using the site and answering questions.

If you have any questions, please let us know on the PowerShell.org site.

Thank you,

Kirk "Poshoholic" Munro

 
Get Currently Existent Object Not Created with New-Object
Last Post 04 Oct 2010 01:17 PM by Chris. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
ChrisUser is Offline
New Member
New Member
Posts:2
Avatar

--
04 Oct 2010 10:42 AM
    Basically I have a script where it logs into a site and browses to a particular page. It then clicks a link that opens a popup window. I'm trying to get the object (-com internetexplorer.application) of the new window that popped up.


    #init internet explorer window
    $oIE = New-Object -com internetexplorer.application;
    $oIE.visible = $true;

    #browse to site
    $oIE.navigate2("http://*****.com");

    while ($oIE.Busy -eq $true)
    {
        #Start-Sleep -Milliseconds 1000;
    }

    #input login info
    $oIE.Document.getElementById("username").value = "*******";
    $oIE.Document.getElementByID("password").value = "********";
    $oIE.Document.getElementById("login").Click();

    while ($oIE.Busy -eq $true)
    {
        Start-Sleep -Milliseconds 1000;
    }

    #browse to job task details page
    $oIE.navigate2("http://*****.com/index.php?action=route_job_task&method=edit&jtlid=1140560");

    while ($oIE.Busy -eq $true)
    {
        Start-Sleep -Milliseconds 1000;
    }

    #find and worksheet link
    $oLinks = @($oIE.document.getElementsByTagName("A"));

    foreach ($oLink in $oLinks)
    {
       if ($oLink.href -eq "http://*****.com/index.php?action=communications_log&mode=add&type=feedback&header=f&jtlid=1140560") {
           #THIS LINK IS A POPUP
           $oLink.click();
       }
    }

    while ($oIE.Busy -eq $true)
    {
        Start-Sleep -Milliseconds 1000;
    }

    #get add inspection window
    #I NEED THE INTERNETEXPLORER OBJECT THAT WAS JUST CREATED VIA THE POPUP
    #THE FOLLOWING GETS THE PROCESS, BUT IT'S NOT AN OBJECT LIKE I NEED

    $oReportForm = Get-Process | where {$_.mainWindowTItle -eq "Add Communication - Windows Internet Explorer"};

    while ($oReportForm.Busy -eq $true)
    {
        Start-Sleep -Milliseconds 1000;
    }

    #I NEED ACCESS TO A .DOCUMENT CONTAINER
    $oReportForm.Document.getElementById("message").value = "I NEED TO INPUT TEXT HERE";

    Start-Sleep -Milliseconds 20000;
    #$oIE.Quit();
    ChrisUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    04 Oct 2010 01:17 PM
    I think I found a solution...

    #get add inspection window
    $app = new-object -com shell.application;
    $oReportForm = $app.windows() | where {$_.LocationName -match "Add Communication"};


    While ($oReportForm.ReadyState -ne 4) { Start-Sleep -Seconds 1 }

    $oReportForm.Document.getElementById("subject").value = "ASDF";
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Many thanks to our original sponsors: Quest Software • SAPIEN Technologies • Compellent • Microsoft footer
    footer   footer