I have an application that uses the Ax web browser object. When I call the
IHTMLElement.click() method on an input button (<input type="submit"> or
<input type="button">), the click fires appropriately, if I'm running it
from a windows forms based application.

However, when I run the EXACT same code under a windows service, either as a
logged in user or as the local system account, the click fails to process.
Clicking on other elements (like <a>) works.

I've tried submitting the form directly, in cases where a submit occurs, but
can't do that either. Both GET and POST actions fail.

What am I doing wrong? Is there something that prohibits the onclick event
from firing for buttons when running as a service? Am I missing something?

Robert

Re: mshtml and the click event inside of a windows service. by Nicholas

Nicholas
Tue Oct 19 11:14:03 CDT 2004

Robert,

As a general rule, you should not try and access UI elements from within
a windows service. It's generally a bad idea.

Do you have the service set up to interact with the desktop? If not,
turn this on, and it might work. This would mean that your service would
always have to have a logged in user to run in order to work (and you can't
guarantee that).

To what end are you using the WebBrowser control?


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

"Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
news:%23KlyBOftEHA.3368@TK2MSFTNGP10.phx.gbl...
>I have an application that uses the Ax web browser object. When I call the
> IHTMLElement.click() method on an input button (<input type="submit"> or
> <input type="button">), the click fires appropriately, if I'm running it
> from a windows forms based application.
>
> However, when I run the EXACT same code under a windows service, either as
> a
> logged in user or as the local system account, the click fails to process.
> Clicking on other elements (like <a>) works.
>
> I've tried submitting the form directly, in cases where a submit occurs,
> but
> can't do that either. Both GET and POST actions fail.
>
> What am I doing wrong? Is there something that prohibits the onclick
> event
> from firing for buttons when running as a service? Am I missing
> something?
>
> Robert
>
>
>



Re: mshtml and the click event inside of a windows service. by Robert

Robert
Tue Oct 19 11:34:10 CDT 2004

Nicholas,

We are gathering the content from various web pages using c# scripts and
don't have the time to write something that would be capable of doing posts
and gets and parsing javascript to determine locations.

We want to have many threads of this automated process. In the future,
we'll write something that doesn't use the webbrowser control because of
issues like this, but we simply didn't have the resources to do so at this
time.

Suggestions?

Robert

