Sign in to follow this  
Followers 0
dew

I have a Case question

8 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

You guys are kidding right?? :)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

You guys are kidding right?? :)

8)

which one? Because I'm not kidding.


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 :)

Share this post


Link to post
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 :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0