Jump to content
Macro Express Forums

Can A Macro Check For Location Color?


Drone
 Share

Recommended Posts

I'm a disabled veteran who loves to play video games but is at a disadvantage because I cannot use a mouse very well now. Because of my situation I was told by the creators of a video game that if I can come up with a way to help me play better it would be fine with them as long as I don't distribute the software. Unfortunately programming isn't my strong point, but I do get the basic idea behind running a macro.

 

What I want to do is have a macro that simulates a left mouse click, then checks to see if a swinging yellow arrow is over the "red area" that would be considered a hit, then clicks the left mouse button if (when) it is. As it stands I can't seem to hit anything with my disability severely limiting my use of the mouse, and there's not even a keyboard command to use a weapon much less get it in the small red "hit" area.

 

Can someone help me?

 

Details...

 

The red "hit" area is always at a fixed point on the interface, and the yellow arrow always travels the same semi-circular path - but at different speeds so you can't make a macro that relies on timing alone. I know how to simulate the mouse clicks, but I can't figure out how to make the macro check to see if the red area has turned yellow.

 

Thanks in advance for any help!

Link to comment
Share on other sites

Yeah, I tried that last night, but apparently the program doesn't check for pixel color as often as I need it to. Either that or I'm doing it wrong. This is what I have...

 

 

<LCLK>

<REP3:08:000001:000002:0006:0:01:58623>

<GETPX:6:S:000227:000725>

<IFVAR2:2:06:1:58623>

<LCLK>

<ENDIF>

<ENDREP>

 

Any suggestions?

Link to comment
Share on other sites

Thanks for including the script, that helps a lot.

 

In terms of timing this should go pretty quick, at least a few hundred times a second or something on that order. If you would like to test the timing I would suggest adding a bit in your loop that would log each loop. Include the milliseconds and it should give you a pretty good idea how fast it is going.

 

Again I have to admit I’m not sure exactly what you are doing so I’ll just toss out some things.

 

1- Are you entering an “enter” in the text type boxes? You should use the <Enter> instead if that’s the case. I don’t know if that makes any difference but I’ve run into weirdness before with doing things like entering a space instead of <SPACE> before. Although I used to enter carriage returns in my text in the early days and I do now they will play back. <TEXTTYPE:<ENTER> >

2- What is you text type delay? If it is set high you might miss it. I often will set the text type delay up to 200mS in order to avoid timing problems on clunky programs but if yours was set to 500 there would be a half second delay. Again, logging the time to a variable would help show this.

3- It seems odd that you are hitting an enter twice outside the if statement every time the thing loops. Maybe there’s a reason for this but that’s a lot of enter key strokes. I’m talking about lines 4 and 6.

4- You could also log the color each time to get a picture of what’s happening.

5- I noticed you have a left mouse click in the “If”. Is this your trigger? If it is it’s not clicking in the right spot. You would need to move the mouse to 227,725 first. Also you can’t be touching the mouse during this time.

6- Your macro keeps firing even after you have success. I’m thinking that if it’s a target the fire should be outside the repeat.

7- Often graphics are not one solid color as they seem. Look closely at the target. Is there any shading? Any gradient in hue? I bet if you did a screen shot and looked at the pixel colors of each individual pixel you will find that they’re all slightly different. In this case I suggest that you look at all the pixel colors and see if you can see a pattern in the number. Let’s say that they’re all in the 50,000 range and when it isn’t in the cross hairs it’s in the 30,000 range. So in this case do an IF greater than 50,000 and less than 60,000 instead of trying for an exact match.

 

Let me rearrange what you have a second. Now I don’t know what the command sequence should be but let’s say you had to enter a left click to start the game offering the target. Then a swinging target dangles back and forth that you want to shoot by hitting the left mouse button. Here’s how I would do it. I took out the enters because I’m not sure what they are doing. Also you can remove the pause once you learn to take your paws off the mouse.

 

<LCLK><PAUSE2:Center,CenterTake your hands off the mouse! Hit enter on the keyboard to continue. T ><MMS2:227,725><REP3:08:000002:000001:0001:1:01:T1 ><GETPX:6:S:000227:000725><IFVAR2:2:06:1:58623 ><EXITREP><ENDIF><ENDREP><LCLK><BEEP>

 

