How to Iteratively Click a List?

I don't quite understand why there can be a blank line between rows.

I think, in general, your approach is OK.

For the end, there is a screen short once you reach the end. You can see "Today's Options Statistics" below all options. That is how you determine it is the end. I don't know to let KM know where is the end based on this info.

I highlighted the "blank line" between rows in the image below so you will know what I'm talking about. It's actually about 1.5 lines in height. (This fact may impact how I write my code.) You've asked me a couple of times what I meant by "blank line" and I think this should clarify that.

I think I can use that phrase "Today's Option Statistics" to solve the problem of detecting end of the job, but I won't be using it in a way you expect.

Remember, the goal I'm setting is to provide the absolute simplest macro to do the job -- I'm not trying to solve the job exactly the way that a human would do it. You have eyes and a brain, but a macro doesn't have those things, at least not very good ones. For a good "eyes and brain" approach, that's what AppleScript is for. But we are resorting to Plan C so there are some tricks I need to employ to keep the code as simple and short as possible.

We are going down the path of tricks and hacks to get the job done as simply as possible, with the least code required.

May I assume that nobody will be moving the mouse while the macro is running? Mouse movement can mess up any macro that uses the mouse. If this is a problem, my current methods won't work. But I could adapt.

While I go make supper and await your reply, one thing I can't do for you, and need done, is get a count of the exact number of pixels per row. It's very likely that the number will not be a fractional number. The best way for you to calculate this is to find a way to get your cursor position and count the number of pixels between the bottom of the first item row and the bottom of, say, the 11th item row. Get that number and divide by ten. (11 is ten more than 1.) If it isn't an integer you may have done something wrong. This is important because it will determine how much the mouse moves down between clicks. A number that's too large may miss a row. A number that's too small may access the same row twice, but you said that wasn't a problem, so too small is better than too large. One thing I can't test is whether there's a space between rows that can't be clicked on. I hope not, or this may slow us down a little bit.

P.S. I recommend that the app you are using NOT be in full screen mode because I'm not familiar with the intricacies of writing KM macros for full screen apps.

You've asked me a couple of times what I meant by "blank line" and I think this should clarify that.

If you click the area that you boxed, nothing happens.

May I assume that nobody will be moving the mouse while the macro is running?

Yes.

recommend that the app you are using NOT be in full screen mode

It doesn't matter to me whether it is full screen or not. You can assume that it is not in full screen.

While I go make supper and await your reply, one thing I can't do for you, and need done, is get a count of the exact number of pixels per row.

This can be figured out by checking the screenshot image that was posted. The number of pixels does not change when the app window is zoomed in/out.

I will need to do other things between sending each option to a bounded color as I mentioned before. This was not mentioned in the original question as I think it should be relatively easy to achieve. But since you use hacks, there will be interdependency between options, are you able to restore the previous mouse location when I do the other things?

Great question.

Do you recall when I asked you if it would be a harmful thing if the macro performed some actions on the same row twice? You said no. But at that point in time I didn't know what your other actions were, and they should have been included in the question and your answer. So the question is now back on the table. If all the actions, including the ones you haven't revealed yet, are performed twice on the same row, is that a problem?

In order to find the simplest solution, I need to know the entire problem. If I take shortcuts, it may not work when you add new things to the problem.

Once I send an option to a bounded color, I will need to click "Chart" then do something over there. Then come back to the option tab to continue to the next option. That is it.

You still haven't answered this question: "So the question is now back on the table. If all the actions, including the ones you haven't revealed yet, are performed twice on the same row, is that a problem?"

I hate to seem argumentative, and I respect your right to keep some things secret, but I'm not sure I can write code to meet your requirements if you won't tell me your requirements. My solution involves lots of shortcuts and assumptions which may not be adaptable to your requirements unless you state your requirements.

P.S. I don't know what you mean by "click Chart". I looked at the screenshot and couldn't find something labelled "Chart." It's a high-res screen and it's hard to find a tiny word on a big screen like that. I found the word "Charts" but not the word "Chart".

"So the question is now back on the table. If all the actions, including the ones you haven't revealed yet, are performed twice on the same row, is that a problem? "

I don't understand what you refer to.

I don't know what you mean by "click Chart".

It should "Charts" instead of "Chart". It is on the top line of the screenshot.

My solution involves lots of shortcuts and assumptions which may not be adaptable to your requirements unless you state your requirements.

The things after Charts should not be relevant to clicking the options. I don't think you should assume too much. I want to have the freedom to do whatever I want to do with Charts. As long as I can get back to the "Trade" tab after working with "Charts", I am fine.

That's because it's hard for me to word my question when you won't tell me what your requirements are in the Chart pane of the window.

The reason for my questions is because I am quite sure you are (falsely) assuming that there will be only one time each row is processed with mouse clicks. But I can't guarantee that. There will very likely be a few cases where the same row is processed twice, including what you do in the Charts pane. And that will mean the Charts tab will be processed twice for some of the rows. Is this clear now? And if it's clear, is this a problem?

The code that I want to write for you is surprisingly simple, but it will likely not meet your needs if you are unhappy with the fact that it will occasionally process the same row of data twice. I don't want to triple the size of my code if I don't have to. I'm sure you can empathize with that.

I am sure that you are expecting that my code is perfectly capable of ensuring that it will never process a row twice, because as a human being it is a perfectly simple task for yourself to ensure that you would never process the same row twice. But my code won't be as smart as a human. In fact it will be running almost blindly, which is why I call it "operating in Helen Keller Mode."

That's because it's hard for me to word my question when you won't tell me what your requirements are in the Chart pane of the window.

I don't understand why what I do on the Charts tab matters. There can be arbitrary things I do in Charts, there are no set things that I will do. Therefore, you should only assume thatyou click "Charts" (at that time all the contents in "Trade" will be replaced by the content in the "Charts"), there will be a bunch of clicks other there. Then, click "Trade" (at that time the original content of "Trade" will come back), then move on from there. Then, the only thing is that you lose the previous mouse location before switching to "Charts", so you need to somehow restore the previous mouse locations.

I'm sure you can empathize with that.

No problem. I will have to see what the code is before I can provide feedback when there are problems.

But my code won't be as smart as a human. In fact it will be running almost blindly, which is why I call it "operating in Helen Keller Mode."

I don't know how bad it is when you say "process a row twice". Once I try your code, then I may provide more useful feedback.

Okay, I'll start coding. But you'll understand the problem the MOMENT you realize that my code may be processing, more than once, the same Charts macro for the same line of text in your main window. Then you might say, "I didn't know your code will process some of the same lines twice! That's not what I wanted! That won't work for me!" And my reply will be "But you kept saying, 'I don't see why that would matter.' "

Okay, here's the first half of the macro. The first half deals ONLY with window frame data collection. There's more than one way to do this data collection, and this is not the way you were imagining, but it is the way that should best help you to appreciate what this macro is going to do. I would suggest that you run this macro in order to see what this first version of the macro will look like before it starts processing your data.

This half of the macro can be changed/improved later, once the whole macro works. I wrote it this way because this way has high reliability. There are other ways which won't require your input, but those ways will require a lot more troubleshooting, so by doing it this way I'm saving you a lot of troubleshooting work.

The important idea that you need to glean from this code is that this macro is gathering all the data points that frame the rectangle where this macro will be working. I want you to see that and understand that. The next step will be to start doing the actual work. But if you spot any wrong assumptions that I've made, this would be a good chance to point them out.

Remember, I've done this before, for a more complicated app, and I'm confident I can do it again for you.

TD Macro.kmmacros (16 KB)