The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 12:00:38 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: C# an axWebBrowser issue  (Read 4409 times)
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« on: June 15, 2007, 08:18:51 AM »

So the Kaptain is here writing a quick little C# app to automate some form field filling.  He was going to share it with a friend of his but has run into some issues.

For some reason on the Kaptain's desktop PC and laptop the program works just ding dong dandy but on his friend's computer it will navigate to the page correctly but never fill in the form fields.  So, we were thinking it was an issue with missing a dependent DLL or something else silly so the Kaptain made an install pack for it that would register the dependent DLLs - no luck.  He wrote a similar app a while back and had a similar problem and making the installer that registers the DLLs seemed to fix it (or it was voodoo we aren't sure) but that doesn't seem to be helping this time.

Has anyone done something similar and had similar issues or have some clue as to WTF the problem is?  The Kaptain is a C# newbie so he's not sure which direction to look.

The program uses the axWebBrowser which is different than the standard web browser control.  The DLLs it includes as dependencies are axInterop.SHDocVw.DLL and Interop.SHDocVw.DLL.  It also says ieframe.dll is a dependency but upon install for the Kaptain and everyone else it says it fails to register ieframe.dll so we dunno WTF that is about.

help?


Logged

We can't stop here, this is bat country.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #1 on: June 15, 2007, 07:04:57 PM »

hey skipper,

presumably you are setting mshtml.IHTMLElement.innerText on an element you are aquiring through mshtml.HTMLDocument.getElementById ? If that's the case perhaps you should throw some debugging code in there to make sure you have the object and it is the object you think it is. This could be a DOM issue, are we talking same version of IE on each machine with same security settings?

them's my thoughts for now. pm me if you need to skipper, I'll give u a hand if I can.

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« Reply #2 on: June 18, 2007, 12:42:59 PM »

Since it worked on all of my computers and only my computers i decided to format and reinstall windows on my work PC because it seemed that my computers all had something that most didn't

so, with doing that and running the app it appears that for some reason the axWebBrowser1_DocumentComplete event isn't firing. 

I have sent it to multiple URLs and it never fires that event

any ideas?
Logged

We can't stop here, this is bat country.
KaptainKrayola
Keeper of Pie
Global Moderator
Lifer
*****
Offline Offline

Posts: 994



View Profile WWW
« Reply #3 on: June 18, 2007, 02:56:53 PM »

Ok!

so I have switched from using the axWebbrowser and mshtml to just using the built in .net webbrowser control.  I can fill in text boxes, etc now no problem but im running into the issue of getting it to submit the form.

MS says you can do something like:

InvokeMember("Submit");

(they use Reset for an example) but that is doing exactly 0 for me.

ideas?

Logged

We can't stop here, this is bat country.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #4 on: June 18, 2007, 05:46:06 PM »

Code:
System::Windows::Forms::HtmlElement^ pSubmit = this->m_doc->GetElementById( "Submit" );
pSubmit->InvokeMember( "Click" );
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #5 on: June 18, 2007, 05:59:51 PM »

Since it worked on all of my computers and only my computers i decided to format and reinstall windows on my work PC because it seemed that my computers all had something that most didn't

so, with doing that and running the app it appears that for some reason the axWebBrowser1_DocumentComplete event isn't firing. 

I have sent it to multiple URLs and it never fires that event

any ideas?

Code:
// Add an event handler for the "doc complete" event
SHDocVw::DWebBrowserEvents2_DocumentCompleteEventHandler^ DDocComplete =  ( gcnew SHDocVw::DWebBrowserEvents2_DocumentCompleteEventHandler(this, &myApp::Form1::DocumentComplete) );
m_ie->DocumentComplete += DDocComplete;

That's what I use. these examples I'm giving you are in managed C++ of course but they should be easy enough to port. This is a definition of a "delegate" function/method which are used quite extensively in dotnet. Search for "documentcomplete event delegate" on G.

Here's what the DocumentComplete method looks like;

Code:
private: System::Void DocumentComplete( System::Object^ pDisp, ref class System::Object^% URL )
{
m_bIsDocComplete = true;

switch( m_pageReference )
{
case 10:
this->m_pageReference = 20;
this->CheckOut();
break;

case 20:
this->m_pageReference = 30;
this->ValidateCheckout();
break;

case 30:
this->m_pageReference = 40;
this->SelectAddress();
break;

case 40:
this->m_pageReference = 50;
this->SelectContinue();

case 50:
this->m_pageReference = 60;
this->PlaceOrder();

default:
break;

}

}

It performs a different task depending on the value of m_pageReference, this is because I load multiple pages in this particular app.

HTH,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!