• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

ACTIVATE doesn't find windows

Apr 13, 2010
212
2
57
The Hague
#1
After starting a process I would like to change the window title to contain a process number.

START "Job starting ..." /PGM "%_CMDSPEC" /C etc<ETC>

and then

ACTIVATE "Job*" MIN "Job - %_STARTPID"

Returns the error message: Window title not found "Job*"
and of course the job window is not minimized.

What am I doing wrong?

DJ
 
#2
----- Original Message -----
From: "djspits" <>
Subject: [Support-t-2004] ACTIVATE doesn't find windows



> After starting a process I would like to change the window title to
> contain a process number.
>
> START "Job starting ..." /PGM "%_CMDSPEC" /C <etc>
>
> and then
>
> ACTIVATE "Job*" MIN "Job - %_STARTPID"
>
> Returns the error message: Window title not found "Job*"
> and of course the job window is not minimized.
>
> What am I doing wrong?
In help topic activate.htm you find this warning:

"Each execution of ACTIVATE allows you to modify one property of the target
window. To perform multiple operations, use multiple ACTIVATE commands."

You tried to do two actions: 1/ window size change and 2/ title change...
--
HTH, Steve
 
Apr 13, 2010
212
2
57
The Hague
#3
Thanks for the reply, Steve.

You're quite right and I removed the MIN.
But still no luck.
I've tried everything I can think of.

Here's my code again

Code:
START "Starting" /PGM "%_CMDSPEC" /IS /IX /IP /C "[EMAIL="%@UNQUOTE"]%@UNQUOTE[/EMAIL][%executable]"
SET new_title=Executing %_STARTPID
ACTIVATE "Starting" "%new_title"
UNSET new_title
ECHO Started: %executable as %_STARTPID
DELAY 3
The delay is there because I also read in the helptext that the lifespan of
a new title is limitted to the lifespan of the changing batch? Is that correct?

Looking forward to your comment.

DJ
 
#4
TCC changes its own title almost immediately after startup.

On Mon, 31 May 2010 11:37:56 -0400, djspits <> wrote:

|Thanks for the reply, Steve.
|
|You're quite right and I removed the MIN.
|But still no luck.
|I've tried everything I can think of.
|
|Here's my code again
|
|
|Code:
|---------
|
|START "Starting" /PGM "%_CMDSPEC" /IS /IX /IP /C "%@UNQUOTE[%executable]"
|SET new_title=Executing %_STARTPID
|ACTIVATE "Starting" "%new_title"
|UNSET new_title
|ECHO Started: %executable as %_STARTPID
|DELAY 3
|---------
|
|The delay is there because I also read in the helptext that the lifespan of
|a new title is limitted to the lifespan of the changing batch? Is that correct?
|
|Looking forward to your comment.
|
|DJ
|
|
|
|
--
- Vince
 
#5
----- Original Message -----
From: "djspits" <>
To: <[email protected]>
Sent: 2010. May 31., Monday 11.37
Subject: RE: [Support-t-2004] Re: ACTIVATE doesn't find windows


| Thanks for the reply, Steve.
|
| You're quite right and I removed the MIN.
| But still no luck.
| I've tried everything I can think of.
|
| Here's my code again
|
|
| Code:
| ---------
|
| START "Starting" /PGM "%_CMDSPEC" /IS /IX /IP /C "%@UNQUOTE[%executable]"
| SET new_title=Executing %_STARTPID
| ACTIVATE "Starting" "%new_title"
| UNSET new_title
| ECHO Started: %executable as %_STARTPID
| DELAY 3
| ---------
|
| The delay is there because I also read in the helptext that the lifespan
of
| a new title is limitted to the lifespan of the changing batch? Is that
correct?

As Vince wrote, UNLESS you use directive UpdateTitle=No (one of the entries
in the Startup page of the OPTION dialog) the title will change rapdily,
ACTIVATE may not find it. However, its TCSTART file can issue a TITLE
command to set its own title to include its PID (and you must skip /IS
option; more below).