To do some logging I suggest creating the CRLF (T95) and TAB (T96) like in my CRLF TAB macro here before the repeat then in the repeat write the time with milliseconds to T6 and then write it all to an accumulator variable. It would look something like

<TVAR2:08:01:%T6%%T96%%N1%%T95%>

Then write all that to a file after the repeat exit. Don’t be tempted to append to a text file instead as I think that might slow you down too much. But you can try it and see what the time log says! Afterwards you can view this text file in Notepad or Excel to see what’s what.

Link to comment
Share on other sites

Thanks very much! Its a step in the right direction but the macro still seems to run too slow. Thanks to your advice I was able to shorten the macro down to five lines...

 

1. Left Mouse Click

2. Repeat until %N2% = 58623

3. Get Pixel Color 227,725 into %N2%

4. End Repeat

5. Left Mouse Click

 

For the game, all you have to do is click the left mouse button and then left click again when the pendelum is in the center. You don't have to place the mouse anywhere specific and you can move it around all you want, just as long as you click at the right times. The problem is that the pendelum does a complete half-circle swing just about every second, and so to get it in the middle the macro needs to be checking that pixel almost every 1/25th of a second to see if it's changed from red to yellow.

 

Even when it works the pendelum seems to always miss the middle because I guess it takes too long for the macro to tell the mouse to click. I tried to find a way to time the loop but couldn't make it work. I'm afraid I'm not a very good programmer, and it's kind hard to type because my fingers are pretty messed up.

 

The written logic would be...

 

1. Left mouse click to get the pendelum swinging.

2. Check if pixel at 227, 725 is red or yellow.

3. If 227, 725 is red keep checking.

4. If 227, 725 is yellow then left mouse click immediately.

 

The key is speed. That pixel needs to be checked very often, maybe even 50 or so times per second or more, and the mouse needs to be told as fast as possible to left click.

 

You mentioned the pixel maybe changing color during the game, so I took about 20 screenshots during various states and it never changed color at that pixel location. It's not a very grahpics intensive game. A friend told me I might be better off with a program specifically designed to do this simple task, and which repeats very very very fast. I don't even know where to begin if I need to go down that route? Any suggestions?

 

Thanks for all your help! I hope I get this figured out. I love to play video games and it would be awful if I couldn't play even very simple ones like this because of my disability.

Link to comment
Share on other sites

A friend told me I might be better off with a program specifically designed to do this simple task, and which repeats very very very fast.

Macro Express is specifically designed to do this simple task.

 

You are running a 5-line macro that checks for the pixel color and then clicks the mouse when found. On my computer, which is old, this macro runs 30,000 loops in a single second and then clicks the mouse. Much, much faster than needed, eh?

 

Forget the game for the moment. Create a loop timing test for yourself (or use the one below) and run it to see how fast it is on your computer. The T1 string holds the start time within 1/1000 of a second. The T2 string is the ending time. Compare the two in the Debug window after the macro runs.

 

Date/Time: Save "hh.mm.ss.zzz" into %T1%
Repeat Start (Repeat 30000 times)
 Get Pixel: Screen Coords: 227,725 into %N6%
Repeat End
Mouse Left Button Click
Date/Time: Save "hh.mm.ss.zzz" into %T2%
Macro Stop


<DT:hh.mm.ss.zzzT:01:1:><REP3:01:000001:000001:30000:0:01:><GETPX:6:S:000227:000725><ENDREP><LCLK><DT:hh.mm.ss.zzzT:02:1:><MSTOP>

Link to comment
Share on other sites

Joe’s right on here. These loops are very fast. I have logical comparison processes that read from files and do comparisons in nested loops. The section itself is a couple hundred lines long and given that it’s nested with other repetitive routines this means it’s on the order ot 10,000 lines of instruction it’s doing INCLUDING reading and writing from files and this part of my macro takes about 1.5 seconds.

 

Joe is suggesting what I suggested. Except I was also suggesting logging the colors. I’ll think you’ll find the answer there.

 

What I think is the problem is the color and I’m afraid I haven’t made myself clear. Let me try another tack. See the simley face post icons some use here? They’re yellow, right? Well not exactly. What they are is several hudred shades of yellow to give the depth to make them look dimensional. Let’s take a closer look:

 

smiley.gif

 

