Jump to content

How do I wait for a grayed out button to become active?


Recommended Posts

There is a dialog box which first appears with a grayed out "OK" button which gets enabled after a delay.

Press CTRL-ALT-F to pause the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Activation

Class: #32770

Size: X: 497 Y: 423 W: 285 H: 178

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 645 Y: 575

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0xF3F3EF Dec: 15987695

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 104 Y: 112 W: 75 H: 23

Control ID: 1

ClassNameNN: Button1

Text: OK

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

OK

Activating now...

You have updated to the Deluxe Version.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

The following will not work as it clicks to early.

WinWait("Activation","")
If Not WinActive("Activation","") Then WinActivate("Activation","")
WinWaitActive("Activation","")
MouseMove(137,152)
MouseDown("left")
MouseUp("left")
Sleep(1000)

I can fix this by adding Sleep(3000), but then this may or may not be a long enough wait if the same script was running on a really old PC.

I would prefer comming up with a better solution for situations like this.

Any suggestions?

Edited by Codesmith
Link to comment
Share on other sites

Try using ControlCommand() to check if the button is enabled.

WinWait("Activation","")
If Not WinActive("Activation","") Then WinActivate("Activation","")
WinWaitActive("Activation","")
While Not ControlCommand('Activation', '', 'Button1', 'IsEnabled', '')
    Sleep(500)
WEnd
MouseClick('left', 137, 152)
Sleep(1000)

The MouseClick() would make MouseMove(), MouseDown(), & MouseUp() obsolete in this code.

:D

Link to comment
Share on other sites

  • Moderators

You could try this, although it doesn't look like the button is disabled:

If Not ControlCommand('Activation', 'OK', 'Button1', 'IsEnabled', '') Then
    Do
        Sleep(10)
    Until ControlCommand('Activation', 'OK', 'Button1', 'IsEnabled', '')
EndIfoÝ÷ Øêò¢ç(ºW]¡«­¢+ØÀÌØí=ÁÑ]Q54ô=ÁÐ Ìäí]¥¹Q¥Ñ±5Ñ¡5½Ìäì°È¤)%]¥¹á¥ÍÑÌ ÌäíÑ¥ÙÑ¥½¸Ìäì°ÌäíÑ¥ÙÑ¥¹¹½Ü¸¸¸Ìäì¤Q¡¸(¼(M±À ÄÀ¤(U¹Ñ¥°9½Ð]¥¹á¥ÍÑÌ ÌäíÑ¥ÙÑ¥½¸Ìäì°ÌäíÑ¥ÙÑ¥¹¹½Ü¸¸¸Ìäì¤)¹%)=ÁÐ Ìäí]¥¹Q¥Ñ±5Ñ¡5½Ìäì°ÀÌØí=ÁÑ]Q54¤
Edit:

The 2nd one is providing that the text changes on the window when it's not activating anymore.

Edit2:

Noticed MHz had the same idea I did... Using While rather than Do...

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks

ControlCommand('Activation', 'OK', 'Button1', 'IsEnabled', '')

will get the job done.

The text doesn't change at all and the button starts out disabled. I grabed the window info after the button was enabled.

I originally used ControlClick("Activation", "", "Button1"), but I discovered that it would let me click the button while it was still disabled causing the program being activated to crash. Now that I will be checking to see if the button is enabled it will be safe.

PS Actually I don't know when I should use Mouse commands and when to use ControlClick when a button doesn't have a keyboard shortcut.

Link to comment
Share on other sites

  • Moderators

Thanks

ControlCommand('Activation', 'OK', 'Button1', 'IsEnabled', '')

will get the job done.

The text doesn't change at all and the button starts out disabled. I grabed the window info after the button was enabled.

I originally used ControlClick("Activation", "", "Button1"), but I discovered that it would let me click the button while it was still disabled causing the program being activated to crash. Now that I will be checking to see if the button is enabled it will be safe.

PS Actually I don't know when I should use Mouse commands and when to use ControlClick when a button doesn't have a keyboard shortcut.

