How to get control of another code's dialog box
-
I'm not sure this is possible - is there a way that I can do the following - I'd like to modify the text in the the filename Edit box of a File Save dialog in a 3rd party program (for which I don't have the source code). Could I do this by using Spy++ to get the handle to the dialog and the Edit box, then use my code to modify the text? Thanks! Tom
-
I'm not sure this is possible - is there a way that I can do the following - I'd like to modify the text in the the filename Edit box of a File Save dialog in a 3rd party program (for which I don't have the source code). Could I do this by using Spy++ to get the handle to the dialog and the Edit box, then use my code to modify the text? Thanks! Tom
Yes, I think it is called automation. It takes figuring the dialog's handle, the textbox's handle (or its tab position), then sending some characters using SendKeys. I tend to identify the foreground window (using user32's GetForegroundWindow) to improve the reliability. Warning: whatever you do it won't be fool proof (unless you can use an API the app provides). There always is a possibility something unexpected happens, e.g. another dialog pops up informing the user about an exceptional situation; and the interactive user might be interfering too. [ADDED] Automation may also stop working when the system load changes dramatically (so operations suddenly exceed the timeouts you have installed), when the app's settings (or the system's regional settings) get changed, when a new version of the app gets installed. [/ADDED] :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
modified on Tuesday, September 28, 2010 10:51 PM
-
Yes, I think it is called automation. It takes figuring the dialog's handle, the textbox's handle (or its tab position), then sending some characters using SendKeys. I tend to identify the foreground window (using user32's GetForegroundWindow) to improve the reliability. Warning: whatever you do it won't be fool proof (unless you can use an API the app provides). There always is a possibility something unexpected happens, e.g. another dialog pops up informing the user about an exceptional situation; and the interactive user might be interfering too. [ADDED] Automation may also stop working when the system load changes dramatically (so operations suddenly exceed the timeouts you have installed), when the app's settings (or the system's regional settings) get changed, when a new version of the app gets installed. [/ADDED] :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
modified on Tuesday, September 28, 2010 10:51 PM