Sign in to follow this  
Followers 0
Ritz

Efficient data structures?

1 post in this topic

I have a program which checks a set of items in a bitmapped-listview (i.e. it is not accessible except by looking at pixels). When you double click an item in the view, it opens a window which contains the name of the listview item in its title bar (ex: if the top item is "Item 1", then you double click it and a window entitled "Item 1" opens).

Now the intuitive way to do this is to simply write a bot to scan each item, opening each new window and writing a new sequence of code to create one giant Select statement:

;get the checksum of the pixel region
$itemChecksum = PixelChecksum($itemTopX, $itemTopY, $itemBottomX, $itemBottomY)

;open the window
MouseClick($itemBottomX, $itemBottomY, 2)

;wait for it to open
Sleep(1000)

;get the title of the window (and consequently, the title of the item in the listview)
$itemName = WinGetTitle()

;add on to the file
FileWrite($myFile, 'Case $_itemChecksum = ' & $itemChecksum & @CRLF & 'Return ' & $itemName & @CRLF)

Then I just loop through until I've scanned all the windows in the listview, and I'm done. I can then copy/paste the big set of Case statements into a function, ChecksumToItemName($itemChecksum).

Now this is all fine and good if the items are static (as I originally thought they were). However, it seems like every day a large # of the items are removed and new ones (with new names etc) are inserted. I could just run my scanner every day that I start it up, but that is really not an elegant solution. On the other hand, neither is creating these huge (1000+) Case Select statements. I feel like it would also start to get really slow after around 10,000 or so.

What would be really nice is to have a hashmap or a binary search tree of some sort so that I could just make it load a file at startup and be done with it, while guaranteeing constant time search and the ability to add new ones dynamically. I suppose I could do this with a very large array, but I'm doing a checksum on over 700 pixels, so my array would need to be 2^700, and that's not gonna fly.

Any ideas?

Share this post


Link to post
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
Sign in to follow this  
Followers 0