PDA

View Full Version : IE Automation - Focused MsgBox



plissken_13x
10-03-2010, 12:53 PM
Hello, I am new to vbaexpress. I attempted to search for about 2 hours externally and internally to this site to see if there was already a posting similar to my issue.Problem: I have built a macro which navigates through multiple websites for my company which harvests the information and makes a determination off of the information. The code for this process works great until on one particular webpage after an input button is depressed a javascript msgbox appears which has explicit focus and halts the code execution. So far I tried Sendkeys and I even located the fields and tag names the msgbox is updating but nothing happens since it halts code execution after the msgbox is deployed. I spared the code but I can provide on demand. I just need to know if there is anyway around this? Any help would be greatly appreciated.

stanl
10-08-2010, 10:45 AM
I have worked with similar jscript pop-ups, normally to verify login credentials to a site. I have either intercepted the DHTML event that launches the jscript or 'paused' my script execution long enough for the jscript to do it's thing.

Unless it is a proprietary site, could you provide that particular URL so at least one can test.

plissken_13x
10-08-2010, 01:34 PM
The site is completely internal proprietary. I received some feedback from someone else who had a similar problem with a javascript ok msgbox. The solution was to use .removeattribute. I have been playing around with this but I am not completely sure it will work since this pop up contains an input field that must have a value other than null to proceed. Here is what I can post.

The input button which I have VBA click calls this javascript function below.

function submitform(form, buttonName, memo)
{
var hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = buttonName;
form.appendChild(hiddenInput);
if(genericMemo(memo))
{
form.submit();
}
}
</script>

stanl
10-09-2010, 04:16 AM
That leaves the essential question as: How important is the jscript pop-up to your script continuing to obtain data? I had an instance where I would register/unregister students to view take an on-line tutorial in basic money management. The unregister part produced a jscript pop-up which prompted for validation to perform the task. I found that setting the elements onclick event to "" would ignore the jscript and the student would still be unregistered.

In other instances where the pop-up would have a window title, my script would run a second script which looked for that window, dealt with it then returned to the main script. The important part there was to use a run command or shell execute rather than a call statement.

plissken_13x
10-11-2010, 10:13 AM
The jscript pop up is not important to me at all. I really wouldn't mind if it captured a null value for the memo line. It is an useless text box that isn't even recording to a table unlike the other data elements on the page.

I actually may have figured out how to get around this. I yet to fully test but I will update if sucessful. Thanks for your help and taking the time to look at this.