Jump to content

Advanced Window Descriptions


Jon
 Share

Recommended Posts

  • Administrators

We are struggling to come up with a "fix" to the advanced window descriptions (in particular with RegExps) that we can all agree on. Ideas so far are:

- Extra quoting characters

- Having it so that TITLE or REGEXPTITLE must go last and then assume it can be read without regard to special chars

- Having PROPERTY: and PROPERTY= mean different things

Suggestions on the best way to fix this would be appreciated.

Link to comment
Share on other sites

  • Administrators

If the problem is with RegExp, you could add a specific format for that.

An expression between slashes like Javascript has: /[Aa]uto[ii]t3/

And using it in for instance WinExists: If WinExists(/[Aa]uto[ii]t3/) Then WinFlash("[LAST]")

We still need to support all the class and instance stuff at the same time though. Eg. the 3rd instance of a particular regexp.

I wonder if I can do away with the doubling of chars by just scanning the line more carefully. Instead of looking for a ; to end the current property I could look for ; followed by whitespace followed by another valid property. That way the only title that I wouldn't be able to use would be something like"[TITLE:SomeTitle; INSTANCE:2]". Hmm.

Link to comment
Share on other sites

  • Administrators

A hypothetical title of [TITLE:title; INSTANCE:1] would give trouble

At the moment we have to double up the special chars:

"[TITLE:[[TITLE::title;; INSTANCE::1]]; INSTANCE:1]"

JP had a suggestion of having to use quotes:

"[TITLE:'[TITLE:title; INSTANCE:1]'; INSTANCE:1]"

or

'[TITLE:"[TITLE:title; INSTANCE:1]"; INSTANCE:1]'

But then you still have the nightmare of having to escape or double ' or "

Maybe a perl/java type use of / (are these used often in Regexp?)

"[TITLE:/[TITLE:title; INSTANCE:1]/; INSTANCE:1]"

I guess if literal / is required it needs to be doubled.

Nightmare.

Link to comment
Share on other sites

I don't know how flexable you want to be with your redesign, but maybe reworking the way advance modes in general... Somthing like-

Remove mode 4. Make autoit macros for LAST and ACTIVE or use "" and/or -1. Some way to allow StringRegExp() directly into Win() functions (or maybe a specialized version of RegExp designed only for use in Win functions)

I just dont see an easy way to implament all the functionality there now AND RegExp but still use the same way of setting the mode. (at least short of putting in special work arounds like are proposed now)

nightmare agreed...

Link to comment
Share on other sites

The instance seems less important. We can put that one last, behind the other properties.

What I was thinking; Don't put too many characters in the properties.

Like the colon, semi-colon and the mandatory last bracket inline.

Suggestions:

- An array to have the options (eg. instance, future options?) seperate from the CLASS/TITLE/REGEXP

Which also gives you the ability to store, reuse the array and update the option/instance.

- Property name at the beginning eg. [CLASS] ARandomClassname

Examples:

['[TITLE] Thunderbird', 3]
['[CLASS] MozillaUIWindowClass', 1]
['[REGEXP] [Tt]hunder[Bb]ird', 2]
;//   OR
[/[Tt]hunder[Bb]ird/, 2]

;// Combination
['[TITLE] Thunderbird', '[CLASS] MozillaUIWindowClass', 1]

If WinExists(['[TITLE] Thunderbird']) Then WinActivate('[LAST]')

And for compatibility allow string input. It's faster too.

Edited by SlimShady
Link to comment
Share on other sites

In fact Jon didn't mention another thing

to avoid string protection inside string protection I suggest also to us = instead of : for the last property hopping we don't need to have 2 properties with []:; inside.

so the "Advanced Window descriptions" can be:

[property1:value1; property2:value2; ... ; lastproperty=anystring]

valuei is anything between the : and ; including blank but no ; nor ].

Link to comment
Share on other sites

  • Moderators

$sString = "[:property1::value1:;:property2::value2:;:lastproperty::anyvalue:]"
$aProps = StringRegExp($sString, "(?m:\[:|;:)(.*?):", 3)
$aVals = StringRegExp($sString, "::(.*?):", 3)
I would think the above to solve most of the issues I see ya'll discussing here, as well as try to avoid some of the more common patterns as slimshady was pointing out with his example.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...