Sign in to follow this  
Followers 0
Delta01

Choosing an instance - Multiple processes

11 posts in this topic

Hi,

My problem is that I can't get my script to separate two windows with the same name and process name. Eg, I have 2 Firefox's open, I need to send different commands to each without renaming the window.

Is there anyway I can do that? Get a PID on start up or something?

Thanks

Share this post


Link to post
Share on other sites



Hi,

My problem is that I can't get my script to separate two windows with the same name and process name. Eg, I have 2 Firefox's open, I need to send different commands to each without renaming the window.

Is there anyway I can do that? Get a PID on start up or something?

Thanks

Use WinList() or WinGetHandle() and work with the handles. They remain unique and specific.

<_<


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

Use WinList() or WinGetHandle() and work with the handles. They remain unique and specific.

<_<

I looked them both up, I can get WinGetHandle to work after a bit of fiddling, but WinList confuses me.

I looked it up and the help file code is

$var = WinList()

For $i = 1 to $var[0][0]
 ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
    MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
  EndIf
Next

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

It gets all visable windows, but, is there a way I can get it to just get a window with a certain name, not all visable ones. Eg, FireFox

Share this post


Link to post
Share on other sites

$List = WinList()

$Program = "FireFox"

For $i = 1 to $List[0][0]
; Only display visble windows that have a title
  If $List[$i][0] <> ""  AND StringInStr($List[$i][0], $Program)Then
    MsgBox(0, "Details", "Title=" & $List[$i][0] & @LF & "Handle=" & $List[$i][1])
  EndIf
Next

Is this what you wanted?


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

It gets all visable windows, but, is there a way I can get it to just get a window with a certain name, not all visable ones. Eg, FireFox

This should list only instances of Firefox. It uses the Window class to find it, and the array lists the titles and handles:

#include <array.au3>
$avFirefoxes = WinList("[CLASS:MozillaUIWindowClass]")
_ArrayDisplay($avFirefoxes, "Firefox Windows")

<_<


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

=). Learn something new everyday. Never would have thought of that sadly.


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

Thanks for your help, got it working great now!

Share this post


Link to post
Share on other sites

$List = WinList()

$Program = "FireFox"

For $i = 1 to $List[0][0]
; Only display visble windows that have a title
  If $List[$i][0] <> ""  AND StringInStr($List[$i][0], $Program)Then
    MsgBox(0, "Details", "Title=" & $List[$i][0] & @LF & "Handle=" & $List[$i][1])
  EndIf
Next

Is this what you wanted?

This does not retrieve only the visible windows as suggested by the comment... you do know that right?

BitAnd(WinGetState($List[$i]), 2) << is missing.


[center]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.[/center]

Share this post


Link to post
Share on other sites

This does not retrieve only the visible windows as suggested by the comment... you do know that right?

BitAnd(WinGetState($List[$i]), 2) << is missing.

If you were only right there my friend.

"but, is there a way I can get it to just get a window with a certain name, not all visable ones. Eg, FireFox"

"NOT ALL VISABLE ONES"


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites

Perhaps you meant "Not only just the visible ones"


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

If you were only right there my friend.

"but, is there a way I can get it to just get a window with a certain name, not all visable ones. Eg, FireFox"

"NOT ALL VISABLE ONES"

You added a little ebonics in there that completely threw me off.

WinList("Name Of Window") is what I'm going to assume you are saying.


[center]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.[/center]

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