Jump to content

Need help sleep/loop.


Recommended Posts

Hello this is my very first topic on this forum just created my account because i couldnt find my answer no where (probably overseen it!)

My problem is this. 

In the While (1) i have the pixelsearch, yea hurray it works etc! BUT , the Call("StayOnline") are supposed to sleep for somewhere between 720000MS To 1080000MS and that seems to be working great BUT! while that sleep timer is ongoing it should keep pixel searching constant.. i can't seem to find anything about it =( any help appreciatet!

 

Thx in advance!

While (1)
                            
        $blah = PixelSearch(686, 118, 1102, 487, 0xFFD166, 0) ; Search for OK button.

        If NOT(@error) Then ; If okay button pop's up this will execute a click on the OK button.
            MouseMove($blah[0]+5, $blah[1]+5, 0)
            Sleep(2000)
            MouseClick("left", $blah[0]+5, $blah[1]+5, 2, 0)
            Sleep(1000)
        EndIf

        If (@error) Then
            Call("StayOnline")
        EndIf

    WEnd

    Func StayOnline() ; Keeps you online.

            Send("{UP}", 0)
            Sleep(Random(50, 250, 0)
            Send("{DOWN}", 0)
            Sleep(Random(720000, 1080000, 0))

    EndFunc

 

Link to comment
Share on other sites

Sleep is a blocking function, it will do just what it says.  Put the entire script to sleep until the wait is over.

For what you want to do, you may look to use timers instead or rebuild the script to work differently such as AdLibRegister() for your StayOnline portion of the script.

Link to comment
Share on other sites

ViciousXUSMC 

15 minutes ago, ViciousXUSMC said:

Sleep is a blocking function, it will do just what it says.  Put the entire script to sleep until the wait is over.

For what you want to do, you may look to use timers instead or rebuild the script to work differently such as AdLibRegister() for your StayOnline portion of the script.

I'm just getting started with AutoIT, how would i do that ? can u make me a example? it still needs to be a random amount of time between 720000 MS to 1080000 MS :P

 

Dequality.

 

Link to comment
Share on other sites

4 minutes ago, Dequalityy said:

ViciousXUSMC 

I'm just getting started with AutoIT, how would i do that ? can u make me a example? it still needs to be a random amount of time between 720000 MS to 1080000 MS :P

 

Dequality.

 

 

Might have it lol.. Can i really do it just like this? 

Dequalityy.

Func StayOnline() ; Keeps you online.

            Send("{UP}", 0)
            Sleep(Random(50, 250, 0)
            Send("{DOWN}", 0)
            AdlibRegister(Random(720000, 1080000, 0))

    EndFunc

 

Link to comment
Share on other sites

Why go for mouse move and click ? Why don't you use ControlClick ?. And don't call the StayOnline function in a separate if statement. Use an else statement in first if statement.

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Just now, kcvinu said:

Why go for mouse move and click ? Why don't you use ControlClick ?. And don't call the StayOnline function in a separate if statement. Use an else statement in first if statement.

As mentioned kcvinu i just started using AutoIT :P im not very familiar with coding at ALL.

So, would it be like this instead? 

While (1)

        $blah = PixelSearch(686, 118, 1102, 487, 0xFFD166, 0) ; Search for OK button.

        If NOT(@error) Then ; If okay button pop's up this will execute a click on the OK button.
            
            MouseMove($blah[0]+5, $blah[1]+5, 0)
            Sleep(2000)
            MouseClick("left", $blah[0]+5, $blah[1]+5, 2, 0)
            Sleep(1000)
        
        Else If (@error) Then
        
            Call("StayOnline")
        
        EndIf
        
    WEnd

Or did i misunderstand ? =) & how exactly does ControlClick work? :)

 

Dequality.

Link to comment
Share on other sites

If you use control click function, then you don't need to tell the mouse position. 

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

1 minute ago, kcvinu said:

If you use control click function, then you don't need to tell the mouse position. 

How does it know where to click then? <.< 

The Pixelsearch is a button it needs to click? =) 

And could anyone answer my question on why it doesnt "pause" / times out for the time i set it to ? it's annoying :(

 

Dequality.

Link to comment
Share on other sites

Just now, Dequalityy said:

How does it know where to click then? <.< 

The Pixelsearch is a button it needs to click? =) 

And could anyone answer my question on why it doesnt "pause" / times out for the time i set it to ? it's annoying :(

 

Dequality.

 

Oh and the button i want it to click isnt always showing up at the same position, thats why i used this function :P

Dequalityy.

Link to comment
Share on other sites

Okay, i figured out it needs to be used to call the function i want it used with i see, BUT the timing should still be random could i do it this way

 

AdlibRegister(StayOnline(Random(720000, 1080000, 0,))) ? or cant u do it that way? ^^ 

Link to comment
Share on other sites

Have you read the help file for ControlClick function ?

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Anyways, the way i make it click isnt the problem honestly, the problem is i can't seem to figure out how to make AdlibRegister use a random timer? is it even possible if not is there another function that works just like adlibregister but with a random timer between 2 numbers? =)

The numbers i need is pretty high as seen in the topic itself (720000 -> 1080000) it should a number randomly between those .. :)

-Dequality.

Link to comment
Share on other sites

Random will return a floating point number if you give 0 as flag. So give 1 as flag. You will get a complete number.

And mind it - AdlibRegister will work regardless sleep

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

13 minutes ago, SadBunny said:
AdlibRegister("beeper", Random(0, 2000, 1))

While True
    Sleep(1000)
WEnd

Func beeper()
    AdlibUnRegister("beeper")
    Beep(1500, 200)
    AdlibRegister("beeper", Random(0, 2000, 1))
EndFunc   ;==>beeper

 

Bunny thank you very much for an example, now my next problem is it doesnt sent the message it should can you tell me if i'm missing something? 

 

WinActivate("Netstationen Client – Google Chrome")
HotKeySet("{F4}", "ExitProg")

MouseClick("left", 1078, 120, 1, 0)


While (1)

        $blah = PixelSearch(686, 118, 1102, 487, 0xFFD166, 0) ; Search for OK button.

        If NOT(@error) Then ; If okay button pop's up this will execute a click on the OK button.

            MouseMove($blah[0]+5, $blah[1]+5, 0)
            Sleep(2000)
            MouseClick("left", $blah[0]+5, $blah[1]+5, 2, 0)
            Sleep(1000)

        ElseIf (@error) Then

            AdlibRegister("StayOnline", Random(720000, 1080000, 1))

        EndIf

    WEnd

    Func StayOnline() ; Keeps you online.
            AdlibRegister("StayOnline")
            Send("/goto 0", 1)
            Sleep(3000)
            Send("{ENTER}", 0)
            AdlibRegister("StayOnline", Random(2000, 2500, 1))

    EndFunc


Func ExitProg() ; Exits Auto
    Exit
EndFunc   ;==>ExitProg

 

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