shootingiron Posted September 28, 2006 Report Share Posted September 28, 2006 Hello. I know this question has been asked/answered a thousand times on these forums, but my situation is a bit different. I play a game called EVE oline, and when I'm mining in space I want an alarm to sound when my cargo hold gets full of ore. I originally though ths would be very easy, I just have to check a pixel at the end of my cargo hold capacity bar. When it changes to orange, ring the bell. However, it was isn't so easy, because not only does this bar have a gradient and a shading, it's also semi transparent. So that means that if my camera angle is over a diferent colored portion of the background, then color will change to a different shade. Any ideas how I can over come this? Quote Link to comment Share on other sites More sharing options...
kevin Posted September 28, 2006 Report Share Posted September 28, 2006 That is a tough one. Instead of looking for a specific color perhaps you could get the color when the ore car is not full and then have the macro look for a change. Another thought is that you may be able to look for a range of colors instead of specific colors. Quote Link to comment Share on other sites More sharing options...
shootingiron Posted September 28, 2006 Author Report Share Posted September 28, 2006 Ah, looking for a change of colors won't work because if the background changes so will my color. For instance my mining laser will fire every second or so, and change the background, and thus the color of the capacity bar. As for looking for a range of colors, I think that is the way to go. An earlier attempt had me doing a 5x5 pixel search and write 25 pixel colors in to a text file multiple times, in different circumstances. Then I'd check the pixels on the screen against the colors in the text file. Not only was this pretty inellegant and slow, ther are also a lot of colors, such as shades of white and black that are present regardless of when the cargo bar is either orange (when she is full) or blue (when she is empty). So maybe I have to some how search for a whole set of orange shades at the end of the cargo bar ... Quote Link to comment Share on other sites More sharing options...
shootingiron Posted September 28, 2006 Author Report Share Posted September 28, 2006 Yes, thats the solution ... I want to check a single pixel and see if it is a shade of orange. I should be able to do this by writing the result of a get pixel command in the variable and then deconstructing it to see if it has the elements that would make it orange. But how do i tell if some random 1 to 8 digit number that this function generates is orange or not? Quote Link to comment Share on other sites More sharing options...
kevin Posted September 28, 2006 Report Share Posted September 28, 2006 It sounds like you will need to have a basic understanding of how colors are created on your computer. Each color on your computer is stored as 3 hexadecimal numbers in BGR format. BGR stands for Blue, Green and Red. Each hexadecimal number represents the amount of that color. So, for example, if the R value is 0 then there is no red. If the R value is FF then there is a lot of red and if the R value is 7F then there is 1/2 the available amount of red. Each hexadecimal number is combined into a color single value. The hexadecimal values range from 00 through FF. On my Windows XP desktop there is a cloudy blue sky. One of the blue colors has a pixel color of EE763B. This means there is EE Red, 76 Green, and 3B Red. Macro Express does not have direct support for hexadecimal numbers. The Get Pixel Color/ command returns a single integer value. For the color EE763B the integer value returned is 15627835. You can use the Calculator in Windows to convert the hexadecimal value of EE763B into an integer and back to confirm this. Knowing this you could write a macro that evaluates colors. But since Macro Express does not directly support hexadecimal numbers you will have to write some routines to do hexadecimal math. I didn't say it was easy, just that it could be done. Quote Link to comment Share on other sites More sharing options...
shootingiron Posted September 28, 2006 Author Report Share Posted September 28, 2006 Right, I do know that hexadecimal is a base 16 number system as opposed to a base 10. I'm looking on the web, but i still have no idea how to convert 15627835 into EE763B. So maybe it's not a basic understanding of colors that I need, but of math! Quote Link to comment Share on other sites More sharing options...
shootingiron Posted September 29, 2006 Author Report Share Posted September 29, 2006 Update: Here is where I stand. I can convert the decimal number to hexadecimal with a pen and paper by repeatedly deviding the number/solution by 16 and recording the remainder. But how do I convert this into code? 15627835/16 = 976739r11 B 976739/16 = 61046r3 61046/16 = 3815r6 3815/16 = 238r7 238/16 = 14r14 E 14/16 = 0r14 E 15627835dec = EE763Bhex! Quote Link to comment Share on other sites More sharing options...
joe Posted September 29, 2006 Report Share Posted September 29, 2006 You could also use the built-in Windows calculator to convert. Change the display to hex, enter the number, and then change the display back to decimal. Quote Link to comment Share on other sites More sharing options...
shootingiron Posted September 29, 2006 Author Report Share Posted September 29, 2006 When you say the built in calculator, you don't mean the app i activate from the start button, but some sort of dos/command line function? Quote Link to comment Share on other sites More sharing options...
joe Posted September 29, 2006 Report Share Posted September 29, 2006 The Windows calculator. You can do all sorts of great things with it. Almost every key has an equivalent keyboard command. You can cut, paste, and copy from it to your clipboard. It works very well using Macro Express's Window Control commands. In your case, its just a matter of switching it to hex mode, pasting a hex string into it, changing it back to decimals, and then copying from it to the clipboard. And of course Macro Express can handle all of this. Quote Link to comment Share on other sites More sharing options...
shootingiron Posted September 29, 2006 Author Report Share Posted September 29, 2006 OK then, excellent .. it will be a while before I can implement this as I have to go away for work, but I'll let you guys know how it turns out. =) Quote Link to comment Share on other sites More sharing options...
kevin Posted September 30, 2006 Report Share Posted September 30, 2006 Here is a macro that will split the pixel color into the component parts of Red, Green and Blue. // Get pixel color Get Pixel: Under Mouse into %N10% Variable Modify Integer: Copy %N10% to %N1% Variable Modify Integer: Convert %N1% to decimal %D1% // Get Red value Variable Modify Decimal: %D1% = %D1% / 256 Variable Modify Decimal: Copy fraction part of %D1% to %D11% Variable Modify Decimal: %D11% = %D11% * 256 // Get Green value Variable Modify Decimal: Truncate %D1% to integer %N1% Variable Modify Integer: Convert %N1% to decimal %D1% Variable Modify Decimal: %D1% = %D1% / 256 Variable Modify Decimal: Copy fraction part of %D1% to %D12% Variable Modify Decimal: %D12% = %D12% * 256 // Get Blue value Variable Modify Decimal: Truncate %D1% to integer %N1% Variable Modify Integer: Convert %N1% to decimal %D13% // Here: // D11 = Red // D12 = Green // D13 = Blue Text Box Display: Result Now you will need to figure out how to determine what range of values represent some shade of orange. Good luck. Let us know how it turns out. Quote Link to comment Share on other sites More sharing options...
shootingiron Posted September 30, 2006 Author Report Share Posted September 30, 2006 Thats brilliant! I had hit on the idea to use trunications, but everytihg else is spectacular and far more efficient than what I was trying. A thosand thank-yous and I'll keep you informed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.