This is one of those smileys at 10X magnification. See how the individual pixels are slightly different colors? If you were just one pixel off ME would not find a match. In fact even half way towards the center where it appears the same they are different. Only the very center pixels are the same. And this is a pretty simple guy. If the pendulum is even slightly realistic none of the colors will be the same. And depending on the lighting and such from the games rendering it could be different all the time. You see most games render every frame so there is a great deal of randomness. This is why I think you need to do a closer analysis of the colors and come up with some way to accept a range of colors. Otherwise it’s hit or miss. Bha ha ha ha….

Link to comment
Share on other sites

Okay, I think my problem is definitely speed. I did what you recommended and made a macro that will log the time it took to perform the pixel checks. You guys said that your macros go really fast, but mine seem to be really slow. I started taking screenshots so you can see it easier than I can describe...

 

The first one I did was for 5000 times, and it seemed to take forever. I think I stopped it before it was done, but a few minutes had gone by and I thought something was wrong...

 

http://www.tarrif.net/macro/check3.bmp

 

As you can see it took more than 4 minutes and still wasn't done. So I changed it from 5000 to 1000. That one definitely completed, but it took more than 2 minutes and 30 seconds to complete!

 

http://www.tarrif.net/macro/check4.bmp

 

Am I doing something wrong? You guys say your computers process these macros much faster than that, and it clearly seems to be the problem standing in my way of finishing this macro and enjoying my game.

 

-----------------------------------

 

You also mentioned colors, so I went ahead and started logging the colors. First, here's what the pendelum looks like in various states.

 

http://www.tarrif.net/macro/pendelum.bmp

 

As you can see it's a very simple guage and the artwork is nothing fancy. The whole game doesn't use more than 78 mb of system resources to run, so it's not a very high-end game. The last guage in the bottom middle has a blue rectangle around where the coordinates I tested are for the test below.

 

Here's what the results I got when the pendelum was no where near the middle...

 

http://www.tarrif.net/macro/check1.bmp

 

Here's what I got when it was very close to the exact middle...

 

http://www.tarrif.net/macro/check2.bmp

 

I hope this helps my explainations.

 

-----------------------------------------------

 

I am using the free trial version of Macro Express 3.5e My computer is a Pentium 4 1.6 Ghz with 2.1 GB of DDR RAM. Is there anything I can do to get my macro's running faster? I'm not running a lot of programs in the background - hardly any at all. I even shut off my virus checker.

 

Thanks for all your help already, you've definitely helped out a lot! I just hope I can get this to work. Sitting here disabled is boring, and constantly losing at video games isn't helping pass the time :(

Link to comment
Share on other sites

It may be that the game is taking so many CPU cycles that the macros run slower. You might try adjusting the Macro Priority. The first step is to download tweakme3.mxe from www.macros.com/downmore.htm. Save it somewhere on your hard drive and double click on it.

 

For the first test you might want to turn the Macro Priority feature off by entering a -1. If that helps macros run faster in the game then you can leave it.

 

You may find that other programs run too slowly with the Macro Priority turned off. If this is the case you may want to experiment with different settings. Perhaps set the macro priority to 10,000 or 50,000.

 

If turning of the Macro Priority feature does not help macros running in your game, then we recommend that you set it back to the default value of 1000.

Link to comment
Share on other sites

I think your problem is timing. As you can see for yourself it's not running very quickly in the program. However I have no idea how to rectify this. Obviously the game it taking priority over other applications. I think Kevin should be able to help you there.

 

pend.gif

 

I would like to beat a dead horse though. I looked at your graphic and it is not at all like I thought so I think you should be able to hit it with one pixel color match. But you do need to take care to get the right pixel. Above is the pendulum at 10X. See how there are several colors of yellow? You need to catch the top 4 pixels I’m thinking. They are all the same color 321276 but below that each rank is a different color. It goes; 3320252, 319228, 318204 and so on. Now notice the top half of the red are real low numbers? At about the halfway point in the red shade gets darker the numbers jump up quickly starting at to 135657 but if in your test if you said Greater than 300000 instead of an exact match you might have greater success.

Link to comment
Share on other sites

One more thought. You mouse click to start the pendulum, right? IF it always started exactly then and IF it always had the same frequency you should be able to have ME do the first click, wait a period of time and then click again instead of sampling colors. I would use a stop watch and time 10 full swings and then divide by 40 as a starting place the monkey with the timing a bit. But those are two big “ifs“, they may have some randomness in there that would make this futile.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...