Jump to content

PixelGrab


Kohr
 Share

Recommended Posts

Here is a tool I made that helps to get pixel colors in an area. I mainly wanted it so I could play around with a form of object recognition and I wanted an easy way to see if there are color patterns.

Credits:

Manadar(DrawBox concept)

Larry & Xandl(AU3MAG)

Any feedback is welcome.

Kohr

Previous Number of downloads: 195

PixelGrab_v1.8.au3

v1.8

Excel now moves to the next sheet to handle overflow when you have more than 256 columns. It keeps moving to the next sheet up to 1280 columns (5 sheets). Excel button now works like Html. If you check ">4000 pixels" and hit the Excel button it bypasses the ListView so you can now display more color hex codes in Excel.

v1.7

Excel use is no longer the embedded type. This should work better I hope. Only restriction is if your width is greater than 256 then it will get cut due to limits of Excel. DrawBox should work a lot better now. I figured out that since I was using "SpaceBar" to get out of the loops it was actually hitting the DrawBox button a 2nd time causing it to act weird. To fix I just disabled the button after it is pressed and added a sleep command after hitting the 1st spacebar.

v1.6

Added ability for Html to get more than 4000 pixels. It takes about 60 secs to do 10k pixels for me so if you want a very large area then it will take a while. To use (which bypasses colors in ListView) check the ">4000 pixels" checkbox and hit the Html button. Html will indicate color (not sure if it is 100% accurate when in html), hex code, and true x/y coordinates. Changed the tooltip for DrawBox so it will still display when you get to the screen edges and it also indicates the total pixels in the box.

v1.5

Added Html export for the colors. Use it after you get colors. This feature is making me reconsider a few things in overall design so any input will be considered. Also a few other minor tweaks.

v1.4

Implimented use of AU3MAG (code from Larry & Xandl). Improved speed on getting colors (limited to number of controls allowed). Added export of the colors (hex code) to embedded excel.

v1.3

Added pixel magnifier using mouse mode. Added ability to show the color region captured (1 and 2x magnify) in a seperate window.

v1.2

Resizing works better now. Added ability to save colors. Added several menu items on listviews.

v1.1

Added simple way for GUI to show up better on other resolutions.

Added tooltip x/y coords when using tools.

Edited by Kohr
Link to comment
Share on other sites

Hey that's pretty cool! You could use that for finding pictures on the screen like so many people have requested. You'd have to put all of them into an array somehow then search the screen for that array of colors... not sure EXACTLY how but I'm sure it's possible. Nice work!

- Dan [Website]

Link to comment
Share on other sites

This is pretty cool. How long does it take to read the entire screen?

I believe it took around 5 minutes on my pc but there are a couple of factors as to why it will not work.

1. The command GUICtrlSetBkColor only works to set the List item color after you use GUICtrlCreateListViewItem.

2. Since I have to use GUICtrlCreateListViewItem then it is restricted to the maximum controls of 4093.

3. I tried using _GUICtrlListViewInsertItem to get around the control maximum but it does not seam to work with GUICtrlSetBkColor so I had to either go with the ability to set any size (but lose the item color) OR keep the color and it does not work right once the 4093 limit is hit.

4. I mainly intended for it to be used for smaller areas anyway to help with creating bots and/or ocr recognition.

Kohr

Link to comment
Share on other sites

Fantastic job - lots to work with.

BTW - I needed line 415 ----$oExcel = ObjCreate("OWC10.spreadsheet") for it to run.

According to MSDN http://msdn.microsoft.com/library/default...._HV05203323.asp

it should be fine without the need for a version number.

Quote from that site

If you use an identifier without a version number suffix, you create an object in the most recent version of Microsoft Office Web Components available on the machine where the macro is running.

No idea why it doesn't work as coded for you.

Kohr

Link to comment
Share on other sites

According to MSDN http://msdn.microsoft.com/library/default...._HV05203323.asp

it should be fine without the need for a version number.

Quote from that site

No idea why it doesn't work as coded for you.

Kohr

I get the same error with v1.3 as well ==> Variable must be of type "Object".:

I change it to OWC10 and it works - so who knows.

Is there a way to change excel.object to R1C1 reference style?

Link to comment
Share on other sites

I get the same error with v1.3 as well ==> Variable must be of type "Object".:

I change it to OWC10 and it works - so who knows.

Is there a way to change excel.object to R1C1 reference style?

As far as I can tell, you can't change OWC.Spreadsheet to R1C1 in code. I don't know if it is supported or not, as I don't have the necessary documentation, but it doesn't work when I attempt to perform the action as I would in Excel.Application:

$oExcel.Application.ReferenceStyle = -4150 ; $xlR1C1 = -4150, $xlA1 = 1oÝ÷ ØêÚºÚ"µÍÌÍÛÑ^Ù[[ÙJ    ][ÝÝÚ]]][ÝÊKY[ÙTÝ[HHMMLÈ    ÌÍÞPÌHHMML  ÌÍÞLHH

So I'm guessing not.

Kohr, perhaps you should consider creating a full Excel object (Excel.Application) instead of the almost-completely-useless embeddable OWC. I had to use OWC10 as well to get your code to work.

-S

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
Link to comment
Share on other sites

Kohr, perhaps you should consider creating a full Excel object (Excel.Application) instead of the almost-completely-useless embeddable OWC. I had to use OWC10 as well to get your code to work.

I will change it to that then for the next release. It was something I added mainly to see if it was possible and it worked fine for me but since users are having issues I will just change it. The only real benefit I saw with embedded was it allowed more columns. It's too bad Excel doesn't support all colors because that would have been nice as well (another reason I tried exporting to Excel).

I will try to get it done soon if I can pull myself away from nwn2 :whistle: .

Kohr

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