How can the controls on the thinkorswim desktop app, which seem to be a WebView2 controls, be enumerated and manipuulated using a C# program. The methods used in a regular windows desktop app do not seem to work.
Loading
How can the controls on the thinkorswim desktop app, which seem to be a WebView2 controls, be enumerated and manipuulated using a C# program. The methods used in a regular windows desktop app do not seem to work.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Daniel WrightPosted Feb 21, 2025, 2:18 PM
It seems like you're trying to interact with the controls of the thinkorswim desktop app, which likely uses WebView2 controls for its login window. When dealing with web content embedded in a desktop application like this, traditional methods used in regular Windows desktop apps may not suffice.
To interact with WebView2 controls in a C# program, you'll need to leverage the WebView2 control provided by Microsoft. This control allows you to host web content within your Windows Forms or WPF application and interact with it programmatically.
Here's a high-level overview of how you can approach interacting with WebView2 controls in the context of the thinkorswim desktop app:
1. Adding the WebView2 Control: First, make sure you have the WebView2 runtime installed on the machine where your application is running. You can download it from the official Microsoft Edge WebView2 site.
2. Integrating WebView2 in your C# Application: Depending on whether you are using Windows Forms or WPF, you'll need to add the WebView2 control to your form or window. This can be done through the designer or programmatically.
3. Navigating and Interacting with Web Content: Once the WebView2 control is set up, you can load the thinkorswim login page into it using the `Source` property. You can also interact with the loaded page using methods provided by the WebView2 control, such as executing JavaScript or handling navigation events.
4. Enumerating and Manipulating Controls: To interact with specific elements on the loaded web page, you can use the WebView2 `ExecuteScriptAsync` method to execute JavaScript code that accesses and manipulates DOM elements. This allows you to automate actions like filling in form fields, clicking buttons, or retrieving data from the page.
Here's a simplified example of how you might interact with a WebView2 control in C# to fill in a username field on a login page:
By using the WebView2 control and its associated methods, you should be able to enumerate and manipulate controls within the thinkorswim login window from your C# program. Remember to handle events and asynchronous operations appropriately to ensure smooth interaction with the web content.
If you encounter specific challenges or have more detailed requirements, feel free to provide additional information so I can offer more targeted assistance.