Hi Guys: I tried Ron's work-around and got mixed results which were not seemingly consistent from test to test. So I decided to do a couple of bare bones tests and document the sstructured results along with providing the simple block of code I used.. Let me know if the code looks correct according to the proposed work around. Here is what I did and the test results of 2 tests: I stripped everything not directly related to my problem from my VB.net Script project. I moved the Logger Utility class into the VB.net Script's Main Module for clarity. I verified all aspects of the vb.net script implementation as follows: In the bin folder in theDebug SubFolder I verified the requisit DLL entries: Scripting.dll windoweyes.dll I verified them in the References Folder: Scripting System ... windoweyes So they are loaded and referenced. They appear in the VB.net Object Browser as expected. The code for my Module: BeginCopiedCode: Imports System.Diagnostics Imports System.Runtime.InteropServices Imports System.Configuration Imports System.IO
Public Module LaunchApp Private MyApp As WindowEyes.Application Private MyMSAAEventSourceWithoutEvents As WindowEyes.MSAAEventSource Private WithEvents MyMSAAEventSource As WindowEyes.MSAAEventSource Public WithEvents MyClientInformation As WindowEyes.ClientInformation Public Speech As WindowEyes.Speech Private start_time As DateTime Private stop_time As DateTime Private elapsed_time As TimeSpan Public Sub Main() start_time = Now Try MyApp = CreateObject("WindowEyes.Application") Logger.WriteLine( "MyApp created ok") Catch ex As Exception Logger.WriteLine( "Error Creating MyApp from WindowEyes.Application: " & VbCrlf & ex.ToString()) End Try Speech = MyApp.Speech Try MyApp.ClientIdentify(System.Diagnostics.Process.GetCurrentProcess().Id ) MyClientInformation = MyApp.ClientInformation MyClientInformation.ScriptName = "RicksWEComScript" MyClientInformation.ScriptDescription = "This is my test script for the vb.net interface" MyClientInformation.ScriptHelp = "This is a help string in ClientInfo." Logger.WriteLine( "ClientInformation Initialized OK") Catch ex As Exception Logger.WriteLine( "ProblemInitializing ClientInformation in MainSub: " & VbCrlf & ex.ToString()) End Try Try MyMSAAEventSourceWithoutEvents = MyApp.MSAAEventSource ' MyMSAAEventSourceWithoutEvents.Process = MyClientInformation.ApplicationProcess MyMSAAEventSourceWithoutEvents.WatchEvent(WindowEyes.MSAAEventID.event_OBJECT_FOCUS) MyMSAAEventSource = MyMSAAEventSourceWithoutEvents Logger.WriteLine( "MyMSAAEventSource Initialized OK") Catch ex As Exception Logger.WriteLine( "Error initializing MSAAEventSource: " & VbCrlf & ex.ToString()) End Try Application.Run(New AppContext) End Sub Private Sub MyMSAAEventSource_OnObjectFocus( AccObj As WindowEyes.Accessible ) _ Handles MyMSAAEventSource.OnObjectFocus If AccObj Is Nothing Then Logger.WriteLine( "Hit: AccObj was nothing in sub") Speech.Speak( "Focus AccObj Is Nothing") Else Logger.WriteLine( "Hit: AccObj.Title: " & AccObj.Title) Speech.Speak( "Hit: AccObj.Title: " & AccObj.Title) End If stop_time = Now elapsed_time = stop_time.Subtract(start_time) Logger.WriteLine( "ElapsedTime To Firings: " & elapsed_time.TotalSeconds.ToString("0.000000") & " Seconds") End Sub Private Sub clientInformation_OnShutdown() _ Handles MyClientInformation.OnShutdown Speech.Speak( "Shutting Down Now, ByeBye") Logger.WriteLine( "Shutting Down Now") Application.Exit() End Sub Public Class AppContext Inherits ApplicationContext Public Sub New() MyBase.New() End Sub End Class Public Class Logger Public Shared Sub WriteLine( ByVal Line As String ) Try Dim LoggerPath As String = _ "C:\DOCUME~1\Rick\MYDOCU~1\VISUAL~1\Projects\RtWECom1\Log.txt" File.AppendAllText( LoggerPath, Line ) File.AppendAllText( LoggerPath, vbCrLf ) Catch ex As Exception MessageBox.Show( "Exception in logger, " & ex.ToString() ) End Try End Sub End Class End Module EndCopiedCode: Test01: To Test the above senario: I UnLoaded my VBScript for Chip's class so it wouldn't interfear with my testing of my Vb.net Script. I ReBooted to make sure everything was clean and ran a test: I opened CSharp Express 2008, the associated Application to my VB.net script: I cursored up and down a ListBox on the Start Page with 6 items, tabbed around a dialog with about 6 items. I then opened the Menu Bar and cursored to and clicked on Create New Project. The OnFocus event did not fire until the Create New Project Dialog came up. >From then on it seemed to continue to fire on focus changes. I Then closed everything up and exited the CSharp Express Application. Here is the log output: BeginCopiedOutput: MyApp created ok ClientInformation Initialized OK MyMSAAEventSource Initialized OK Hit: AccObj was nothing in sub ElapsedTime To Firings: 39.328125 Hit: AccObj was nothing in sub ElapsedTime To Firings: 39.343750 Hit: AccObj was nothing in sub ElapsedTime To Firings: 39.359375 Hit: AccObj was nothing in sub ElapsedTime To Firings: 39.359375 Hit: AccObj was nothing in sub ElapsedTime To Firings: 39.359375 Hit: AccObj was nothing in sub ElapsedTime To Firings: 39.375000 Hit: AccObj was nothing in sub ElapsedTime To Firings: 55.625000 Hit: AccObj was nothing in sub ElapsedTime To Firings: 74.218750 Shutting Down Now EndCopiedOutput: Test02: I repeated the above test: Again the OnFocus event did not fire on the Start Page no matter how I navigated around it. I then hit alt, opened the Menu Bar: right Cursored to the Tools Menu: Cursored up to the Options Item and hit enter on it. As soon as the Options Window Came up the OnFocus Event started firing again as in test01. It continued to fire until I closed CSharp Express 2008. Here is the copied output: BeginCopiedOutput: MyApp created ok ClientInformation Initialized OK MyMSAAEventSource Initialized OK Hit: AccObj was nothing in sub ElapsedTime To Firings: 65.078125 Hit: AccObj was nothing in sub ElapsedTime To Firings: 65.078125 Hit: AccObj was nothing in sub ElapsedTime To Firings: 65.093750 Hit: AccObj was nothing in sub ElapsedTime To Firings: 65.093750 Hit: AccObj was nothing in sub ElapsedTime To Firings: 65.109375 Hit: AccObj was nothing in sub ElapsedTime To Firings: 80.859375 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.062500 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.062500 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.078125 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.078125 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.093750 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.093750 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.093750 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.109375 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.109375 Hit: AccObj was nothing in sub ElapsedTime To Firings: 85.125000 Hit: AccObj was nothing in sub ElapsedTime To Firings: 86.843750 Hit: AccObj was nothing in sub ElapsedTime To Firings: 86.859375 Shutting Down Now EndCopiedOutput: OK, so the only thing I can note is that my app needed a second window, the Create New Project dialog in the first test and the Options Window in the second test, before the OnFocus event started firing. Second, in neither case did I get an Accessible Object provided to my OnFocus handler sub indicating something is still not working. Well, this is the end of this test session... If you see something I am doing wrong let me know. If not, perhaps it will help you if you work on this sample. Good luck guys and let me know if anything comes up that I might be able to help with. Rick USA