tim9525

Using IF statement to recognize filename

4 posts in this topic

Dear Members,

   I am trying to teach Autoit to recognize several features in the file names. I tried the following two different methods using IF.....Then statements. But, none of them work. Can anyone please help?

Tim

Method 1:

If StringInStr($filename1, "plus2" ) > 0 Then  ; check if the filename is right
   Elseif StringInStr($filename1, "212") > 0 Then
   Elseif StringInStr($filename1, "252") > 0 Then
   Sleep(300)
   WinActivate("EXCEL")
   WinWaitActive("EXCEL")

 

Method 2:

If StringInStr($filename1, "plus2" or "212" or "252") > 0 Then  ; check if the filename is right
   Sleep(300)
   WinActivate("EXCEL")
   WinWaitActive("EXCEL")

Share this post


Link to post
Share on other sites



I would try:

If StringInStr($filename1, "plus2" ) > 0 Or _
   StringInStr($filename1, "212") > 0 Or _
   StringInStr($filename1, "252") > 0 Then
       Sleep(300)
       WinActivate("EXCEL")
       WinWaitActive("EXCEL")
EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

BTW:
To work with Excel I suggest you try the Excel UDF that comes with AutoIt. Automating the GUI is always  a source of problems ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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