Sign in to follow this  
Followers 0
trof

Merge two scripts

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I'd like to repeatedly click on a  button that is enabled/disabled many times per minute

For the button that is alternately enabled/disabled, I use

WinActivate("Stato motore Script")
Do
Sleep(150)
Until ControlCommand("Stato motore Script", '', "[NAME:CmdContinue]]", "IsEnabled") = 1
ControlClick("Stato motore Script", "", "[NAME:CmdContinue]]")

For the loop, I'd like to use

While 1
    WinActivate("Stato motore Script")
        ControlClick("Stato motore Script", "", "[NAME:CmdContinue]")
     WEnd
exit

 

I tried to merge both scripts,

Do
    Sleep(150)
    While 1
    WinActivate("Stato motore Script")
    Until ControlCommand("Stato motore Script", '', "[NAME:CmdContinue]]", "IsEnabled") = 1
    ControlClick("Stato motore Script", "", "[NAME:CmdContinue]]")
WEnd
Exit

but it doesn't work

Edited by trof

Share this post


Link to post
Share on other sites



Do
   While
   WEnd
Until

 

The way you have it now the loops wont interact as your while loop will not reference Do/Until when it loops.

What you should probably do is create just one loop and add some If/Then statements.

Maybe something like this?

While 1
 If WinExists("Stato motore Script") Then
     WinActivate("Stato motore Script")
     If  ControlCommand("Stato motore Script", '', "[NAME:CmdContinue]]", "IsEnabled") = 1 Then
          ControlClick("Stato motore Script", "", "[NAME:CmdContinue]")
     EndIf
 EndIf
 Sleep(10)      
WEnd

 

Share this post


Link to post
Share on other sites

Thanks,

I solved with a simple loop as you suggested me.

I didn't well observe the popup windows. I don't need 

If  ControlCommand("Stato motore Script", '', "[NAME:CmdContinue]]", "IsEnabled") = 1 Then

My loop is 

WinActivate("Stato motore Script")
While 1
    WinWaitActive("Stato motore Script", "Ignora e Continua")
        ControlClick("Stato motore Script", "", "[NAME:CmdContinue]")
     WEnd
exit

I apologize for my hastiness

Share this post


Link to post
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
Sign in to follow this  
Followers 0