'Autohotkey Multiple switch cases

How to make a different switches for checking. In this code i want to make switch check the wintitle variable and winclass variable at once, look at the row Switch (wintitle || winclass) This is the example:

WinGetTitle, wintitle, A
WinGetClass, winclass, A

Switch (wintitle || winclass)    ;;<<<<< Look at this row, How to set -
{                                           ;; - multiple variations for check ??
Case "Calculator":  ;;<< This is the %wintitle%
    WinActivate, %wintitle%
    send 5
    send {NumpadAdd}
    send 10
Case "ahk_class Notepad++":   ;;<<This shoud check %winclass% variable
    WinActivate, %winclass%
    send I am a bot
Default:
    msgbox,,, not found
}

Or i should write it as && ?? Like this: Switch (wintitle && winclass) Please explain the way how it does work



Solution 1:[1]

Switches are only for checking a single value, you can't check two values at once in them. For something more complex like this, you want to instead use if statements:

if (wintitle == "Calculator") {
    WinActivate, %wintitle%
    send 5
    send {NumpadAdd}
    send 10
} else if (winclass == "ahk_class Notepad++") {
    WinActivate, %winclass%
    send I am a bot
} else {
    msgbox,,, not found
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hovercouch