"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:u7zh5aftEHA.4040@tk2msftngp13.phx.gbl...
> Robert,
>
> As a general rule, you should not try and access UI elements from
> within a windows service. It's generally a bad idea.
>
> Do you have the service set up to interact with the desktop? If not,
> turn this on, and it might work. This would mean that your service would
> always have to have a logged in user to run in order to work (and you
> can't guarantee that).
>
> To what end are you using the WebBrowser control?
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@spam.guard.caspershouse.com
>
> "Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
> news:%23KlyBOftEHA.3368@TK2MSFTNGP10.phx.gbl...
>>I have an application that uses the Ax web browser object. When I call the
>> IHTMLElement.click() method on an input button (<input type="submit"> or
>> <input type="button">), the click fires appropriately, if I'm running it
>> from a windows forms based application.
>>
>> However, when I run the EXACT same code under a windows service, either
>> as a
>> logged in user or as the local system account, the click fails to
>> process.
>> Clicking on other elements (like <a>) works.
>>
>> I've tried submitting the form directly, in cases where a submit occurs,
>> but
>> can't do that either. Both GET and POST actions fail.
>>
>> What am I doing wrong? Is there something that prohibits the onclick
>> event
>> from firing for buttons when running as a service? Am I missing
>> something?
>>
>> Robert
>>
>>
>>
>
>



Re: mshtml and the click event inside of a windows service. by Nicholas

Nicholas
Tue Oct 19 11:44:07 CDT 2004

Robert,

I think the only other option would be to access MSHTML yourself, and
load the content into there. I don't know if it needs access to the desktop
(it shouldn't, if the host doesn't support it), but you will have to do a
lot of interop to load your documents (depending on where you get them
from).

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

"Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
news:eO%23a4lftEHA.1088@TK2MSFTNGP12.phx.gbl...
> Nicholas,
>
> We are gathering the content from various web pages using c# scripts and
> don't have the time to write something that would be capable of doing
> posts and gets and parsing javascript to determine locations.
>
> We want to have many threads of this automated process. In the future,
> we'll write something that doesn't use the webbrowser control because of
> issues like this, but we simply didn't have the resources to do so at this
> time.
>
> Suggestions?
>
> Robert
>
> "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote
> in message news:u7zh5aftEHA.4040@tk2msftngp13.phx.gbl...
>> Robert,
>>
>> As a general rule, you should not try and access UI elements from
>> within a windows service. It's generally a bad idea.
>>
>> Do you have the service set up to interact with the desktop? If not,
>> turn this on, and it might work. This would mean that your service would
>> always have to have a logged in user to run in order to work (and you
>> can't guarantee that).
>>
>> To what end are you using the WebBrowser control?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mvp@spam.guard.caspershouse.com
>>
>> "Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
>> news:%23KlyBOftEHA.3368@TK2MSFTNGP10.phx.gbl...
>>>I have an application that uses the Ax web browser object. When I call
>>>the
>>> IHTMLElement.click() method on an input button (<input type="submit"> or
>>> <input type="button">), the click fires appropriately, if I'm running it
>>> from a windows forms based application.
>>>
>>> However, when I run the EXACT same code under a windows service, either
>>> as a
>>> logged in user or as the local system account, the click fails to
>>> process.
>>> Clicking on other elements (like <a>) works.
>>>
>>> I've tried submitting the form directly, in cases where a submit occurs,
>>> but
>>> can't do that either. Both GET and POST actions fail.
>>>
>>> What am I doing wrong? Is there something that prohibits the onclick
>>> event
>>> from firing for buttons when running as a service? Am I missing
>>> something?
>>>
>>> Robert
>>>
>>>
>>>
>>
>>
>
>



Re: mshtml and the click event inside of a windows service. by Robert

Robert
Tue Oct 19 12:34:08 CDT 2004

Nicholas,

We actually ARE using MSHTML. We have the browser navigate, get the doc and
then parse through the document. We're then calling the
IHTMLElement.click() method and expecting this to do the navigation back
with the browser.

Under a windows service, it doesn't work. :( Even if we get the form that
we're trying to submit and call submit, it doesn't work. It's like post
backs are disabled in windows services.

Robert

"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:OeAssrftEHA.272@TK2MSFTNGP12.phx.gbl...
> Robert,
>
> I think the only other option would be to access MSHTML yourself, and
> load the content into there. I don't know if it needs access to the
> desktop (it shouldn't, if the host doesn't support it), but you will have
> to do a lot of interop to load your documents (depending on where you get
> them from).
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@spam.guard.caspershouse.com
>
> "Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
> news:eO%23a4lftEHA.1088@TK2MSFTNGP12.phx.gbl...
>> Nicholas,
>>
>> We are gathering the content from various web pages using c# scripts and
>> don't have the time to write something that would be capable of doing
>> posts and gets and parsing javascript to determine locations.
>>
>> We want to have many threads of this automated process. In the future,
>> we'll write something that doesn't use the webbrowser control because of
>> issues like this, but we simply didn't have the resources to do so at
>> this time.
>>
>> Suggestions?
>>
>> Robert
>>
>> "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote
>> in message news:u7zh5aftEHA.4040@tk2msftngp13.phx.gbl...
>>> Robert,
>>>
>>> As a general rule, you should not try and access UI elements from
>>> within a windows service. It's generally a bad idea.
>>>
>>> Do you have the service set up to interact with the desktop? If not,
>>> turn this on, and it might work. This would mean that your service
>>> would always have to have a logged in user to run in order to work (and
>>> you can't guarantee that).
>>>
>>> To what end are you using the WebBrowser control?
>>>
>>>
>>> --
>>> - Nicholas Paldino [.NET/C# MVP]
>>> - mvp@spam.guard.caspershouse.com
>>>
>>> "Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
>>> news:%23KlyBOftEHA.3368@TK2MSFTNGP10.phx.gbl...
>>>>I have an application that uses the Ax web browser object. When I call
>>>>the
>>>> IHTMLElement.click() method on an input button (<input type="submit">
>>>> or
>>>> <input type="button">), the click fires appropriately, if I'm running
>>>> it
>>>> from a windows forms based application.
>>>>
>>>> However, when I run the EXACT same code under a windows service, either
>>>> as a
>>>> logged in user or as the local system account, the click fails to
>>>> process.
>>>> Clicking on other elements (like <a>) works.
>>>>
>>>> I've tried submitting the form directly, in cases where a submit
>>>> occurs, but
>>>> can't do that either. Both GET and POST actions fail.
>>>>
>>>> What am I doing wrong? Is there something that prohibits the onclick
>>>> event
>>>> from firing for buttons when running as a service? Am I missing
>>>> something?
>>>>
>>>> Robert
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: mshtml and the click event inside of a windows service. by Nicholas

Nicholas
Tue Oct 19 12:43:42 CDT 2004

Robert,

Yes, you are using MSHTML, but you are getting it from a WebBrowser
control, and I believe that this is the issue. You need to create an
instance of MSHTML.HTMLDocument yourself, and load the content into there.
The document on it's own doesn't require interaction with the desktop (even
though you still have access to javascript events and the like).

You will have to create an IPersistMoniker definition, and then upload
your content through the call to Load. It's a lot of work, but the only way
to untie the document from the visualizer (which is the control).


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

"Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
news:uk8uXHgtEHA.2128@TK2MSFTNGP11.phx.gbl...
> Nicholas,
>
> We actually ARE using MSHTML. We have the browser navigate, get the doc
> and then parse through the document. We're then calling the
> IHTMLElement.click() method and expecting this to do the navigation back
> with the browser.
>
> Under a windows service, it doesn't work. :( Even if we get the form that
> we're trying to submit and call submit, it doesn't work. It's like post
> backs are disabled in windows services.
>
> Robert
>
> "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote
> in message news:OeAssrftEHA.272@TK2MSFTNGP12.phx.gbl...
>> Robert,
>>
>> I think the only other option would be to access MSHTML yourself, and
>> load the content into there. I don't know if it needs access to the
>> desktop (it shouldn't, if the host doesn't support it), but you will have
>> to do a lot of interop to load your documents (depending on where you get
>> them from).
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mvp@spam.guard.caspershouse.com
>>
>> "Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
>> news:eO%23a4lftEHA.1088@TK2MSFTNGP12.phx.gbl...
>>> Nicholas,
>>>
>>> We are gathering the content from various web pages using c# scripts and
>>> don't have the time to write something that would be capable of doing
>>> posts and gets and parsing javascript to determine locations.
>>>
>>> We want to have many threads of this automated process. In the future,
>>> we'll write something that doesn't use the webbrowser control because of
>>> issues like this, but we simply didn't have the resources to do so at
>>> this time.
>>>
>>> Suggestions?
>>>
>>> Robert
>>>
>>> "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote
>>> in message news:u7zh5aftEHA.4040@tk2msftngp13.phx.gbl...
>>>> Robert,
>>>>
>>>> As a general rule, you should not try and access UI elements from
>>>> within a windows service. It's generally a bad idea.
>>>>
>>>> Do you have the service set up to interact with the desktop? If
>>>> not, turn this on, and it might work. This would mean that your
>>>> service would always have to have a logged in user to run in order to
>>>> work (and you can't guarantee that).
>>>>
>>>> To what end are you using the WebBrowser control?
>>>>
>>>>
>>>> --
>>>> - Nicholas Paldino [.NET/C# MVP]
>>>> - mvp@spam.guard.caspershouse.com
>>>>
>>>> "Robert May" <rakkerspamisevil91@hotmail.com> wrote in message
>>>> news:%23KlyBOftEHA.3368@TK2MSFTNGP10.phx.gbl...
>>>>>I have an application that uses the Ax web browser object. When I call
>>>>>the
>>>>> IHTMLElement.click() method on an input button (<input type="submit">
>>>>> or
>>>>> <input type="button">), the click fires appropriately, if I'm running
>>>>> it
>>>>> from a windows forms based application.
>>>>>
>>>>> However, when I run the EXACT same code under a windows service,
>>>>> either as a
>>>>> logged in user or as the local system account, the click fails to
>>>>> process.
>>>>> Clicking on other elements (like <a>) works.
>>>>>
>>>>> I've tried submitting the form directly, in cases where a submit
>>>>> occurs, but
>>>>> can't do that either. Both GET and POST actions fail.
>>>>>
>>>>> What am I doing wrong? Is there something that prohibits the onclick
>>>>> event
>>>>> from firing for buttons when running as a service? Am I missing
>>>>> something?
>>>>>
>>>>> Robert
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: mshtml and the click event inside of a windows service. by Robert

Robert
Tue Oct 19 13:09:15 CDT 2004

Hi Nicholas,

> Yes, you are using MSHTML, but you are getting it from a WebBrowser
> control, and I believe that this is the issue. You need to create an
> instance of MSHTML.HTMLDocument yourself, and load the content into there.
> The document on it's own doesn't require interaction with the desktop (even
> though you still have access to javascript events and the like).
>
> You will have to create an IPersistMoniker definition, and then upload
> your content through the call to Load. It's a lot of work, but the only way
> to untie the document from the visualizer (which is the control).

That's a good starting point:

"Writer", hosted on the GotDotNet Workplaces.
Quite high quality [Lutz Roeder ("Reflector") is involved].

Another project:

http://www.itwriting.com/htmleditor/index.php

As far I can recall, the project embeds MSHTML exactly as you
recommend, but I don't think that IPersistMoniker is used.

bye
Rob

Re: mshtml and the click event inside of a windows service. by Nicholas

Nicholas
Tue Oct 19 13:18:54 CDT 2004

Robert,

This is definitely a good place to start. Granted, you won't want to
provide the visual elements in hosting (because I assume that would bring
you back to the same problem you had before), but it will show you how to
host MSHTML.

Check out the section of MSDN titled "Reusing MSHTML", located at (watch
for line wrap):

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/hosting.asp

It will give you a good idea of where to start. Everything is done in
C++, but can be converted to interop calls.

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

"Robert Jordan" <robertj@gmx.net> wrote in message
news:cl3l8d$ga1$03$1@news.t-online.com...
> Hi Nicholas,
>
>> Yes, you are using MSHTML, but you are getting it from a WebBrowser
>> control, and I believe that this is the issue. You need to create an
>> instance of MSHTML.HTMLDocument yourself, and load the content into
>> there. The document on it's own doesn't require interaction with the
>> desktop (even though you still have access to javascript events and the
>> like).
>>
>> You will have to create an IPersistMoniker definition, and then
>> upload your content through the call to Load. It's a lot of work, but
>> the only way to untie the document from the visualizer (which is the
>> control).
>
> That's a good starting point:
>
> "Writer", hosted on the GotDotNet Workplaces.
> Quite high quality [Lutz Roeder ("Reflector") is involved].
>
> Another project:
>
> http://www.itwriting.com/htmleditor/index.php
>
> As far I can recall, the project embeds MSHTML exactly as you
> recommend, but I don't think that IPersistMoniker is used.
>
> bye
> Rob