This project is read-only.

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);  

neither does this

var guiAutomation = new API_GuiAutomation("msiexec");  
var setup =[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

Mar 15, 2011 at 2:10 PM


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


Invoke is like Click();



Mar 15, 2011 at 2:22 PM

Well, one can enable Windows UI controls via Windows Messages, for example this is how Cow Spy ( and 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