SHDocVw & MSHTML dom - Popup menu problem

S

SQACSharp

I'm trying to automate an action in Internet Explorer.... I'm trying
to click an image that open a popup menu. The html code of the iimage
look like like <img blabla..OnClick="ShowMenu()"/>

I can click the image but my application is "sleeping" until I
manually click an item in the popup menu.

My code :

//--------------------------------//
using mshtml;
using SHDocVw;
...
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();
SHDocVw.IWebBrowserApp ObjBrowser = (SHDocVw.IWebBrowserApp)ie;
ObjBrowser.Visible = true;
object noValue = System.Reflection.Missing.Value;
object noValue1 = System.Reflection.Missing.Value;
ie.Navigate("http://www.blabla.com", ref noValue, ref noValue, ref
noValue, ref noValue);
System.Threading.Thread.Sleep(1000);
WaitForReadyState(); not included in this example
HTMLImgClass Image =
(HTMLImgClass)ie.document.getElementById("MyImageId");
Image.click(); // a PopupMenu is displayed after clicking the
object
MessageBox.Show("This message box is displayed only after manually
select an item in the popupmenu")
//--------------------------------//

Question 1 - Is there any way to have the messagebox displayed
immediatly after clicking the image...what is missing? look like my
click is waiting for something...

Question 2 - Is there any way to access to this popup menu ?> what
kind of object it is??

Question 3 - Why this popup menu is not the in the HTML page? When
doing a view source i cant see anything about this popup menu, no
ShowMenu definition or javascript function/include...

Thanks for your help...
 
S

SQACSharp

Still need help :( ... At least I need to be able to do the
Image.click(); without having my c# application completely suspended
until a selection is done in the popupmenu
 
N

Nicholas Paldino [.NET/C# MVP]

It's hard to say what is going on. Without seeing the Javascript code
for ShowMenu, it's impossible to say what exactly is going on.
 
S

SQACSharp

It's hard to say what is going on. Without seeing the Javascript code
for ShowMenu, it's impossible to say what exactly is going on.

We can assume that the javascript function return the hand to the
caller only after a selection is made in the popupmenu.

I suppose we will get the same result if the javascript function was
"WaitUntilForever" with code like "do while(true) //infinitive loop

Here is the javascript code for ShowMenu :

function ModalPopUp(items,xpos,ypos) {
alert('Custom Controls are not Installed.');
return false;
popupHeight = items.length * 17 + 32;
popupWidth = 0;
for (i=0; i<items.length; i++) {
stringWidth = 5.5 * items.length;
if (stringWidth > popupWidth) {
popupWidth = stringWidth;
}
}

popupWidth = Math.floor(popupWidth+25);

if (event) {
top.ActiveEvent = event;
}

if (!xpos) {
try {
xpos = top.ActiveEvent.screenX;
} catch (ee) { xpos=1; }
}
if (!ypos) {
try {
ypos = top.ActiveEvent.screenY;
} catch (ee) { ypos=1; }
}

return window.showModalDialog(top.BASE_HREF + '/blablabla/
modalmenu.html',items,
'dialogTop:'+ypos+'px;dialogLeft:'+xpos+
'px;dialogHeight:'+popupHeight+'px;dialogWidth:'+popupWidth
+'px;help:no;status:no;scroll:no;title:no');
}

function ShowMenu(menuName,xpos,ypos) {
try {
if (xpos && ypos) {
paramtext = "xpos,ypos";
} else {
paramtext = '';
}
eval(menuName + ".PopUp("+paramtext+")");
} catch (e) {
eval("val = ModalPopUp(" + menuName +
"Items.toArray(),xpos,ypos);");

if (val>0) {
try {
eval(menuName + "_Click(val)");
} catch (e1) {}
}
}
}


Is it possible to access and interract with a window.showModalDialog
with DOM or something else???

thanks!
 
S

SQACSharp

i'm completely stock with this... is there any trick or a workaround
to select an item in this menu or at least being able to continue to
the next line of code?? When doing image.click() i will get the
control in my code only after a selection is made in the menu...

I really need help on this...

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top