0

I try to define Win+1 to launch some application on Windows XP, but don't want such behavior on Win7+. How can I do that?

The following snippet will cause Windows 7 to show "Trigger on Win 5.x" box as well. What's going wrong?

#If, A_OSVersion in WIN_2003, WIN_XP, WIN_2000
#1::
    MsgBox Trigger on Win 5.x
return
#If

Autohotkey version 1.1.13.01

1

Update: #If [, Expression ] The operators "between", "is", "in", and "contains" are not supported in expressions.

I changed it to

#1::
If A_OSVersion in WIN_2003,WIN_XP,WIN_2000
    MsgBox Trigger on Win 5.x
return

NOTE: No spaces in WIN_2003,WIN_XP,WIN_2000

This shows no message box on Windows 7

  • Thanks, but sorry, still not what I expect, that will invalidate Win7's native Win+1 functionality. – Jimm Chen Jan 21 '15 at 5:10
  • You didn't mention this specific requirement! – AEonAX Jan 21 '15 at 8:39
1

I think I've figured it out. Autohotkey's #If doc presents examples that the condition can be a function, so the following code works:

IsWin5x()
{
    if A_OSVersion in WIN_2003,WIN_XP,WIN_2000
    {
        return 1
    }
    else
    {
        return 0
    }
}

#If IsWin5x()
#1::
    MsgBox Trigger on Win 5.x
return
#If

Win+1 works on WinXP and Win+1 preserves its original functionality on Win7.

  • Yes this will work. – AEonAX Jan 21 '15 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.