Jump to content

I have a Case question


dew
 Share

Recommended Posts

I am using Select (Case) based on the window dialog title (below). This is for testing various Windows applications (below is just a brief description).

What I would like to know is, can "Case" be an "or" as well. I would like to use this in other Windows systems under different languages.

So as an example: Using Accessibility Wizard the title in other language would be something like:

Case $shWndFocus= "Accessibility Wizard" or "language2" or "language3" or ... (language2 lets say is French for "Accessibility Wizard")

If this is not possible, is there any other way of doing this and not make the script into a monster?

Select

Case $shWndFocus = "Accessibility Wizard" ;Accessibility Wizard

MouseClick("left", 365, 360) ;click next

Sleep(2000)

MouseClick("left", 455, 360) ;click cancel

Case $shWndFocus = "calculator" ;Calculator

Sleep(3000)

WinClose($shWndFocus) ;close application

Case $shWndFocus = "untitled - Paint" ;MS Paint

Sleep(3000)

WinClose($shWndFocus) ;close application

EndSelect

Link to comment
Share on other sites

Help file says

Select statements may be nested.

The expression can contain the boolean operators of AND, OR, and NOT as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.

However you might want to do something like this instead:

Global $aAW = StringSplit("Accessibility Wizard|language2|language3")

Select
Case _ArraySearch($aAW,$shWndFocus)<>-1
[ other code here... ]
Edited by this
UDFsWinSineInOutResize () - Resize a window smoothly based on a sine curve.
Link to comment
Share on other sites

Maybe...

Switch $shWndFocus
    Case "Accessibility Wizard", "Accessibility Wizard2" ; example
        MouseClick("left", 365, 360) ;click next
        Sleep(2000)
        MouseClick("left", 455, 360) ;click cancel

    Case "calculator" ;Calculator
        Sleep(3000)
        WinClose($shWndFocus) ;close application

    Case "untitled - Paint" ;MS Paint
        Sleep(3000)
        WinClose($shWndFocus) ;close application

EndSwitch

; my previous use in autoit error reporting

Case "_GUIToolTip_EnumTools", "_GUIToolTip_GetCurrentTool", "_GUIToolTip_GetToolInfo", "_GUIToolTip_HitTest", "_GUIToolTip_ToolToArray"

http: / / www.autoitscript.com / forum / index.php?autocom = downloads & showfile = 104

8)

NEWHeader1.png

Link to comment
Share on other sites

Of course you can use logical operators there.

Using your example, it is correct to write:

Case $shWndFocus = "calculator" Or $shWndFocus = "untitled - Paint"
    Sleep(3000)
    WinClose($shWndFocus);close application

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Take the one you like.

;include library
#Include <Array.au3>

;global definition
Global $aAW = StringSplit("a|b|c","|")

; input
$sOneLetter = InputBox("input", "Type letter a , b or c")

;output 1
Select 
    Case $sOneLetter = "a" or $sOneLetter = "b" or $sOneLetter = "c"
        MsgBox(64,"output 1", "The letter was " & $sOneLetter)
    Case Else
        MsgBox(64, "output 1", "The letter was NOT a , b or c")
EndSelect

;output 2
Select
    Case _ArraySearch($aAW,$sOneLetter) <> -1
        MsgBox(64,"output 2", "The letter was " & $sOneLetter)
    Case Else
        MsgBox(64, "output 2", "The letter was NOT a , b or c")
EndSelect

;output 3
Switch $sOneLetter
    Case "a", "b", "c"
        MsgBox(64,"output 3", "The letter was " & $sOneLetter)
    Case Else
        MsgBox(64, "output 3", "The letter was NOT a , b or c")
EndSwitch

;output 4
Switch $sOneLetter
    Case "a" To "c"
        MsgBox(64,"output 4", "The letter was " & $sOneLetter)
    Case Else
        MsgBox(64, "output 4", "The letter was NOT a , b or c")
EndSwitch

[list][font="Century Gothic"]If nothing is certain, everything is possible.[/font][/list][font="Century Gothic"]Experience is something you get, just after you need it.[/font]

Link to comment
Share on other sites

Of course you can use logical operators there.

Using your example, it is correct to write:

Case $shWndFocus = "calculator" Or $shWndFocus = "untitled - Paint"
    Sleep(3000)
    WinClose($shWndFocus);close application
Thanks, I like your answer for it is just what I needed.

And No you are not kidding :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...