Jump to content

Nested Loops


Recommended Posts

God day for all;

I want to do the following steps:

;First:-

MouseClick(left,240,400,1)

Send("{down}{enter}")

;*Do Loop

;Second:-

MouseClick(left,240,400,1)

Send("{down}{down}{enter}")

;*Do Loop

;Third:-

MouseClick(left,240,400,1)

Send("{down}{down}{down}{enter}")

;*Do Loop

..

;Fifth:-

MouseClick(left,240,400,1)

Send("{down}{down}{down}{down}{enter}")

;*Do Loop

Note the loop is the same in all cases; its working now, but the script is too long:

1- How can I make a nested loop to do the work, instead of this long process?

2- How can I make the whole loop to repeat itself every 15minits all the day?

Thanks for any feed back

Link to comment
Share on other sites

Seems relatively easy, but why so many do loops? Why not just have one while loop ( While 1 ) so it runs until you shut the script/exe down, then do the steps inside after a sleep of 900000(15 minutes)?

Edited by kjmarket
Pink Floyd - The Wall
Link to comment
Share on other sites

While 1

   Sleep (900000);Sleep for 15 minutes

   MouseClick(left,240,400,1)
   Send("{down}{enter}")
   MouseClick(left,240,400,1)
   Send("{down}{down}{enter}")
   MouseClick(left,240,400,1)
   Send("{down}{down}{down}{enter}")
   MouseClick(left,240,400,1)
   Send("{down}{down}{down}{down}{enter}")

Wend

Seems to me that something like that should work, with maybe a short sleep after each send, but only if the script is going too fast and the wrong things being selected/clicked...etc.

Edited by kjmarket
Pink Floyd - The Wall
Link to comment
Share on other sites

Seems relatively easy, but why so many do loops? Why not just have one while loop ( While 1 ) so it runs until you shut the script/exe down, then do the steps inside after a sleep of 900000(15 minutes)?

Thanks kjmarket;

I think you are so kind and answered question 2; I will try it to see,

but I have to do a loop when I do every step (the same loop every time); do I have to copy it and inseret it for each step (the existing situation), and then I will have problemes in editing it, or how can I write it once, I know it might be easy for you but I am new in this;

thanks a gain

Link to comment
Share on other sites

YOu need to do a loop for each set of commands? Are you needing to do them more than once every 15 minutes? If not then only the while loop is needed, and the script would be very basic.

P.S. Didn't mean to imply that this was an easy issue and you should know how to do it. I was just stating that it seems like a relatively easy concept. :whistle:

Pink Floyd - The Wall
Link to comment
Share on other sites

The Prince,

Try the following.

taurus905

HotkeySet("{Esc}", "_Terminate"); End Program
Global $Start, $Time = 9000; in milliseconds; 9000 = 9 seconds; 900000 = 15 minutes
_Do_Things()

While 1
    If  TimerDiff($Start) > $Time Then _Do_Things()
WEnd
Exit

Func _Do_Things()
    For $i = 1 To 5
        MouseClick("left", 240, 400, 1)
        Send("{down}" & $i & "}" & "{enter}")
        MsgBox(0, "$i", $i, 1)
    Next
    $Start = TimerInit()
    Sleep($Time)
EndFunc; ==> _Do_Things

Func _Terminate(); End Program
    Exit
EndFunc; ==> _Terminate

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

If you can post your entire code with loops in place it would be easier for us to understand and help you.

[quote name='DaleHohm']You have a strange habit of posting error messages that don't match your code.[/quote][quote name='SmOke_N']Forget the learning... straight to the scripting :lol: (laugh.gif)[/quote]

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