Jump to content

Need some help!


Recommended Posts

How could I find the title of a window for witch I olny know the name of the process?

for example I whant to find the title of the window opened by "process.exe" and then, after finding the title, I whant to make it visible/invisible

I have tried:

$a= ProcessList("iexplore.exe")
$PID = $a[1][1]
$Ferestre = WinList()
For $i = 1 To UBound($Ferestre) - 1
    If $Ferestre[$i][0] <> "" Then
        MsgBox(0,$PID&" - "&WinGetProcess($Ferestre[$i][0]),$Ferestre[$i][0])
        If $PID = WinGetProcess($Ferestre[$i][0]) Then
        ;If $Ferestre[$i][0] <> "" Then WinSetState($Ferestre[$i][1], "", @SW_SHOW)
        EndIf
    EndIf
Next

It does not work because when $PID = WinGetProcess($Ferestre[$i][0]) it will find more than one window with the same PID, but none of those is the one I am looking for...

Is ther another way, or am I doing something rong?

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

How could I find the title of a window for witch I olny know the name of the process?

for example I whant to find the title of the window opened by "process.exe" and then, after finding the title, I whant to make it visible/invisible

I have tried:

$a= ProcessList("iexplore.exe")
$PID = $a[1][1]
$Ferestre = WinList()
For $i = 1 To UBound($Ferestre) - 1
    If $Ferestre[$i][0] <> "" Then
        MsgBox(0,$PID&" - "&WinGetProcess($Ferestre[$i][0]),$Ferestre[$i][0])
        If $PID = WinGetProcess($Ferestre[$i][0]) Then
    ;If $Ferestre[$i][0] <> "" Then WinSetState($Ferestre[$i][1], "", @SW_SHOW)
        EndIf
    EndIf
Next

It does not work because when $PID = WinGetProcess($Ferestre[$i][0]) it will find more than one window with the same PID, but none of those is the one I am looking for...

Is ther another way, or am I doing something rong?

Did you check $PID to see if you are getting the right value? Use _ArrayDisplay() to show you the results of WinList() in $Ferestre, and examine the actual window with AU3Info.exe at the same time to see if there are any matching handles. Eventually, you'll find where you are not getting a match.

:mellow:

P.S. Note that it is possible for one process to have multiple windows, and if the target window has a null title, your script won't find 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
Link to comment
Share on other sites

well, some windows have the same title,

i.e - Firefox is always "Title of webiste" - Mozilla Firefox

so you can use WinTitleMatchMode and then winsetstate("- Mozilla Firefox",@SW_hide)

BUT---

If you are doing this with INternet explorer, You can use the IE functions to make it visible

_iecreate()

code
Link to comment
Share on other sites

Did you check $PID to see if you are getting the right value? Use _ArrayDisplay() to show you the results of WinList() in $Ferestre, and examine the actual window with AU3Info.exe at the same time to see if there are any matching handles. Eventually, you'll find where you are not getting a match.

:mellow:

P.S. Note that it is possible for one process to have multiple windows, and if the target window has a null title, your script won't find it.

Actualy I have used _ArrayDisplay(), but the problem is when the window I am looking for is initialy hiden and it does not have a null title.

using WinList() I can find the hiden window I am looking for, and also a title....it would be very easy if I vere using for example the StringRegExp function to search for the title in the results of the WinList() function and then get the handle, but I want this script to be able to find any window title, just by knowing the process name.

open the Internet explorer and run this script:

#include <Array.au3>
Dim $Mem[1][4]
$a= ProcessList("iexplore.exe")
$PID = $a[1][1]
$Mem[0][0]= $PID
$Ferestre = WinList()
_ArrayDisplay($Ferestre)
For $i = 1 To UBound($Ferestre) - 1
    If $Ferestre[$i][0] <> "" Then
        MsgBox(0,$PID&" - "&WinGetProcess($Ferestre[$i][0]),$Ferestre[$i][0])
        If $PID = WinGetProcess($Ferestre[$i][0]) Then
            ReDim $Mem[UBound($Mem)+1][4]
            $Mem[UBound($Mem)-1][1]=$Ferestre[$i][0]
            $Mem[UBound($Mem)-1][2]=$Ferestre[$i][1]
            $Mem[UBound($Mem)-1][3]=WinGetProcess($Ferestre[$i][0])
        ;If $Ferestre[$i][0] <> "" Then WinSetState($Ferestre[$i][1], "", @SW_SHOW)
        EndIf
    EndIf
Next
_ArrayDisplay($Mem)

WinGetProcess($Ferestre[$i][0]) returs a PID that is different from the PID returned by the ProcessList() function....even though the $Ferestre[$i][0] var has the title of the window I am searching for...

so...what should I do?

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Actualy I have used _ArrayDisplay(), but the problem is when the window I am looking for is initialy hiden and it does not have a null title.

using WinList() I can find the hiden window I am looking for, and also a title....it would be very easy if I vere using for example the StringRegExp function to search for the title in the results of the WinList() function and then get the handle, but I want this script to be able to find any window title, just by knowing the process name.

open the Internet explorer and run this script:

#include <Array.au3>
Dim $Mem[1][4]
$a= ProcessList("iexplore.exe")
$PID = $a[1][1]
$Mem[0][0]= $PID
$Ferestre = WinList()
_ArrayDisplay($Ferestre)
For $i = 1 To UBound($Ferestre) - 1
    If $Ferestre[$i][0] <> "" Then
        MsgBox(0,$PID&" - "&WinGetProcess($Ferestre[$i][0]),$Ferestre[$i][0])
        If $PID = WinGetProcess($Ferestre[$i][0]) Then
            ReDim $Mem[UBound($Mem)+1][4]
            $Mem[UBound($Mem)-1][1]=$Ferestre[$i][0]
            $Mem[UBound($Mem)-1][2]=$Ferestre[$i][1]
            $Mem[UBound($Mem)-1][3]=WinGetProcess($Ferestre[$i][0])
    ;If $Ferestre[$i][0] <> "" Then WinSetState($Ferestre[$i][1], "", @SW_SHOW)
        EndIf
    EndIf
Next
_ArrayDisplay($Mem)

WinGetProcess($Ferestre[$i][0]) returs a PID that is different from the PID returned by the ProcessList() function....even though the $Ferestre[$i][0] var has the title of the window I am searching for...

so...what should I do?

Either you are looking at the wrong window, or it was launched by a different (perhaps child) process. You could use something like _ProcessListProperties() to get the PPID (parent PID) of the window's process to see if that matches.

:mellow:

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

Either you are looking at the wrong window, or it was launched by a different (perhaps child) process. You could use something like _ProcessListProperties() to get the PPID (parent PID) of the window's process to see if that matches.

:mellow:

I already did that...it is the same with the one from ProcessList()

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

I already did that...it is the same with the one from ProcessList()

If there is more than one similar window, then there may be more than one similar process. Why do you automatically use $a[1][1] without checking if there are more matching PIDs?

:mellow:

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