Chip: OK, when I fired up the WeEvent module and then fired up CSharp, and 
subsequently my VB.net script automatically, the bloody thing did the following 
indicating that the WatchEvent is working but not as I expected. 
First I started WEEvent to capture all the events for later review.
Next I started CSharp application so I could trace the sequence of events 
firing during the Initialization process ( the SetUp sub) where I set up the 
variables including the WatchEvent variable.
Instead of having the CSharp application fire up as usual I heard the OnFocus 
event fire over and over the string I had it say from inside the OnFocus event. 
That means that while in WEEvent and watching the CSharp Application under 
Windoweyes, that the OnFocus and WatchEvent are working but not when I just 
start CSharp without first starting WEEvent!
That leads me twoard your initial idea about the ApplicationProcess I am 
useing. I have to leave for the Hospital pretty soon but will follow up this 
line of research later and report back either way.
So, it appears the WatchEvent and the Sub I use to handle the OnFocus event are 
working in some process or thread, I just have to figure out which one and how 
to use it correctly. That is unless the process is working in the WEEvent 
application procesws somehow but still not working in the CSharp model if that 
makes sense....
Later and I can't thank you enough for your insightful help.
Rick USA
  ----- Original Message ----- 
  From: RicksPlace 
  To: gw-scripting@gwmicro.com 
  Sent: Friday, April 01, 2011 6:37 AM
  Subject: Re: Need Help With MSAAEventSource Problem In External Script


  Hay Chip: I missed this the first read but I will try WEEvent. In fact if I 
enable pretty much everything there should be some mention of the WatchEvent 
having fired if it is infact working. Thanks, thanks --- I was running out of 
things to try except for perhaps trying to learn how to read a dump and I don't 
think that's in the cards at this point.
  I'll try that WeEvent to see what comes up when I fire that puppy up... 
Thanks again for a real-world thing to try...
  Rick USA
    ----- Original Message ----- 
    From: Chip Orange 
    To: gw-scripting@gwmicro.com 
    Sent: Thursday, March 31, 2011 6:01 PM
    Subject: RE: Need Help With MSAAEventSource Problem In External Script


    Rick,

    it sounds like you're doing a great job, and just running into normal 
development problems that we all hit.

    if you don't want to try WEEvent, you could write this in VBScript just to 
see if you're even getting the MSAA info you think you are.  WEEvent would have 
just done this for you and logged it into a test file, but they're otherwise 
the same approach.

    once you know you are getting the MSAA info, then it becomes a question of 
something specific to an external script; but you don't want to spend all your 
time toing down that road if you aren't even getting the MSAA info.

    If you're not getting it, could you use the window onObjectFocus event 
instead?  maybe not if you want to block WE's behavior, but I'm not sure 
exactly why you're doing this, so it's just another route you could possibly 
take if you had to.

    hth,

    Chip




----------------------------------------------------------------------------
    From: RicksPlace [mailto:ofbgm...@mi.rr.com] 
    Sent: Thursday, March 31, 2011 6:27 AM
    To: gw-scripting@gwmicro.com
    Subject: Re: Need Help With MSAAEventSource Problem In External Script


    Hi Chip: I haven't tried using any tools yetother than the speak command 
and logging logic flow and the contents of variables to a text file for 
analyysis. I will give that some thought to try and figure out a plan using one 
of the tools which I downloaded yesterday in preparation for your next classes. 
I think I have the BlockEvent working in my VB.net script since when I bring up 
the CSharp Application the cursor nor tab keys seem to work as they did before 
I added the BlockEvent. I still can't seem to get the bloody Watch statement to 
work or I can't get the MSAAEventSource to trigger the on focus event to fire 
the event handler sub. I will play with it some more today along with my 
VBScript  I am now going through line by line based on the WEFramework. I am 
starting to get it. The Dictionary Objects to handle strings, the Help Dialog 
that comes up under the ScriptManager - not the one that comes up if something 
goes wrong during the running of the script I think, and I am starting to look 
into the ToolKit Shared Objects a little.I know that the MSAA stuff works fine 
in VBS since I used it to do a little scripting for VWD a few years ago.The 
reason I am folling around with VB.net is that it has access to all the .net 
framework which is a massive repository of powerfull tools involving everything 
from Database and other file construction, access and binding to Strongly Typed 
objects and killer UI setups using properties rather than xml layouts. Also, if 
it works in Vb.net it will likely work in Visual Web Developer which opens some 
interesting ideas about scripting during website processing or even website 
creation. It is just something GW has touted for many years but never had a 
real world example of. Their sample has a couple of things that give a good 
idea of how to try and handle things but they did not even associate their 
sample with an application so it is not as relevant   as it should have been as 
an example of an external script. For example, with no example of using the 
native VB.net controls, no MSAA Event Processing and not any other Application 
Specific hooks the sample is pretty much devoid of the hooks necessary to 
create a real script that works to expose an Applications more inaccessible 
objects. So, unless they tested external scripts beyond the samples they posted 
the ground is soft in my opinion and I am never quite sure if I am doing 
something wrong or if there is another problem with the external scripting 
package itself. If I get this puppy working I might post it up as a real-world 
sample of an external script in VB.net 2008 but that is a big if for now. Sorry 
this is so long but I managed a major headache last night after tearing my 
vb.net script apart and rebuilding it in several diferent configurations to try 
and get, and verify, the ProcessId, the BlockEvent and still, when it gets to 
the WatchEvent it just won't fire that blasted handler. So, it's another day - 
more vBScript and VB.net with trying out the new tools I downloaded thanks to 
your wiki.
    Later and thanks for all your help and your classes:
    Rick USA
      ----- Original Message ----- 
      From: Chip Orange 
      To: gw-scripting@gwmicro.com 
      Sent: Wednesday, March 30, 2011 9:19 PM
      Subject: RE: Need Help With MSAAEventSource Problem In External Script


      Hi Rick,

      have you used WEEvent to log the MSAA events to make sure onObjectFocus 
