0

Working on a quick Powershell script to use the IE object to enter values and submit a web page with a modal dialog. I want to be able to invoke the modal dialog, check some boxes on the dialog, and then close it and return to the page. I can invoke the modal dialog but nothing executes after the line to invoke the dialog until it is closed.

Powershell

$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true

$ie.navigate($url); do {sleep 1} until (-not ($ie.Busy)) 

$doc = $ie.Document
$books = $doc.getElementById(“searchBooks”).click();

Javascript

var ret = window.showModalDialog('selectBooks.aspx, books, ...);

I need a way to invoke commands in the context of the dialog. Tried running in the background and creating a runspace but no joy with either solution

& {$books = $doc.getElementById(“searchBooks”).click();}

(blocking)

$rs = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs.Open()

$rs.SessionStateProxy.SetVariable("doc", $doc)
$p = $rs.CreatePipeline( { $books = $doc.getElementById(“searchBooks”).click(); } )
$p.Input.Close()
$p.InvokeAsync()

(not blocking, but I didn't have a handle to dialog elements)

dr3x
  • 917
  • 2
  • 14
  • 26

1 Answers1

0

That's an expected behavior of the modal dialog. If you want to interact with a dialog, perhaps showModelessDialog() is what you want.

Teemu
  • 22,918
  • 7
  • 53
  • 106
  • Yes I understand the meaning of modal; that should be evident from two solutions I tried – dr3x Jan 29 '13 at 21:06