 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
scouchman
Joined: 28 Apr 2004 Posts: 44
|
Posted: Sun Aug 15, 2004 7:18 pm Post subject: IfInString or IfEqual and ignoring type of character |
|
|
So, I have two program windows open (two versions, same title, format of the page is a little different) and I want to determine which version of the program I am currently in. I have a decent script that does do it, but was wondering if there was a better way to deterimine based on the formatting.
In this case, I found that box "Edit20" in one version is different than "Edit20 in the other. And in one version, it always has the same info: the date and time in the following format: 08/15/2004 12:11:00. The other Edit20 can contain anything. So, the script I have that works pretty good is the following:
| Code: | #z:: ; VersionTest:
Test =
Integer = 0
ControlGetText, Test, Edit20, A
Loop, 10 ; Removes all the numbers
{
StringReplace, Test, Test, %Integer%, , A
EnvAdd, Integer, 1
}
IfEqual, Test, // `:`:
MsgBox, Test says you're in Version 1
Else
MsgBox, Test says you're in Version 2 |
Would there be a way to do something like:
| Code: | | IfEqual, Test, ??/??/?? ??:??:?? |
where the question marks would be a character to ignore.
While in my example case here, it wouldn't be much of an enhancement, but I could see something like this used for more complex situations, like taking out something from a long string with not an exact phrase, but the same format. _________________ Scott F Couchman |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Sun Aug 15, 2004 8:01 pm Post subject: |
|
|
Generally, you can use StringGetPos to do more flexible string searching. In v1.0.09+, it has this additional feature: "to find a match other than the first, specify the letter L or R followed by the number of the occurrence. For example, to find the fourth occurrence from the right, specify r4."
There is also an item on the to-do list to support regular expressions with StringGetPos, which are a lot more powerful than wildcards (though harder to learn).
In your particular example, you could use StringGetPos or StringSplit to count how many slashes are present in a string. For example:
StringSplit, MyArray, Test, /
if MyArray0 = 3 ; Since there are 3 fields, there must be 2 slashes.
... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|