Sign in to follow this  
Followers 0
mxyzptlk

Your thoughts on omnipotence...

5 posts in this topic

Does anyone have any idea how to send commands to 2 or more instances of the same program when they both share the same window and process name? (eg. such as pausing tasks in several programs at once)

Thanks for any help.

Share this post


Link to post
Share on other sites



Does anyone have any idea how to send commands to 2 or more instances of the same program when they both share the same window and process name? (eg. such as pausing tasks in several programs at once)

Thanks for any help.

You can get window handles if your script is running as the windows are created(unless they are created simultaneously) other than that, find other ways to distinguish them.

Share this post


Link to post
Share on other sites

WinList() will create an array of the instances of matching windows, use the window handle from that. Or, if your script opened those other windows, then you can WinGetHandle() on each one as you create it.

:)


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

I was fearing arrays (I wanted to keep it relatively simple)...ahhhhhhh c'est la vie

But thank you for the help and suggestions.

Share this post


Link to post
Share on other sites

I was fearing arrays (I wanted to keep it relatively simple)...ahhhhhhh c'est la vie

But thank you for the help and suggestions.

Nothing complicated about arrays.

A one-dimension array is just a numbered list. Like you might write on a grocery list:

0. Apples
1. Oranges
2. Pears

Being a geek, of course, you number your list from zero. :P

In an array, that looks like this:

Dim $avFruit[3]
$avFruit[0] = "Apples"
$avFruit[1] = "Oranges"
$avFruit[2] = "Pears"oÝ÷ Øp¡Ø¦z{"¢v«­¬¢²;¬µªèÃ÷(駵¦åzX¤y«)­æ²¶ì¦í±º1±Ê+zÂâèÊ«ºz¼¥ËpjÆ¥Ûezj+y×­j)^w*.(!·
âµëaÇ(uákº+OiÉãn·«ezÀZS«jx°F£Þj»j}¿r^`Ú®¶²$²X¤zØb°uç@®¶²+)¬­¢ÈhÂ+m£*.jëh×6#include <array.au3>

Dim $avFruit[4][3] ; 4 rows, 3 columns
$avFruit[0][0] = "Fruit"
$avFruit[0][1] = "Package"
$avFruit[0][2] = "Number"
$avFruit[1][0] = "Apples"
$avFruit[1][1] = "Bag"
$avFruit[1][2] = 1
$avFruit[2][0] = "Oranges"
$avFruit[2][1] = "Each"
$avFruit[2][2] = 6
$avFruit[3][0] = "Pears"
$avFruit[3][1] = "Can"
$avFruit[3][2] = 2

_ArrayDisplay($avFruit, "2D Array: $avFruit")

You are still a geek, so you number the columns from zero too. :)

Now, in many arrays (not all) the programmer decides to use the first element [0] to contain the COUNT of how many other things are in the array. WinList() does this. So when you look at the array that WinList returns, you see the first element is [0][0] because it's a 2D array and that has the count. From the help file:

The array returned is two-dimensional and is made up as follows:

$array[0][0] = Number of windows returned

$array[1][0] = 1st window title

$array[1][1] = 1st window handle (HWND)

$array[2][0] = 2nd window title

$array[2][1] = 2nd window handle (HWND)

...

$array[n][0] = nth window title

$array[n][1] = nth window handle (HWND)

So there are as many rows, numbered from 1 since [0] has the count, as there are windows listed. Each row has two columns. The first is the title and the second is the handle. Your problem is the titles are the same, so column [0] is useless and you just use the handles in column [1]. If there are three of your windows present, then their handles are in $array[1][1], $array[2][1], and $array[3][1].

Assume the lotus position, and chant with me: "Arrays are our friends, arrays are our friends, arrays..."

:)


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