dougc39
dougc39

Reputation: 13

Autohotkey / pulovers macro creator inputbox loop error

First post here on stack overflow, I've been using the forums and lurking for a while but decided to sign up as my job now involves a lot more scripting.

So I'm using Pulover's Macro Creator to build an autohotkey script and I can't get my head around a problem with the InputBox command.

The purpose of the script is to error check user input, comparing the output variable to a set of 4 predetermined values. If the output variable is found to be invalid a MsgBox pops up to inform the user and then the script loops back around to the beginning so that they can try again.

The issue I'm having is that the script hangs on the InputBox command, but only after it has looped back to the start after an invalid string was detected by the if switch.

e.g.

InputBox - user inputs invalid variable

MsgBox appears

Script restarts

InputBox - user inputs VALID variable

Script hangs


Here is my code:

F8::

/*
This script asks for user input and keeps looping until the input matches the predefined valid strings.
*/

Loop
{

    InputBox, price_type, title, text, , , , , , , , RRP ; Get user input for "price_type" variable

    Sleep, 5

    StringUpper, price_type, price_type ; convert variable to uppercase to allow error checking

    Sleep, 5

    If price_type not in RRP,SALE,OFFERING,WAS ; check variable for invalid strings

        {
        MsgBox, 16, Invalid Input, Invalid Input message ; warn user that input is invalid
    }

Until, %price_type% in RRP,SALE,OFFERING,WAS ; infinite loop until variable matches valid input options
}

I have a suspicion the problem is to do with the way pulover's macro creator formats the ahk script but I'm all out of ideas!

Any help would be greatly appreciated.

Many thanks Doug

Upvotes: 1

Views: 2109

Answers (1)

Jim U
Jim U

Reputation: 3366

The UNTIL clause only accepts conditions that autohotkey considers expressions. IFIN is a command and not an autohotkey expression. From the documentation for IFIN:

The operators "between", "is", "in", and "contains" are not supported in expressions.

Your code works if we refactor out the WHILE clause with it's invalid IN operator:

Loop
{
  InputBox, price_type, title, text, , , , , , , , RRP

  StringUpper, price_type, price_type

  If price_type in RRP,SALE,OFFERING,WAS
    break

  MsgBox, 16, Invalid Input, Invalid Input message
}

Upvotes: 0

Related Questions