Jump to content

Newbie AutoIt user trying Pixel detection


Tokra
 Share

Recommended Posts

Basicly what i want is for a game is if the Health reaches an amount (Will do with pixel detection on the health bar) that it drinks a potion.

This is what im trying to code

Pixel at cordinate Turns into color (indicating Health drop under 50%) Then button lets say F10 gets pressed.

Also since theres 3 Bars ( Health Stamina and Mana ) Would there be possible for me to make one macro for All 3 rows or would i be having to make 3 diferent macros and run them at same time? (If that is possible)

AS a guy with almost 0 skill when it comes to making macros where should i look to learn how to put together these commands.

Link to comment
Share on other sites

What I would recommend first is to use Window Info to get the pixel colors you are looking for, and the window handle. In the simplest form, you could use a Select..Case loop, and in each case tell the script to press the key(s) based on the color. Use a hotkey to exit the script.

Winactivate(<your window>)
While 1 ;Infinite Loop
Select
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The first bar
Send("{F10}")
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The second bar
Send("{F11}")
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The third bar
Send("{F12}")
EndSelect
Wend ;If none are matched, returns to top of loop

Hope that helps!

Edited by mikjay
Link to comment
Share on other sites

What I would recommend first is to use Window Info to get the pixel colors you are looking for, and the window handle. In the simplest form, you could use a Select..Case loop, and in each case tell the script to press the key(s) based on the color. Use a hotkey to exit the script.

Winactivate(<your window>)
While 1 ;Infinite Loop
Select
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The first bar
Send("{F10}")
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The second bar
Send("{F11}")
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The third bar
Send("{F12}")
EndSelect
Wend ;If none are matched, returns to top of loop

Hope that helps!

That was prety nice.

But when i compile it and try and run it i get an error

Line -1:

Error: "Wend" statment with no matching "while" statement.

Link to comment
Share on other sites

Tokra, I have no problems running it. Can you show me the exact code you used?

WinWaitActive("Darkfall Online")
While 1 ;Infinite Loop
Select
Case Hex(PixelGetColor(<64,570>)) = "<BF2525>" ;The first bar
Send("{F5}")
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The second bar
Send("{F11}")
Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The third bar
Send("{F12}")
Wend ;If none are matched, returns to top of loop
Link to comment
Share on other sites

Tokra, the line before the Wend should contain an Endselect.

Also, since you are trying to get a single bar to work before you move on, comment out the second 2 cases. Another problem is you took my pointed brackets literally. Just enter the coordinates and color hex codes without the brackets.

I don't mind showing you the code, but I would appreciate it if you did your homework. That means looking at the helpfile (F1) to get proper syntax. If you can understand the code you are writing, it makes troubleshooting it 150% easier.

WinActivate("Darkfall Online")
WinWaitActive("Darkfall Online")
While 1 ;Infinite Loop
Select
Case Hex(PixelGetColor(64,570)) = "BF2525" ;The first bar
Send("{F5}")
;Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The second bar
;Send("{F11}")
;Case Hex(PixelGetColor(<x,y>)) = "<your hex color>" ;The third bar
;Send("{F12}")
EndSelect
Wend ;If none are matched, returns to top of loop
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...