I would think you would be able to use ControlClick now, because it would be active before you got to it:
WinWait('Activation')
While Not ControlCommand('Activation', '', 'Button1', 'IsEnabled', '')
    Sleep(500)
WEnd
ControlClick('Activation', 'OK', 'Button1')
Might be all you need.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I would only use MouseClick() if any of the Control*() functions could not do the task. Control*() functions can be so more reliable so long as Autoit Info Tool can see it.

Edit:

Hmm. Beat me this time Smoke, but reply is somewhat of different direction. :D

Edited by MHz
Link to comment
Share on other sites

Opps ControlCommand uses Classname while ControlClick uses Control ID

So I had to use ControlClick("Activation","",1,"left")

But I tested my new script and adding the while loop to wait for the button fixed the problem.

Thanks

Link to comment
Share on other sites

  • 5 years later...

I have been messing with this script for a while now and tried different methods mentioned in this thread and a couple others...the issue that I'm running into is that the script pauses for the While statement, but never resumes once the button becomes active and 'IsEnabled' is true.

If I click next manually the script then continues instead of sending the ControlClick command that I want it to.

I'm using the example provided by SmOke_N , and my code is here. I'm still pretty new to this AutoIt stuff, so any info would be great. I'm wondering if I'm using the wrong ControlID, but the ID from the window info does say ID: 6143 for that specific button.

;Network
  Case $R292654 ;Wireless
   ShellExecute("E:\Win7 Drivers\E6420\Network\R292654.exe")
    
      WinWaitActive("Intel Intel(R) WiFi Link 6300, Intel (R) WiFi Link 6250, Intel(R) WiFi Link 6205, Intel Intel(R) WiFi Link 6xxx Series WLAN Half-Mini Card, v.14.00.20110, A01")
      Send("{TAB 3}")
      Send("{enter}")
      WinWaitActive("Intel® PROSet/Wireless Software","Next")
      Send("{enter}")
    
      WinWaitActive("Intel(R) PROSet/Wireless WiFi Software")
     While Not ControlCommand('Intel(R) PROSet/Wireless WiFi Software','','Button3','IsEnabled','')
      Do
      Sleep(500)
      Until ControlCommand('Intel(R) PROSet/Wireless WiFi Software','','Button3','IsEnabled','')
      WEnd
        
      ControlClick('Intel(R) PROSet/Wireless WiFi Software','Next','[ID:6143]')
    
      WinWaitActive("Intel(R) PROSet/Wireless WiFi Software","Back")
      ControlCommand("Intel(R) PROSet/Wireless WiFi Software","","[ID:6019]","Check","")
      WinWaitActive("Intel(R) PROSet/Wireless WiFi Software","Next")
      Send("{enter}")
      WinWaitActive("Intel(R) PROSet/Wireless WiFi Software","Next")
      Send("{enter}")
      WinWaitActive("Intel(R) PROSet/Wireless WiFi Software","Next")
      Send("{enter}")
      WinWaitActive("Intel(R) PROSet/Wireless WiFi Software","Finish")
      Send("{enter}")
      WinActivate("Intel Intel(R) WiFi Link 6300, Intel (R) WiFi Link 6250, Intel(R) WiFi Link 6205, Intel Intel(R) WiFi Link 6xxx Series WLAN Half-Mini Card, v.14.00.20110, A01")
         Sleep(1000)
      WinClose("Intel Intel(R) WiFi Link 6300, Intel (R) WiFi Link 6250, Intel(R) WiFi Link 6205, Intel Intel(R) WiFi Link 6xxx Series WLAN Half-Mini Card, v.14.00.20110, A01","")
Link to comment
Share on other sites

instead of

While Not ControlCommand('Intel® PROSet/Wireless WiFi Software','','Button3','IsEnabled','')
      Do
      Sleep(500)
      Until ControlCommand('Intel® PROSet/Wireless WiFi Software','','Button3','IsEnabled','')
      WEnd

do this

While Not ControlCommand('Intel® PROSet/Wireless WiFi Software','','Button3','IsEnabled','')
      Sleep(500)
      WEnd

EDIT: don't post to 6 years old topics instead create your own new topic and optionally add link to related old topic

Edited by Zedna
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...