mercredi 28 décembre 2016

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 ouput variable is found to be invalid a MsgBox pops up to inform the user and then the script loops back around to the begginning 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

Aucun commentaire:

Enregistrer un commentaire