is getting called?

      I've never used this event, I've used the onObjectFocus for the window 
object, but maybe this isn't generating MSAA events for some reason?  WEEvent 
would tell you anyway.

      hth,

      Chip





--------------------------------------------------------------------------
      From: RicksPlace [mailto:ofbgm...@mi.rr.com] 
      Sent: Tuesday, March 29, 2011 7:00 PM
      To: gw-scripting@gwmicro.com
      Subject: Need Help With MSAAEventSource Problem In External Script


      Hi: I have a VB.net script working until I try and use the 
MSAAEventSource. 
      I had some hot keys code which I removed for clarity which are working. 
      I handled the MSAAEventSource the same way that the ClientInformation 
object was handled unless I missed something. 
      Everything other than the MSAAEventSource code seems to work fine. 
      Below is the code for trying to handle the MSAAEventSource and 
ClientInformation objects. 
      I pulled the ClientInformation code pretty much directly from the GW 
VB.net sample script.
      I am getting no errors or warnings but the 
      Private Shared Sub OnObjectFocus( Acc As WindowEyes.Accessible ) _
      Handles MSAAEventSource.OnObjectFocus
      Subroutine does not seem to be getting executed when I navigate around 
the associated application (CSharp Express 2008). 
      Can you spot anything I might be doing wrong in handling the 
MSAAEventSource to try and capture the OnObjectFocus event?

      BeginCopiedCode:
      Imports System.Diagnostics
      Imports System.Runtime.InteropServices
      Imports Windoweyes
      ' Note, outer class to hold required "Global" variables and start message 
pump.
      Public Class AppContext
      Inherits ApplicationContext
      Private Shared app As WindowEyes.Application
      Private Shared WithEvents clientInformation As 
WindowEyes.ClientInformation
      Private Shared WithEvents MSAAEventSource As WindowEyes.MSAAEventSource
      Private Shared Speech As WindowEyes.Speech
      Public Sub New()
      MyBase.New()
      SetUp.SetUp()
      End Sub
      Private Shared Sub OnObjectFocus( Acc As WindowEyes.Accessible ) _
      Handles MSAAEventSource.OnObjectFocus
      Speech.Speak( "Focus Set")
      Logger.WriteLine( "Should Have Spoken in OnObjectFocus sub" )
      Speech.Speak( "Focus Set")
      End Sub
      Private Shared Sub clientInformation_OnShutdown() Handles 
clientInformation.OnShutdown
      System.Windows.Forms.Application.Exit()
      End Sub
      ' The below is a nested class using outer class variables.
      Public Class SetUp
      Public Shared Sub SetUp()
      app = New WindowEyes.Application()
      Speech = app.Speech
      app.ClientIdentify(System.Diagnostics.Process.GetCurrentProcess().Id)
                  clientInformation = app.ClientInformation
      clientInformation.ScriptName = "RicksWEComScript"
      clientInformation.ScriptDescription = "This is my test script." 
      clientInformation.ScriptHelp = "This is a help string in ClientInfo."
      MSAAEventSource= app.MSAAEventSource 
      Dim event_OBJECT_FOCUS As Long = &H8005
      MSAAEventSource.WatchEvent( event_OBJECT_FOCUS )
      End Sub
      End Class
      End Class
      EndCopiedCode:
      Note that some of the lines wrapped in this e-mail but are clean in the 
code editor.

      I hope you can help as things look correct - at least as far as I 
understand them so far but they just dont work to capture the OnObjectFocus 
event. 
      Thanks:
      Rick USA

Reply via email to