Embedded webBrowser triggers

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
mark106
Posts: 27
Last visit: Thu Mar 21, 2024 2:29 pm
Has voted: 1 time

Embedded webBrowser triggers

Post by mark106 »

PowerShell Studio V5.4.145 64 bit
Win 7 (64)


Hi,

I'm trying to use an embedded webBrowser in my project so that I can use an intranet site to trigger tasks in my PowerShell (Studio) GUI. I've been using the WebBrowser Navigating and WebBrowser Navigated events and then parsing things such innerHtml / innerText etc. Unfortunately, in this particular situation, the Navigating and Navigated triggers occur at the wrong time (before the data that I want is presented by the website). So, is there a way that I can get the website author to send a trigger to the PowerShell GUI at the right time?

I've been experimenting myself with a webpage that adds and removes controls and attempts to resize the browser, but I don't seem to be able to get a trigger.
events.png
events.png (15.96 KiB) Viewed 2251 times

Any suggestions greatfully received.

Thanks
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Embedded webBrowser triggers

Post by davidc »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]

You will need to use the DocumentCompleted event handler. This event is called after the page is completed loaded.
David
SAPIEN Technologies, Inc.
User avatar
mark106
Posts: 27
Last visit: Thu Mar 21, 2024 2:29 pm
Has voted: 1 time

Re: Embedded webBrowser triggers

Post by mark106 »

Hi,

Thanks for the reply. Unfortunately, the DocumentCompleted event handler doesn't trigger at the required point either. I think because the webpage is largely JavaScript based the user interaction doesn't generate those triggers. It would be great if a trigger could be initiated from JavaScript (even if it involved creating an invisble control, resizing the page or something) but I don't know if that's possible. I tried a simple webpage which did those things, but I couldn't seem to get a trigger. I'm not a web / JS coder though.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Embedded webBrowser triggers

Post by jvierra »

Ajax pages will not load as expected into a browser control. if the pages require interaction then there is little that you can do. In some cases you can call "Click" on a control but most modern web sites do not allow this because the main page intercepts only actual clicks generated by a mouse and all programmatic "Clicks" are thrown away.
This topic is 6 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked