Jump to content

Recommended Posts

Posted

Hello

For example i have a script like this:

While 1
Mousemove(0,0, 10)
Mousemove(10,10,10)
Wend

What i want to do is, to make the script break this While loop and Mousemove(20,20,10) every X amount of time, (Let's say every 60 seconds).

I mean even if the while loop is not ended so, the script has just moved the mouse to 0,0 coordinates (Mousemove(0,0,10) but (60 seconds) has passed so script won't move mouse to 10,10 coordinates (Mousemove(10,10,10) and will move mouse to 20,20 coordinates and the start the while loop from the begginning.

Thanks!

Posted (edited)

You may need to look at the Sleep command and maybe using addition with coordinates as variables.

i.e. Similar to the following perhaps

$a = 0

$b = 0

$c = 0

While 1

Sleep(1000)

MouseMove($a, $b, $c)

$a = $a + 10

$b = $b + 10

$c = $c + 10

If $c = 500 Then ExitLoop

Wend

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

  Reveal hidden contents

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Posted

Can you please tell us the purpose of this script? Do you just want to learn AutoIt or do you need to solve a real problem?

If we know what you want to achive we might suggest an easier and even more reliable way.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

Okay, you understood my problem differently guys. I brought that mousemove while loop as an example.

I will expalin what i want to know better

For Example i have a script whith main while loop:

While 1
; a whole bunch of script here with If statements, for loops, and so on
Wend

I want the script to stop the while loop and for example Msgbox(0, 'Title', "Text"), every 60 seconds and then start the while loop again.

Okay, if it's still confusing let me introduce another example (it seems Mousemove have lost you):

Script:

While 1
Msgbox(0, "Box1", "Box2")
Sleep(1000)
Msgbox(0, "Box2", "Box2")
Wend

Here we have a script, which makes first a Msgbox appear wth title and text: Box1 and after that a Msgbox with title and text: Box2

I want every 60 seconds the script to make a Msgbox with title and Text: Box3 (Msgbox(0, "Box3", "Box3"))

And finally why i am asking this question: I have a script that does something continuously with While 1 Loop (I don't want to upload a whole script), and i wan't to make my script to break the This while loop every 60 seconds then do something for example move mouse and start the while loop all over again.

Sorry for my bad english and if i was not able to explain my problem clearly

Thanks!

Edited by Danger111
Posted (edited)

Is it so hard to understand what i am asking? The script FireFox replied:

While 1
Mousemove(0,0, 10)
Mousemove(10,10,10)
Sleep(60000)
MsgBox(0, "", "That was so hard.")
Wend

This script moves mouse to 0,0 then to 10,10 and waits 60seconds i could do that myself too. What i want to do is, that when i have a While loop, ok let's say that Mousemove loop:

While 1
Mousemove(0,0, 10)
Mousemove(10,10,10)
Wend

I want every 60 seconds script to STOP/BREAK (call whatever you like) this WHILE LOOP then do something else (For example move mouse on random coordinates Say X, Y only once) and START the WHILE LOOP again.

Thanks!

Edited by Danger111
Posted (edited)

Okay, I solved the half of my Problem: It seems i had to use AdlibRegister function here is my script:

HotKeySet("E", "_Exit")
AdlibRegister("_Break", 6000)

while 1
MouseMove(0,0,10)
sleep(1000)
MouseMove(1887, 977,10)
WEnd

Func _Break()
Mousemove(889, 471,10)
EndFunc

Func _Exit()
Exit
EndFunc

But the problem is when the Adlib uses _Break function the While loop continues from where he stopped, i want after the Break function while loop to start from the beginning. Is it possible?

Thanks!

Edited by Danger111
Posted (edited)

Hmm i have tried it like this:

HotKeySet("E", "_Exit")
AdlibRegister("_Break", 6000)

_start()

Func _Start()
while 1
MsgBox(0, "Box1", "Box1")
MsgBox(0, "Box2", "Box2")
MsgBox(0, "Box3", "Box3")
WEnd
EndFunc

Func _Break()
MsgBox(0, "Box4", "Box4")
_start()
EndFunc

Func _Exit()
Exit
EndFunc

Resut: After first 6 seconds Box4 appears and then the while loop starts from begginging (From Box1), but after first 6 seconds Box4 never appears it's like AdlibRegister stopped working, any ideas?

Thanks!

Edited by Danger111
Posted

  On 4/15/2013 at 7:23 AM, 'Danger111 said:

Is it so hard to understand what i am asking?

I would say yes if I was not the only one to answer wrongly but it's not the case.

I doubt the script purpose is legit (to the forum rules)...

Posted

That's what I asked for in post #4. But the OP refused to answer my question.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

Whats not legit in asking how to break a Loop every X amount of time and then start it again?

Or because i don't want to upload my script you decided that i am writing some hacking program or virus?

Anyway from my #13 post i think my question is clear and if you got a solution please reply me.

Thanks!

Edited by Danger111
Posted

  On 4/15/2013 at 9:34 AM, 'Danger111 said:

Whats not legit in asking how to break a Loop every X amount of time and then start it again?

Or because i don't want to upload my script you decided that i am writing some hacking program or virus?

Anyway from my #13 post i think my question is clear and if you got a solution please reply me.

Thanks!

No, you refuse to say what you are automating. I too think you are doing something we do not allow here.
Posted

@Danger111

If the replies to this topic has frustrated you, try testing this example for an extended length of time when your a little tired.

It should cure you.

; The chance of the AdlibRegister's function returning
; to the loop after any of the If statements to execute
; the following command line is possible, but unlikely.
Global $Flag = 1
HotKeySet("E", "_Exit")
AdlibRegister("_Break", 6000)

_start()

Func _Start()
    While 1
        $Flag = 1
        MouseMove(0, 0, 10)
        If $Flag = 0 Then ContinueLoop
        Sleep(1000)
        If $Flag = 0 Then ContinueLoop
        MouseMove(587, 377, 10)
        If $Flag = 0 Then ContinueLoop
        MsgBox(0, "Box1", "Box1", 1)
        If $Flag = 0 Then ContinueLoop
        MsgBox(0, "Box2", "Box2", 1)
        If $Flag = 0 Then ContinueLoop
        MsgBox(0, "Box3", "Box3", 1)
    WEnd
EndFunc   ;==>_Start

Func _Break()
    MouseMove(20, 350)
    MsgBox(0, "Box4", "Box4")
    $Flag = 0
EndFunc   ;==>_Break

Func _Exit()
    Exit 0
EndFunc   ;==>_Exit
Posted (edited)

@Malkey

Yep, that works exactly as i wanted. Thank you so much.

Thanks a lot all of you for spending your time helping me and special thanks to Malkey for solving my problem:)

Thanks!

Edited by Danger111

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
  • Recently Browsing   0 members

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