leuce Posted April 6, 2011 Share Posted April 6, 2011 G'day everyone I'm using a script to compare a line of text in some program with a line of text in a text file. If the two lines of text aren't the same, then the script replaces the text in that program with the line from the text file. Unfortunately it now appears that AutoIt doesn't do the comparison case-sensitively. It regards "FOO" as being equal to "foo" or "Foo", which is very bad for my purpose. Here is the script: expandcollapse popupGlobal $alldone Global $changeddone Global $filereadline #include <File.au3> #cs A more advanced version of the script that compares what is currently in the segment with what is to be pasted, and if it is the same, then it doesn't paste (thereby not affecting the segment status). #ce HotKeySet ("{ESC}", "TheEnd") While 1 $fileopen = FileOpen ("idiotica.txt", 128) $filecountlines = _FileCountLines ("idiotica.txt") MsgBox (0, "Click in Idiom!", "Click with your mouse in the first line in Idiom... you have 5 seconds!", 5) Sleep ("5000") ; so actually you have 10 seconds... WinWaitActive ("Idiom WorldServer", "") $alldone = 0 $changeddone = 0 For $i = 1 to $filecountlines WinWaitActive ("Idiom WorldServer", "") $filereadline = FileReadLine ("idiotica.txt", $i) Send ("^a") Sleep ("100") Send ("^c") Sleep ("100") $existingtext = ClipGet() Sleep ("100") If $existingtext = $filereadline Then Send ("{DOWN}") ElseIf $existingtext <> $filereadline Then ClipPut ($filereadline) Sleep ("100") Send ("^a") Sleep ("100") Send ("^v") Sleep ("100") Send ("{DOWN}") Sleep ("100") $changeddone = $changeddone + 1 Else MsgBox (0, "Comparison failed", "Comparison failed", 0) Exit EndIf $alldone = $alldone + 1 Next MsgBox (0, "Done!", "Did " & $alldone & " segments, of which " & $changeddone & " changed.", 10) Exit WEnd Func TheEnd() MsgBox (0, "Done!", "Did " & $alldone & " segments, of which " & $changeddone & " changed.", 10) Exit EndFunc How can I ensure that the comparison is case-sensitive? Thanks Samuel Link to comment Share on other sites More sharing options...
water Posted April 6, 2011 Share Posted April 6, 2011 Try this: If "Foo" = "foo" Then msgBox(0,"","equal") Else msgBox(0,"","not equal") Endif If "Foo" == "foo" Then msgBox(0,"","equal") Else msgBox(0,"","not equal") Endif My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 6, 2011 Share Posted April 6, 2011 Also see Language Reference - Operators in the helpfile. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
leuce Posted April 6, 2011 Author Share Posted April 6, 2011 Try this: If "Foo" = "foo" Then msgBox(0,"","equal") Else msgBox(0,"","not equal") Endif If "Foo" == "foo" Then msgBox(0,"","equal") Else msgBox(0,"","not equal") Endif Thanks to both repliers -- the combination of the two replies gave me my answer. Thanks Samuel Link to comment Share on other sites More sharing options...
saywell Posted April 6, 2011 Share Posted April 6, 2011 Or you could use StringCompare with flag 1. William Link to comment Share on other sites More sharing options...
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