How to enable a button

Mar 15, 2011 at 1:24 PM

Hi, I'm trying to automate an installation wizard and I needed to click on a button that is not enabled.

I know that this can be done using Windows Messages, but I was wondering if there is already support in White or UIAutomation for this

For reference this doesn't work:

var invoke =  (System.Windows.Automation.InvokePattern)setup.button("Next >").AutomationElement.GetCurrentPattern(System.Windows.Automation.InvokePattern.Pattern);  
invoke.Invoke();

neither does this

var guiAutomation = new API_GuiAutomation("msiexec");  
var setup = guiAutomation.windows()[0]; 
setup .bringToFront(); 
setup .button("Next >").mouse().click();  // this will work
setup .button("Next >").mouse().click();  // this will not work since the button is not enabled
The example above uses the White based API I added to the O2 Platform (see here an example of automating notepad http://diniscruz.blogspot.com/2010/10/example-of-gui-automation-controlling.html)

Mar 15, 2011 at 2:10 PM

Hi

as far as I know you can't "enable" a button , since the program state does not enable it.

 

Invoke is like Click();

 

Throndorin

Mar 15, 2011 at 2:22 PM

Well, one can enable Windows UI controls via Windows Messages, for example this is how Cow Spy (http://www.softpedia.com/developer/Nakencow-43342.html and http://www.nakencow.tk/cowspyindex.php) works.

Another way to do it is to hook the Controls Win32 Enable function (I did that in the past using Microsoft Detours, but the Windows message should work)

And once it is enabled like that, the White/UIAutomation functions should work