I guarantee that line would of generated an error. However, without
seeing your entire script I can't tell why you didn't see it. Perhaps
you were using the on error or some issue with using the toolkit's error
reporting. But again, I only saw a small snippet.
Doug
On 1/30/2012 12:48 PM, David wrote:
Thing is, there was no error. If there had been, I would of course
have included it in my initial message. All I got, was that the
desired window did not get activated and focused. No error, no other
message. That's why I was so puzzled.
----- Original Message -----
*From:* Doug Geoffray <mailto:[email protected]>
*To:* [email protected] <mailto:[email protected]>
*Sent:* Monday, January 30, 2012 6:39 PM
*Subject:* Re: Activating a window - help needed
David,
Since the line you had would of generated an error and a line
number, it would be helpful to let us know the exact error and
line of code. That saves us from having to think of all the
possible problems that a script could have and focus on the real
problem at hand.
Doug
On 1/30/2012 12:34 PM, David wrote:
Thanks Doug. The Desktop command was the problem. I changed it to
DesktopWindow, and everything worked right away. Got me a couple
of steps further in the development. Thanks again.
----- Original Message -----
*From:* Doug Geoffray <mailto:[email protected]>
*To:* [email protected] <mailto:[email protected]>
*Sent:* Monday, January 30, 2012 3:06 PM
*Subject:* Re: Activating a window - help needed
David,
Along with Aaron's comment, it would be nice to know exactly
the problem you are getting. Are you getting a script
error? Is the window just not getting activated and/or
focused? Are you sure the overlap of the window you have can
be activated?
I did see in your code you have:
Set FWin = Desktop.Children.Find( WinHandle )
This should of failed because Desktop is not a property of
Application. I'm sure you meant:
Set FWin = DesktopWindow.Children.Find( WinHandle )
So you should of gotten an error on that line. Something
like "Object required: 'desktop'"
But just to show what you are trying is possible, I launched
Notepad, brought up immed and typed the following 2 lines
(The second line is really 2 lines of VBScript but I needed
the activate and focus to be on the same line):
Set myWindow =
DesktopWindow.Children.FilterByClassAndModule("edit",
"notepad")(1)
myWindow.Overlap.Activate : myWindow.Focus
I purposefully looked for the edit box of Notepad. After
finding that window I activated its overlap and than focused
the edit itself. This worked perfectly.
Doug
On 1/29/2012 7:22 PM, David wrote:
I am attempting to write a small app, that has a feature of
""Switching" to a given window that is already open on my
computer. Let's just for the example say, that I have a
Notepad window open on my system. My app scrolls through all
the Children windows of the desktop, and finds the one for
Notepad. I then let it derive the handle for that window. So
far, the app works just fine.
The problem arises when I try to Activate, and Focus the
newly found Window. I have been looking on a couple of other
apps, that I thought could have lead me in right direction,
but without any luck (they simply got too complicated for my
brain). Then also, I have been spending a couple of hours
with that App developers Reference under the Help menu in
WE. Still I don't grasp why my app won't switch to the found
window.
Here is the troublesome code, that I cannot get to work.
What am I doing wrong? Maybe I am totally astray here?
Thanks for your feedback:
Dim WinHandle
' My app search for the window I want, and fills in this
variable with the Window Handle, just fine. I won't copy
that few lines here.
' Then comes the section I apparently have got wrong:
Sleep 2000 'Just tried to give the app enough time here.
dim FWin: Set FWin = Desktop.Children.Find( WinHandle )
' This line, I thought, would find the correct window, and
make it ready for activation.
FWin.Overlap.Activate
' To Activate the Window, or it's Overlap.
FWin.Focus
' I had hoped, this would have focused me on the actual
window. But such is not the case.
Sleep 1000
' A last sleep command, just to let things settle.
End of code snip