Jump to content

AdlibEnable question


andrew01
 Share

Recommended Posts

I have another question. I have been messing around with the adlib function a little. Basically, Im having adlibenable("Func Name") at the beginning of a function, and then adlibdisable at the end of that function. What the adlibfunction does it looks for a color on the screen. If they color is not found, it goes and does something else, if it is found it just repeats the adlib until it is false.

Is this basically what the adlib function is supposed to be used for? I want it to check for that color every second or less during one of the functions, and I dont know if that is the best way to do it.

Link to comment
Share on other sites

I have another question. I have been messing around with the adlib function a little. Basically, Im having adlibenable("Func Name") at the beginning of a function, and then adlibdisable at the end of that function. What the adlibfunction does it looks for a color on the screen. If they color is not found, it goes and does something else, if it is found it just repeats the adlib until it is false.

Is this basically what the adlib function is supposed to be used for? I want it to check for that color every second or less during one of the functions, and I dont know if that is the best way to do it.

The function specified in AdLibEnable() will interrupt the rest of the script to run. It will also interrupt itself and run again, leading to recursion errors if your function takes too long to finish. So the function called by AdLib should be short and efficient. You can control the AdLib inside a function, but not the same function that AdLib is calling (recursion errors again). So this should work - _MyFunction() will return when AdLibFunc() reports finding the red pixel at 400/300:

Global $Test
_MyFunction()

Func _MyFunction()
     $Test = 0
     AdLibEnable("_AdLibFunc", 500)
     While 1
          If $Test Then ExitLoop
          Sleep(250)
     WEnd
EndFunc

Func _AdLibFunc()
     ; Pixel check to run every 500ms goes here
     Local $x = 400, $y = 300
     If PixelGetColor($x, $y) = 0xFF0000 Then $Test = 1
EndFunc

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...