im stuck in my problem, i have invoke a process and now i want its focused elements.
for example. i run a process http://www.google.com that opens up in Google chrome
now lets say i want to search “hello” the way of doing this as far as i know is to get the keyboard focus element that will be a textbox of google.com .so how to do that through my application i.e programmatically(getting keyboard focused element of chrome process)
Process[] pr = Process.GetProcessesByName("chrome");
var target = pr[0];
Your question a is a bit vague, so I’ll try to give several pointers based on several different interpretations:
1) If the process you’re referring to is always a web-site, you should skip the screen-scraping techniques, like @vulkanino mentioned, and simply fetch the contents of the web-site directly. If you must get the website as parsed by a real browser (rather than the raw HTML itself), you can use screen-scraping, but remember that not all computers use the same browser.
2) If you want to screen-scrape information from a running process, you (unfortunately) don’t have a simple API like the one you expected, where the
Process probject contains a list of elements you can traverse. This is because the process might have been written in .NET/WinForms, .NET/WPF, C++/MFC or any of a dozen other UI frameworks that work very differently.What I would suggest is using a screen-reader accessibility framework, such as Microsoft’s UI Automation, which is able to extract text from the UI of many common applications. This functionality exists to help read out application UI for the hard of sight, but can be used for screen-scraping as well.