It depends from application to application but usually you will use UiExplorer and look for property changes in Property Explorer panel.
In this case - SQL Server Management Studio - when enabled, the button will have aastate = focusable
; when not enabled aastate = unavailable
. At runtime use Get Attribute
activity to query the status.