Jump to content

Differentiating same name windows/programs


Recommended Posts

I started with autoit awhile back, and up to now, have been able to find everything I've needed fairly easily. Unfortunately, i recently ran into a slight roadblock.

I started using Autoit to automate actions in a running window... Easy. I then used Autoit to automate tasks in different windows, by switching to them by name... Easy. Now, I wish to Automate an action in 1 window, then switch to another of the same name and perform an action.

I have a bad habit of making difficult to understand explanations, so I'll use an example.

Lets say I'm running two instances of ABC.exe, and they both show as "ABC-Program" in the task manager. I use autoit to type a sentence (or do whatever) in the first, but i can not switch to the second instance of ABC to do an action because it has the same name as the first.

So, is there any way around this, or am i destined to alt+tab the rest of my life?

Thank you.

Link to comment
Share on other sites

I started with autoit awhile back, and up to now, have been able to find everything I've needed fairly easily. Unfortunately, i recently ran into a slight roadblock.

I started using Autoit to automate actions in a running window... Easy. I then used Autoit to automate tasks in different windows, by switching to them by name... Easy. Now, I wish to Automate an action in 1 window, then switch to another of the same name and perform an action.

I have a bad habit of making difficult to understand explanations, so I'll use an example.

Lets say I'm running two instances of ABC.exe, and they both show as "ABC-Program" in the task manager. I use autoit to type a sentence (or do whatever) in the first, but i can not switch to the second instance of ABC to do an action because it has the same name as the first.

So, is there any way around this, or am i destined to alt+tab the rest of my life?

Thank you.

Use a handle instead... WinList() will list the titles and handles or WinGetHandle() of course some manipulation is needed if you cant figure anything back just mention it and Ill see if I can get an ok model of it

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Link to comment
Share on other sites

Use a handle instead... WinList() will list the titles and handles or WinGetHandle() of course some manipulation is needed if you cant figure anything back just mention it and Ill see if I can get an ok model of it

Thanks for the direction. I'm reading about those now, but if you happen to have a model handy, that would be great as well.

Link to comment
Share on other sites

The helpfile provides a good model of using the function WinList(). One thing you can do, once you have the handles of the windows you want to interact with, is use WinActive($wHndl) to find out which of those windows is the currently active one. Maybe an example would better express what I am trying to say.

Lets say that $wHndl is an array which contains the handles of both of the windows (remembering that both windows have the same title). The handles are unique, so we know that $wHndl[0] refers to only one of those windows, while $wHndl[1] refers to the other. To figure out which is which, lets find out which is the active window by doing something like this

for $i = 0 to 1
if WinActive($wHndl[$i]) then $WA=$i
next

Then $wHndl[$WA] will be the handle to the active window. There are many other ways of doing this, but hopefully this will get you going in the right direction.

Of course, this example assumes that one of the windows is active in the first place.

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...