Hi Rick,
I will send you something directly to let you try it.
Bruce
Sent: Wednesday, June 20, 2012 9:42 AM
Subject: Re: Follow-up Threads WE, ExternalScript and vb.net 2010 Express
Hi Guys:
I stripped out everything from error handling to the streamwriter log file
and a few other objects and methods used for support and other operations.
Here is the barebones logic I use to implement the Keyboard.OnKeyDown and
Keyboard.OnKeyUp events as described in the WE Docs.
If you see something wrong with the way I am handling the delegation of the
Events or how I set up the return values of the Handler functions
(OnKeyDownHandler and OnKeyUpHandler) let me know or let me know if you
think of anything to try diferently.
If you want the project I will attach it to a message but it is created in
vb.net 2008 and it requires both vb.net 2008 Express and vb.net 2010 express
to test.
Public Module LaunchApp
' All variables in module are global
Public myKeyboard As WindowEyes.Keyboard
Public weApplication As WindowEyes.Application
Public WithEvents weClientInformation As WindowEyes.ClientInformation
Public Sub Main()
Application.Run(New ScriptContext)
End Sub
End Module
Public Class ScriptContext
Inherits ApplicationContext
Public Sub New()
Dim instTester As New Tester()
weApplication = New WindowEyes.Application
weApplication.ClientIdentify(System.Diagnostics.Process.GetCurrentProcess().Id)
weClientInformation = weApplication.ClientInformation
AddHandler weClientInformation.OnShutdown, AddressOf
weClientInformation_OnShutdown
myKeyBoard = weApplication.KeyBoard
AddHandler myKeyboard.OnKeyDown, AddressOf instTester.OnKeyDownHandler
AddHandler myKeyboard.OnKeyUp, AddressOf instTester.OnKeyUpHandler
End Sub
Public Sub weClientInformation_OnShutdown()
Dim instTester As New Tester
RemoveHandler myKeyboard.OnKeyDown, AddressOf instTester.OnKeyDownHandler
RemoveHandler myKeyboard.OnKeyUp, AddressOf instTester.OnKeyUpHandler
Application.Exit()
System.Environment.Exit(0)
End Sub
End Class
Public Class Tester
Public Function OnKeyDownHandler( _
ByVal ReturnedKey As Integer, ByVal ReturnedModifiers As
WindowEyes.KeyModifiers) _
As WindowEyes.KeyDisposition
Dim AppropriateDisposition As WindowEyes.KeyDisposition
AppropriateDisposition = WindowEyes.KeyDisposition.kdProcess
Return AppropriateDisposition
End Function
Public Function OnKeyUpHandler( _
ByVal ReturnedKey As Integer, ByVal ReturnedModifiers As
WindowEyes.KeyModifiers) _
As WindowEyes.KeyDisposition
Dim AppropriateDisposition As WindowEyes.KeyDisposition
AppropriateDisposition = WindowEyes.KeyDisposition.kdProcess
Return AppropriateDisposition
End Function
End Class