mobamoba Posted May 6, 2005 Posted May 6, 2005 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
herewasplato Posted May 6, 2005 Posted May 6, 2005 (edited) 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)WEndExitFunc Click() If WinExists("Siemens SmartSync") Then ControlClick("Siemens SmartSync", "&Retry",4)EndIfEndFunc<{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 EndFuncI assume that you are actually doing somethings else during the While/WEnd?EDIT: added cancel stuff Edited May 6, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
mobamoba Posted May 6, 2005 Author Posted May 6, 2005 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 EndFuncI 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.
herewasplato Posted May 6, 2005 Posted May 6, 2005 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]
Developers Jos Posted May 6, 2005 Developers Posted May 6, 2005 (edited) 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 May 6, 2005 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.
mobamoba Posted May 6, 2005 Author Posted May 6, 2005 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?
Developers Jos Posted May 6, 2005 Developers Posted May 6, 2005 (edited) 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 May 6, 2005 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.
herewasplato Posted May 6, 2005 Posted May 6, 2005 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}>@JdeBYes, 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]
Developers Jos Posted May 6, 2005 Developers Posted May 6, 2005 (edited) @JdeBYes, 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 May 6, 2005 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.
herewasplato Posted May 6, 2005 Posted May 6, 2005 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]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now