Find name in screen and move mouse on it

Ask gaming related questions (AHK v1.1 and older)
Ricardofsk8
Posts: 3
Joined: 17 May 2018, 08:34

Find name in screen and move mouse on it

18 May 2018, 13:39

i would like to get a script that search a name on my game screen and move my mouse on this name, remeber that this name can be in any cordinate of my screen, i tried some scripts below but i cant think how to do this... Can someone help me?


Haystack = arroz
Needle = def
StringGetPos, pos, Haystack, %Needle%
CoordMode, Mouse
MouseMove, X, Y
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Find name in screen and move mouse on it

18 May 2018, 14:15

yeah uhhh, i dont think you can do it like that. can u post a screenshot of what this name looks like, also what game

if i had to guess, i think youd need to OCR the entire screen looking for the name(not exactly the most viable of methods, but may be the only one applicable)
Ricardofsk8
Posts: 3
Joined: 17 May 2018, 08:34

Re: Find name in screen and move mouse on it

21 May 2018, 13:14

https://imgur.com/a/RJkVrz3

The image is on link above, and the name of game is Tibia.

The name of target is Bexten.

The script must find this name in any part of screen and must stop mouse on it, is this possible?
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Find name in screen and move mouse on it

21 May 2018, 14:27

You can try image search using *Trans and some variation to find anything.

Example based on the image in your link (not zoomed in)

Code: Select all

#NoEnv
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen


1::
    ImageSearch, FoundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *TransBlack *30 %A_ScriptDir%\Bexten.png
    if (ErrorLevel = 0)
        MouseMove, FoundX+32, foundY+7    ; Offset to click in the middle of found image.
    else
        MsgBox % ErrorLevel
return
This example is using *TransBlack the trick is to black out any colors that you dont want in the image search. ie: antialiasing and shifting colors.
Zoom in on the attached image to see the blacked out parts. This is nothing complicated it can be done in paint.

HTH
Attachments
Bexten.png
Bexten.png (1.55 KiB) Viewed 1709 times
Ricardofsk8
Posts: 3
Joined: 17 May 2018, 08:34

Re: Find name in screen and move mouse on it

23 May 2018, 05:59

Do not worked brother, i think its because the function must scanner the screen every time, this is not a static image, its a online game that de name is mooving on screen every time. Im stating to think this is not possible. And sorry about my english, im not so good yet.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Find name in screen and move mouse on it

23 May 2018, 11:25

I was only providing an example script method of how you could go about scripting what you want to do.
It is not plug and play use.

You most likely would need to create an image from the game window and use a loop or timer to run the routine to do what you want.
Once that works if it doesn't run fast enough there are options you can use to speed it up.

Anyways maybe someone else will find this technique useful.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Find name in screen and move mouse on it

23 May 2018, 14:48

disregarding the fact these name tags seems to get occluded whenever there's crap being spammed on the screen, i dont think Xtra's solution, though an elegant one, would work even if you were to code it in properly. I personally havent had much success in employing TransColor + Variation with image searches. Nevertheless, do try it out, im curious to see how it goes.

Instead, i was thinking more along the lines of finding something unique about the nametag, maybe the vertical bar in B or something, and searching for that instead.
Provided u manage to do all of that, youre still facing the issue of Imagesearching not a minuscule portion of the screen. If speed is of any importance, this method might yield poor results in the first place.

Idk what anticheat tibia has(if any at all), but another approach could be to read your target player's coordinated(if theyre at all provided) from memory, compare them with your own, triangulate the relative position of the target player based off of that, translate it into mouse coordinates and click with some unspecified degree of accuracy of your target player.

Anyway, i decided to test out ImgSearch TransColor for my own amusement in this mock example(see attachments)
Spoiler

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 94 guests