Help - Search - Members - Calendar
Full Version: ScreenScrape.inc
AC Tools Everything Macro > AC Tool Macros > Asheron's Call Macros
Ahk
Edited 1/22, posted ScreenScrape.txt, you have to rename to .inc or .mac - whichever you choose. Forum removed my attachment.

Update: Version 1.1

QUOTE
//Version 1.1 Updated on 10/26 - Ahk
//1.1 changes - Scrape will calculate around the coordinates given
//---Before you probably would have had to compute these yourself, but now it will compute
//---half of the scan before the coordinates given and the other half will be covered as part of the range
//---Removed timestamp for each pixel test, only timestamps at begining and if found.
//You WILL need to update your macro's coordinates to be at the center of the search area.


I am posting this as it seems to be in popular demand and is a common question.
Plus, I had a use for creating it -- otherwise it probably would not exist wink.gif.

Modify as you wish. Code sample included in comment blocks.

That all said, here's some things I want to say.
Screen Scraping is ONLY useful if you know what you're looking for, and it's actually pretty limited for use with objects. This likely won't be able to find a monster in a 3d game unless you get really lucky, or it has a low-end 2-D graphics engine. For 3-D games, you'll probably need to modify this to search for a pixel color.

Keep your objects as small as possible to speed things up.

It appears ObjLoadWindow does not work for this, so I have not included it with the macro. It may/may not work with color testing.

Save to your AcTool macros folder, or you'll need to put the path of the file in the Include statement...EX: C:\Macros\ScreenScrape.inc

Edit/Note:
This is meant more to be a guide on how you can screen scrape for pixels, objects aren't very useful as far as scraping goes unless you've got an icon like in the example (or other object that doesn't change).
Another note: TimeStamps are hard-coded, and will cause a slight delay, removing them will provide a bit better performance. Don't forget to tweek the delay!

-Ahk
Ahk
Version 1.1 posted. See above.
vhaldir
QUOTE(Ahk @ Oct 26 2006, 07:37 PM) *
Version 1.1 posted. See above.


Where did it go...?
hepburn
This is quite good actually, albeit a bit slow, but it would have to be.
Ahk
QUOTE(hepburn @ Jan 24 2007, 01:31 PM) *
This is quite good actually, albeit a bit slow, but it would have to be.


If you remove some of the lines in the objects, it also runs much faster. I commonly used 15x10, and only that large because tabs are mostly grey area...not good for checks, and I also wanted to see if the tab was activated.

I posted it as more as a model for people to look at for straight out screen scraping...though I did create it for a windows application that moved the tabs up to 5 pixels away when switching to other windows.

Pixels would be much faster, especially if you use the ObjLoadWindow/ObjRelease (assuming they work).
hepburn
Yea I think I may mess about with it a little, but so far I've had some good results and its very accurate.
Would be nice to be able to search a rectangular area rather then a square though, which I think will be most first modification. That way allowing you to search a strip of the screen for the object.
I've been using pretty darn small objects so I suppose the next step really has to be pixels, which could work.
Thanks
UnleashedNewt
Will this allow me to look for a certain object somewhere on a screen of 1024 x 768?

How long would it take to do a scan full scan of that scale?

I'm trying to figure this thing out but its a bit confusing. What do I need to change to search for my own object and what do I need to change for searching the parameters of 1024 x 768?

Would I change this line?

Call ScreenScrape blue, 1024, 768, ?? //Scrape 0,0 to 14, 14 (0,0 counts as one set of pixels...)

LOL wow I tried the test object looking for the AC tool icon and changed this line to this

Call ScreenScrape Icon, 300, 2, 2 //Scrape 0,0 to 14, 14 (0,0 counts as one set of pixels...)

does that mean its going to make a 300, 300 sweep? Well anyways it found the object after about 3 mins of scanning when I moved the box a bit to the right. For my purposes I don't mind if it takes 5 minutes to scan, but any longer it might be too much.
UnleashedNewt
I should also say that is some sophisticated coding or i'm a newbie for life sad.gif

Nice job! I do have a question though, in terms of speed is this about as fast as a screenscrape can be? Or do you think there might be other ways to make it extremely fast? Like a full search for a small object in less then 1 minute on a full screen?
Ahk
QUOTE(UnleashedNewt @ Feb 4 2007, 04:59 AM) *
I should also say that is some sophisticated coding or i'm a newbie for life sad.gif

Nice job! I do have a question though, in terms of speed is this about as fast as a screenscrape can be? Or do you think there might be other ways to make it extremely fast? Like a full search for a small object in less then 1 minute on a full screen?


300 will make a 300x300 sweep, yes.

A full screen scan will always take a VERY long time to do. There are some alternative routes you can take though.

1) Try to narrow the search area. If only part of the screen is the area you're really interested in, then you can cut a huge scan area out of the picture.

2) If your object has more than a couple of pixels of the same color, you would probably greatly benefit by trying to switch to LoadRGB and test every other pixel (or more) for that color, and when found, check for the object *around* that position. I object test should fail on the first pixel that doesn't match up, so it'd be much easier to try for the object in a small area where the color was picked up at.

3) Figure out a way to hint where the object should be that can let you use #2, like selection arrows. I don't know what you're using this for, so I have to assume a game.

4) Modify the code to specify the start x/end x/start y/end y so that you can scan a rectangular area instead of the regular left->right, down 1, left->right method.

5) Find a way to avoid scraping for the object in the first place to save a lot of time.

You should know that if even one pixel is off in your object, the scrape will not work. So if this is a monster or something that can turn, you're wasting your time....a better method all around would be to use the game's own memory to select things, find where they are, etc. I can't help you with that...
Chazcon
Thank you Ahk, for this sweet little tidbit. Very useful! Using it in a LotR macro.

Some of us are still around (and hell, I'm still a rank n00b compared to the old guard here)

Ipa: I recommend this thread be moved over to the Macro Development forum, as it's a very handy script for more than just AC smile.gif
Ahk
Oops just posted to other topic that this was here wink.gif

Check the other post as it might help some, unless it's already been said here.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.