Vince's plugin sysutils.dll includes the WHICHWIN command, which (among
other things) can return the current title of a window when you have its
PID. You can use that to determine the title needed in the ACTIVATE command
if you do not want to use TCSTART.

Note that the suboptions of the /I option MUST be combined into a single
option, i.e., /IIPSX, not spread out as 3 separate arguments.

Last but not least: why do you need a spearate instance of TCC at all just
to run another program? It could be started directly with the START command.
--
HTH, Steve
 
Apr 13, 2010
212
2
57
The Hague
#6
Steve,

I'm using START "%_cmdspec" because I'm running a batch. (Sorry about the misleading envar "executable").

OPTON UpdateTitle was already off but I added the explicit change just to put your mind at rest.

I changed the /I syntax. Thank you. Please add that to the helptext topic "TCC Startup Options".

I didn't understand Vince' remarks. Which window is changed by TCC immediately after startup?

However, it did make me wonder if perhaps the opposite was true. Namely that I was trying to catch a window that hasn't had it's default TCC title changed yet by START.

The following code now works.

Code:
OPTION //UpdateTitle=No
 
START "Job starting..." /PGM "%_CMDSPEC" /IPSX /C "%@UNQUOTE[%executable]"
DELAY 1
ACTIVATE "Job starting*" "Executing job %_STARTPID"
 
ECHO Started: %executable as %_STARTPID
I have two closing questions left:
1) Is the OPTION really necessary?
2) How would you implement a loop that waits for the window to become visible before using ACTIVATE to rename it? The DELAY seems a brittle solution.

Thx, DJ
 
#7
----- Original Message -----
From: "djspits" <>
| I didn't understand Vince' remarks. Which window is changed by TCC
immediately after startup?

If the directive UpdateTitle is set to YES in TCC, it changes its own title
to match the command it currently executes by appending it to the original
title, and dropping ot when the command is completed. With your options
(i.e., ignore all startup controls, use parent's options) the time between
creating a new instance and executing the first command (which with the /C
option is the only command) is minimal.
|
| However, it did make me wonder if perhaps the opposite was true. Namely
that I was trying to catch a window that hasn't had it's default TCC title
changed yet by START.
|
| The following code now works.
|
|
| Code:
| ---------
|
| OPTION //UpdateTitle=No
|
| START "Job starting..." /PGM "%_CMDSPEC" /IPSX /C "%@UNQUOTE[%executable]"
| DELAY 1
| ACTIVATE "Job starting*" "Executing job %_STARTPID"
|
| ECHO Started: %executable as %_STARTPID
| ---------
|
| I have two closing questions left:
| 1) Is the OPTION really necessary?

I think not, because the (temporary) changes are appended to the title, so
the wildcard in the searched after title in ACTIVATE will find it anyway.
Furthermore, you can put the option into the START command itself, so your
interactive session can continue updating its own title:

START "Job starting..." /PGM "%_CMDSPEC" /IPSX //UpdateTitle=No /C
"%@UNQUOTE[%executable]"

| 2) How would you implement a loop that waits for the window to become
visible before using ACTIVATE to rename it? The DELAY seems a brittle
solution.

For that very reason at my request Vince added the WAITWIN command to his
sysutils.dll plugin. You can use that command instead. If you loaded the
plugin, use its SYSHELP command for more details.
--
HTH, Steve
 
#8
On Wed, 02 Jun 2010 08:46:53 -0400, Steve Fábián <> wrote:

|| 2) How would you implement a loop that waits for the window to become
|visible before using ACTIVATE to rename it? The DELAY seems a brittle
|solution.
|
|For that very reason at my request Vince added the WAITWIN command to his
|sysutils.dll plugin. You can use that command instead. If you loaded the
|plugin, use its SYSHELP command for more details.

At some level TCC has to do nothing for a while. WAITWIN does this.

while ( (nReturn = WaitForMultipleObjects(3, EventHandles, FALSE, 20)) =WAIT_TIMEOUT )
{
Sleep(20);
tty_yield(0);
}

That probably isn't very different from

DO WHILE NOT ISWINDOW "title"
DELAY /M 20
REM timeout mechanism
ENDDO
--
- Vince
 
Top Bottom