Jump to content

Script help


Recommended Posts

I'm a total scripting newbie and had a question. Below is my script so far. What I'm basically trying to do is get AutoIt to press the "Retry" button 4 times then give up and hit cancel. How do I do that while still having the program running in the background all the time? Thanks in advance!

AdlibEnable ("Click", 10000)

While 1

Sleep (1000)

WEnd

Exit

Func Click()

If WinExists("Siemens SmartSync") Then

ControlClick("Siemens SmartSync", "&Retry",4)

EndIf

EndFunc

Link to comment
Share on other sites

I'm a total scripting newbie and had a question.  Below is my script so far.  What I'm basically trying to do is get AutoIt to press the "Retry" button 4 times then give up and hit cancel.  How do I do that while still having the program running in the background all the time?  Thanks in advance!

AdlibEnable ("Click", 10000)

While 1

Sleep (1000)

WEnd

Exit

Func Click()

If WinExists("Siemens SmartSync") Then

ControlClick("Siemens SmartSync", "&Retry",4)

EndIf

EndFunc

<{POST_SNAPBACK}>

Sticking with your general method --- try:

$index = 0
AdlibEnable ("Click", 10000)

While 1
   Sleep (1000)
WEnd

Exit

Func Click()
   $index = $index + 1
   If $index < 5 Then
      If WinExists("Siemens SmartSync") Then
         ControlClick("Siemens SmartSync", "&Retry",4)
      EndIf
   Else
     ;do cancel stuff here
     ;maybe exit script
   EndIf
EndFunc

I assume that you are actually doing somethings else during the While/WEnd?

EDIT: added cancel stuff

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Sticking with your general method --- try:

$index = 0
AdlibEnable ("Click", 10000)

While 1
   Sleep (1000)
WEnd

Exit

Func Click()
   $index = $index + 1
   If $index < 5 Then
      If WinExists("Siemens SmartSync") Then
         ControlClick("Siemens SmartSync", "&Retry",4)
      EndIf
   EndIf
EndFunc

I assume that you are actually doing somethings else during the While/WEnd?

<{POST_SNAPBACK}>

No - it was just the pausing the script because I'm leaving this running in the background all the time. It's basically sitting around waiting for the window to pop up, hitting retry four times, then hitting cancel the 5th time.
Link to comment
Share on other sites

Then try:

index = 0

While 1
    Sleep (10000)
   $index = $index + 1
   If $index < 5 Then
      If WinExists("Siemens SmartSync") Then
         ControlClick("Siemens SmartSync", "&Retry",4)
      EndIf
   Else
    ;do cancel stuff here
     Exit
   EndIf
WEnd

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

  • Developers

or something like:

While 1
    $index = 0
    While WinExists("Siemens SmartSync")
        $index = $index + 1
        If $index < 5 Then
            ControlClick("Siemens SmartSync", "&Retry",4)
        Else
            ControlClick("Siemens SmartSync", "&Cancel",4)
            ExitLoop
        EndIf
        Sleep(1000); <- depends on the time it take till the next Retry window
    WEnd
WEnd
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

or something like:

While 1
    $index = 0
    While WinExists("Siemens SmartSync")
        $index = $index + 1
        If $index < 5 Then
            ControlClick("Siemens SmartSync", "&Retry",4)
        Else
            ControlClick("Siemens SmartSync", "&Cancel",4)
            ExitLoop
        EndIf
        Sleep(1000); <- depends on the time it take till the next Retry window
    WEnd
WEnd

<{POST_SNAPBACK}>

The reason I had the AdLibEnable is because the box doesn't pop up on a set schedule, so I wanted the program to keep running all the time and check for it every 10 seconds. So where would I put the AdLibEnable in the new version?
Link to comment
Share on other sites

  • Developers

The reason I had the AdLibEnable is because the box doesn't pop up on a set schedule, so I wanted the program to keep running all the time and check for it every 10 seconds.  So where would I put the AdLibEnable in the new version?

<{POST_SNAPBACK}>

You only need adlib when your script also does other stuff......

This script will run forever....

By the way it needs a sleep just before the last Wend else your CPU will max out...

:(

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

or something like:

While 1
    $index = 0
    While WinExists("Siemens SmartSync")
        $index = $index + 1
        If $index < 5 Then
            ControlClick("Siemens SmartSync", "&Retry",4)
        Else
            ControlClick("Siemens SmartSync", "&Cancel",4)
            ExitLoop
        EndIf
        Sleep(1000); <- depends on the time it take till the next Retry window
    WEnd
WEnd

<{POST_SNAPBACK}>

@JdeB

Yes, much better. I can't say that the forum has my full attention at the moment.

Does the ExitLoop need a number after it in order to exit the entire script? I cannot pick the number without running it. Is one used by the If and 2 more for the Whiles?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

  • Developers

@JdeB

Yes, much better. I can't say that the forum has my full attention at the moment.

Does the ExitLoop need a number after it in order to exit the entire script? I cannot pick the number without running it. Is one used by the If and 2 more for the Whiles?

<{POST_SNAPBACK}>

The ExitLoop doesn't need a number because it should only exit the inner While-Wend loop when the cancel is pressed.. (Would be the same as ExitLoop 1)

ExitLoop 2 would exit the outer While--Wend loop....

While 1
    $index = 0
    While WinExists("Siemens SmartSync")
        $index = $index + 1
        If $index < 5 Then
            ControlClick("Siemens SmartSync", "&Retry",4)
        Else
            ControlClick("Siemens SmartSync", "&Cancel",4)
            ExitLoop
        EndIf
        Sleep(1000); <- depends on the time it take till the next Retry window
    WEnd
    Sleep(1000)
WEnd
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Silly me - IF ain't no loop.

If we wanted it to just exit - change exitloop to exit.

I must be blind at the moment. I think I'll get back to work now and get paid to be blind.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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...