failedtocompile Posted July 6, 2009 Posted July 6, 2009 (edited) Hello Guys I'm new to Autoit I was wondering if there is a way to have multiple "If" statements grouped together. Or is there a cleaner and or simpler way using $var = $ProcessName1|$ProcessName2|$ProcessName3 If you could enlighten me in the right terminology that would be great e.g. (code below doesn't work with having multiple if statements within my script) $ProcessName1 = "" $ProcessName2 = "" $ProcessName3 = "" Case $Btn_1 If ProcessExists($ProcessName1) Then MsgBox(0, "?? is Running", $ProcessName1 & " etc......") Else If ProcessExists($ProcessName2) then MsgBox(0, "?? is Running", $ProcessName2 & " etc......") Else If ProcessExists($ProcessName3) then MsgBox(0, "?? is Running", $ProcessName3 & " etc......") Else Runwait() EndIf Case $btn_2 If ProcessExists($ProcessName1) Then MsgBox(0, "?? is Running", $ProcessName1 & " etc......") Else If ProcessExists($ProcessName2) then MsgBox(0, "?? is Running", $ProcessName2 & " etc......") Else If ProcessExists($ProcessName3) then MsgBox(0, "?? is Running", $ProcessName3 & " etc......") Else Runwait() EndIf Thanks in advance Edited July 6, 2009 by failedtocompile
Andreik Posted July 6, 2009 Posted July 6, 2009 The correct syntax is: If ..... Then .... ElseIf..... Then ..... Else ..... EndIf On your code: If ProcessExists($ProcessName1) Then MsgBox(0, "?? is Running", $ProcessName1 & " etc......") ElseIf ProcessExists($ProcessName2) then MsgBox(0, "?? is Running", $ProcessName2 & " etc......") ElseIf ProcessExists($ProcessName3) then MsgBox(0, "?? is Running", $ProcessName3 & " etc......") Else Runwait() EndIf
failedtocompile Posted July 8, 2009 Author Posted July 8, 2009 The correct syntax is: If ..... Then .... ElseIf..... Then ..... Else ..... EndIf On your code: If ProcessExists($ProcessName1) Then MsgBox(0, "?? is Running", $ProcessName1 & " etc......") ElseIf ProcessExists($ProcessName2) then MsgBox(0, "?? is Running", $ProcessName2 & " etc......") ElseIf ProcessExists($ProcessName3) then MsgBox(0, "?? is Running", $ProcessName3 & " etc......") Else Runwait() EndIf Awesome thanks very much Andreik this has worked
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now