OCR Condition for Until Action - Using Var for Input Text

I'm trying to get the until action to work with OCR using a variable for the input text. I'm working inside an app. I want to scroll down until specific text is displayed. I got it working by adding the text to search for directly inside the contains box. is there a way to add a variable to that box so i can use different text each time it runs? i added the text to a variable called clip and i tried to insert the variable inside that box using %clip% and %Variable%clip% but it doesn't work. Is there a way to parse the variable into that input box so it can change dynamically every time it runs?

Two things. First, don't use "Languages - English" but instead change that to "Apple Text Recognition" which is about 6x faster and 10x better at reading.

Second, it is possible to use a variable in that box, but since you didn't show how you were doing it in the above screenshot, I can't tell you what you were doing wrong. Maybe there was something wrong with your syntax. If you show us what isn't working, I'm sure we can fix it.

Hi Airy thanks I got it working with your help. I had an emoji in the variable thats why it was failing. Since I cant find text containing emojis I'm splitting the first two lines of the text block and removing the emojis and then adding the first line into clip 1 variable and the second line into clip 2 variable. the problem is when I add two ocr's to the same until action it fails. if I only use one variable it works perfectly and it doesnt matter which variable I use they both work. but when they are both added together it fails. do you know if this action works with two ocr's? please see screenshot

The first thing I would do is use "%Variable%clip1%" instead of "%clip1%". It may not change your results, but in some situations your shorthand will cause you problems.

Second, it is perfectly legal to have multiple OCR conditions in an action like that. It should work. If it's not working, it's either because your variables don't contain what you think they do, or because what you intended was to look for EITHER string in which case you need "if any of the following are true" instead of "if all of the following are true." You haven't told us what exactly is in the variables clip1 and clip so it's hard to be sure if this is your problem.

Third, there's a chance that your macro needs to be slowed down. You see, the GUI may need time to process your Down keystroke, but your OCR condition (perhaps) isn't waiting for the GUI to catch up. Therefore you should put a pause after the Down arrow, start with 1 second, to see if that's causing the problem. In other words, insert a "pause for 1 second" action after your down arrow. Once we determine if this is your problem or not, then we can reduce the pause time.

Fourth, your OCR code will take twice as long to execute the way you've written it, as it needs to be. Instead, you should do it this way, and it will take half as long. Apple's OCR is fast, but it's not instant.

Thanks Airy your suggestions worked in the end

1 Like