Martin,

It doesn't matter how many windows are in the system. The event will only fire when activation changes. You can verify this by speaking something in your OnChildActivate callback. It doesn't fire 452 times, it only fires when activation changes. Meaning a new window has come to the foreground. So if you alt-tab to Notepad, it will fire once. Ifyou bring up the print dialog in Notepad, it will fire once. These fire because of a new active window. But as you type in Notepad or tab around the print dialog there is no activation change and therefore your event won't fire.

I really don't know what you are trying to do but remember, whatever window you put in the ConnectEvent, ONLY children of that window that get activation will fire. So as long as you put a parent or grandparent or great great grandparent or on and on, you'll get the event for your window. But if you don't put in a window who ultimately is a child of the window you pass in, you won't get the event.

Doug

On 2/2/2012 2:01 PM, martin webster wrote:
Hi Doug,
Yes, the OnChildActivate catches my window, so thanks for the information. Just 
one question about setting the OnChildActivate to the DeskTopWindow, Isn't this 
all so CPU intensive. as the last time I checked there were 452 windows 
reported in the count. The below snippet from Immed reported a count of 452.

Begin VBScript
Set d = DeskTopWindow.Children
Print D.Count
452

Warm regards.
Martin Webster.


--- On Wed, 2/1/12, Doug Geoffray<[email protected]>  wrote:

From: Doug Geoffray<[email protected]>
Subject: Re: differences in window count when using startTimer
To: [email protected]
Date: Wednesday, February 1, 2012, 6:03 PM
Martin,

The window you pass into ConnectEvent tells window-Eyes you
want only
children of that window that get activation to fire the
event.  You just
got whatever window was active at the moment and used
it.  Very likely
there is no child window of that window that ever gets
activation.

You should do the following:

Dim OnChildWindowEvent
OnChildWindowEvent = ConnectEvent(DesktopWindow,
"onChildActivate",
"OnChildActivate")
Function OnChildActivate(WinObj)
Speak "child window activated"
End Function

This passes in the DesktopWindow which is the top most
window.  All
windows are children of the desktop so you'll get them all
now.

Doug


On 2/1/2012 12:53 PM, martin webster wrote:
Hi Doug,
Thanks for your reply, but how do I use the
OnChildActivate event. Blow I have written a global routine
which should hook the activate window of any ap running and
tell me if a child window gains activation, but it doesn't
seem to work. What have I got wrong.
Begin VBScript:

Dim OnChildWindowEvent, WinObj
Set WinObj = ActiveWindow
OnChildWindowEvent = ConnectEvent(WinObj,
"onChildActivate", "OnChildActivate")
Function OnChildActivate(WinObj)
Speak "child window activated"
End Function

Warm regards.
Martin Webster.


--- On Tue, 1/31/12, Doug Geoffray<[email protected]>
wrote:
From: Doug Geoffray<[email protected]>
Subject: Re: differences in window count when using
startTimer
To: [email protected]
Date: Tuesday, January 31, 2012, 2:41 PM
Martin,

I would say that both methods are working as
designed.
In your first case you have a dedicated thread that
looks at
the active window every 200 milliseconds.  In
the
second case you have setup a callback to occur
every 200
milliseconds.  So you might ask isn't that the
same
<smile>?  Well, in theory maybe so but
not in
practice.  Again, in the first case you have
not given
up control of your thread.  It just waits 200
ms and
goes on.  In the second case, you have given
up control
of your thread and setup a timer callback.
Timers have
a very low priority.  The only thing with a
timer that
you are guaranteed is that it will not fire before
your
timeout value.  But because it is low on the
totem pole
(so to speak) it lets things with higher priority
execute
first and when there is nothing better, than it
will fire
your callback.  So one time it may be 230 ms
than maybe
400 ms and so on.

I'm not totally sure I see what you are trying to
do but I
would argue that neither approach is good.
You
shouldn't be polling over and over for what the
active
window is.  For one thing, you could easily
miss a
window that got activation and it just eats
unneeded cpu
from your system.  What you should do is use
the
OnChildActive callback.  If you set this up
whenever
the active window changes, Window-Eyes will call
your
function for you.  This means you don't have
to sit in
some loop checking and you are guaranteed you'll
see every
active window when and only when it changes.

Doug

On 1/31/2012 5:09 AM, martin webster wrote:
Hi all,
I use the following vbscript routine to make
windo-eyes
wait until the correct window is active, before
setting an
object reference to my window of choice. I wrote
the first
routine rapidly using do until loop and sleep
commands and
this never fails. However, thinking that using the
StartTimer object would be a much better aproach I
rewrote
the routine to use this object, and now instead of
30
children in the active window I now have three, or
sometimes
4. I have to write such a routine as if this
software is not
registered you get a trial days counter window and
options
to purchase the software. this is not the same
window as I
am wanting to script for. I am scripting for
baygenie pro
auction sniping software.
Now follows the first routine and the one that
works:
Begin VBScript

Function ChecWindow()
Dim CheckWinObj
Set CheckWinObj = ActiveWindow
Do Until(Left(CheckWinObj.Title, 32)) =
"BayGenie eBay
Auction Sniper Pro"
Sleep 200
Set CheckWinObj = ActiveWindow
Loop
Set CheckWinObj = Nothing
ActiveWindow.Redraw
Sleep 200
Speak "loop ended"
End Function

Out put:

children count 30
1 tooltips_class32
2 IME
3 ReBarWindow32
4 AfxMDIFrame70u
5 msctls_statusbar32
6 MSCTFIME UI
7 ToolbarWindow32
8 #32770
9 AfxMDIFrame70u
10 AfxFrameOrView70u
11 Button
12 Static
13 Static
14 SysTreeView32
15 #32770
16 ReBarWindow32
17 AfxFrameOrView70u
18 MFCGridCtrl
19 ToolbarWindow32
20 #32770
21 Shell Embedding
22 Button
23 Edit
24 Button
25 ComboBox
26 Button
27 Static
28 Static
29 Shell DocObject View
30 Internet Explorer_Server
This is correct.
Now for the second routine written with the
StartTimer
object.
Begin VBScript

Function ChecWindow()
Dim CheckWinObj
Set CheckWinObj = ActiveWindow
If(Left(CheckWinObj.Title, 32)) = "BayGenie
eBay
Auction Sniper Pro" Then
Speak "timer ended"
Set CheckWinObj = Nothing
ActiveWindow.Redraw
Sleep 200
Else
StartTimer 200, "ChecWindow"
end If
End Function

Output
children 4
1 Static
2 Shell Embedding
3 Shell DocObject View
4 Internet Explorer_Server

I don't understand.
Warm regards.
Martin Webster.



Reply via email to