Using an If to check that a string contains a certain substring


#1

I’m new to Kantu and one of the things I’m trying to do with my first macro is click a certain area of the screen based on some text that is already there. I’ve stored the string in a variable (Description) and I now want to check it for a substring using an if statement. I’ve been trying several different ways to use a contains function, but I’m apparently failing to hit the right syntax.

So, what should my condition (Target:) be for the if statement if I want it to evaluate true when the variable includes the number 110?


#2

Here is a code snippet to check that a string contains a certain substring. I copied the code from the DemoPDFTest_with_OCR macro that ships with Kantu.

{
      "Command": "storeEval",
      "Target": "var string = \"${q}\", substring = \"110\";  b= string.includes(substring); b;",
      "Value": "textfound"
    },

#3

Thank you! I went through several of the demos, but I don’t think I went through that one. I appreciate the help!