access controls in other applications from .NET (C#)
-
how can access other controls such as button, textbox etc. in an other application from C#. For example I want to design a form that has a combo box with some data in it, and by choosing an Item from the combo box, that item will be copied to the search box of Internet Explorer (for example).
-
how can access other controls such as button, textbox etc. in an other application from C#. For example I want to design a form that has a combo box with some data in it, and by choosing an Item from the combo box, that item will be copied to the search box of Internet Explorer (for example).
Member 6289976 wrote:
how can access other controls such as button, textbox etc. in an other application from C#.
With extreme difficulty. Controlling another appication requires you to use Win32 API functions to search for windows, then search those windows for other windows, representing buttons and other controls, to find the one you want, get it's window handle, craft an appropriate window message to send to it and then send the message. There is also no guarantee that the control you're "talking" to will respond to the message you send. IE complicates this even further, because now you have to use an entirely different method, using IE's Document Object Model, to get at the controls on a web form.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
how can access other controls such as button, textbox etc. in an other application from C#. For example I want to design a form that has a combo box with some data in it, and by choosing an Item from the combo box, that item will be copied to the search box of Internet Explorer (for example).
Hi, FWIW, you could tackle your particular example in quite some different ways: 1. for Google, you can come up with the URL that specifies your search (just try it manually and see what URL Google generates when you hit the Search button; now use Process.Start(searchURL) to launch your default web browser and have it search right away. 2. or put a WebBrowser Control on your Form and give it a Navigate() command. :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
Member 6289976 wrote:
how can access other controls such as button, textbox etc. in an other application from C#.
With extreme difficulty. Controlling another appication requires you to use Win32 API functions to search for windows, then search those windows for other windows, representing buttons and other controls, to find the one you want, get it's window handle, craft an appropriate window message to send to it and then send the message. There is also no guarantee that the control you're "talking" to will respond to the message you send. IE complicates this even further, because now you have to use an entirely different method, using IE's Document Object Model, to get at the controls on a web form.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hi, FWIW, you could tackle your particular example in quite some different ways: 1. for Google, you can come up with the URL that specifies your search (just try it manually and see what URL Google generates when you hit the Search button; now use Process.Start(searchURL) to launch your default web browser and have it search right away. 2. or put a WebBrowser Control on your Form and give it a Navigate() command. :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
thank you luc. but I just meant an example. my question was general, I mean what if I want to access a button in photoshop for example, to make a little plugin for myself... thank you again. :)
Then you'd use the SDK for PhotoShop to create the plugin. Not some screwed up method of "remote controlling" another application.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
SO that's possible...... but a little hard as you say. can you mention some basic information for solving this problem. I mean what background should I have to do this. and thank you very much for your reply. :)
You need the Win32 API functions FindWindowEx and SendMessage at a minimum. You've got enough to Google with and find examples on how to use them.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008