Sign in to follow this  
Followers 0
butlerjames

How to identify a window by its name?

3 posts in this topic

The application I'm using is kind of a browser. It gets data from a server and opens then a new window as tab in a main window. When I request another customer's data, it opens up another window as tab in the same main window; just like tabbed browsing in Firefox.

I need to copy the email address from a specific field from every of the tabbed windows and to paste it into the same tabbed window to another empty field; then that tabbed window should be closed and the next customer from the list in the main window will be selected and the same procedure as above should happen with that customer.

The main window has the name: abc - company - CRM.

One tabbed window which must be open in order to open all customers data windows has the name: Contacts without a login - company - CRM

All tabbed windows in that main window look like that: customer's name - company - CRM.

As it takes a while to transfer the data from the server, the tabbed window doesn't show the data unless it has received all data. This can take some seconds. Meanwhile the empty window will be displayed and it's name is then only company - CRM.

And this is the only common thing to all windows: company - CRM. No identical classes or something else. My idea was to wait for a window which has any other name than company - CRM and abc - company - CRM. Of course customers have different names and some even don't enter anything in the name field. At least I know the name of the tabbed window must be something with - company - CRM. But not Contacts without a login - company - CRM.

My idea:

If WinExists("[REGEXPTITLE:\D - company\D]") Then

If WinExists("[REGEXPTITLE:^(Contacts without a login)\D]") Then

MsgBox(0, "", "Window exists")

It fails as it seems not possible to match all EXCEPT Contacts without a login\D and that's my question: How could I get the title in order to go on with the script?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The application I'm using is kind of a browser. It gets data from a server and opens then a new window as tab in a main window. When I request another customer's data, it opens up another window as tab in the same main window; just like tabbed browsing in Firefox.

I need to copy the email address from a specific field from every of the tabbed windows and to paste it into the same tabbed window to another empty field; then that tabbed window should be closed and the next customer from the list in the main window will be selected and the same procedure as above should happen with that customer.

The main window has the name: abc - company - CRM.

One tabbed window which must be open in order to open all customers data windows has the name: Contacts without a login - company - CRM

All tabbed windows in that main window look like that: customer's name - company - CRM.

As it takes a while to transfer the data from the server, the tabbed window doesn't show the data unless it has received all data. This can take some seconds. Meanwhile the empty window will be displayed and it's name is then only company - CRM.

And this is the only common thing to all windows: company - CRM. No identical classes or something else. My idea was to wait for a window which has any other name than company - CRM and abc - company - CRM. Of course customers have different names and some even don't enter anything in the name field. At least I know the name of the tabbed window must be something with - company - CRM. But not Contacts without a login - company - CRM.

My idea:

If WinExists("[REGEXPTITLE:\D - company\D]") Then

If WinExists("[REGEXPTITLE:^(Contacts without a login)\D]") Then

MsgBox(0, "", "Window exists")

It fails as it seems not possible to match all EXCEPT Contacts without a login\D and that's my question: How could I get the title in order to go on with the script?

I think this expression

If WinExists("[REGEXPTITLE:\D - company\D]") Then

should be

If WinExists("[REGEXPTITLE:\D* - company\D*]") Then

otherwise it will only match titles which have one character before and one character after.

This one

If WinExists("[REGEXPTITLE:^(Contacts without a login)\D]") Then

I'm not sure what you want , but maybe you should have this instead

If Not WinExists("[REGEXPTITLE:.*Contacts without a login.*]") Then

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

The application I'm using is kind of a browser. It gets data from a server and opens then a new window as tab in a main window. When I request another customer's data, it opens up another window as tab in the same main window; just like tabbed browsing in Firefox.

I need to copy the email address from a specific field from every of the tabbed windows and to paste it into the same tabbed window to another empty field; then that tabbed window should be closed and the next customer from the list in the main window will be selected and the same procedure as above should happen with that customer.

The main window has the name: abc - company - CRM.

One tabbed window which must be open in order to open all customers data windows has the name: Contacts without a login - company - CRM

All tabbed windows in that main window look like that: customer's name - company - CRM.

As it takes a while to transfer the data from the server, the tabbed window doesn't show the data unless it has received all data. This can take some seconds. Meanwhile the empty window will be displayed and it's name is then only company - CRM.

And this is the only common thing to all windows: company - CRM. No identical classes or something else. My idea was to wait for a window which has any other name than company - CRM and abc - company - CRM. Of course customers have different names and some even don't enter anything in the name field. At least I know the name of the tabbed window must be something with - company - CRM. But not Contacts without a login - company - CRM.

My idea:

If WinExists("[REGEXPTITLE:\D - company\D]") Then

If WinExists("[REGEXPTITLE:^(Contacts without a login)\D]") Then

MsgBox(0, "", "Window exists")

It fails as it seems not possible to match all EXCEPT Contacts without a login\D and that's my question: How could I get the title in order to go on with the script?

I was not able to extract a usable selection criteria from your description. But you don't have to get it in a single line with REGEXPTITLE, though that may be possible. You could do WinList() and then walk the array doing ordinary string manipulation or whatever it takes to pick out the ones you want.
Opt("WinTitleMatchMode", 2)

$avWinList = WinList("company")
For $n = 1 To $avWinList[0][0]
    $sTitle = $avWinList[$n][0]
    If StringInStr($sTitle, "Look for something") Then
    ; Further processing
    EndIf
Next

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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
Sign in to follow this  
Followers 0