all groups > c# > april 2007 >
You're in the

c#

group:

SHDocVw & MSHTML dom - Popup menu problem


SHDocVw & MSHTML dom - Popup menu problem SQACSharp
4/8/2007 11:42:57 PM
c#:
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...
Re: SHDocVw & MSHTML dom - Popup menu problem SQACSharp
4/9/2007 12:29:40 PM
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



Re: SHDocVw & MSHTML dom - Popup menu problem SQACSharp
4/9/2007 3:17:44 PM
On 9 avr, 16:45, "Nicholas Paldino [.NET/C# MVP]"
[quoted text, click to view]

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[i].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!
Re: SHDocVw & MSHTML dom - Popup menu problem Nicholas Paldino [.NET/C# MVP]
4/9/2007 4:45:19 PM
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.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

Re: SHDocVw & MSHTML dom - Popup menu problem SQACSharp
4/10/2007 12:21:12 PM
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
Re: SHDocVw & MSHTML dom - Popup menu problem SQACSharp
4/13/2007 7:02:32 AM
Still need help to solve this problem..... :(

AddThis Social Bookmark Button