Rick,

I've mentioned vb.net isn't something I'm familiar with; but could you
explain to me: in sub New()  of class ScriptContext, you declare what looks
like a local variable  named instTester, then you assign two onKey handlers
to methods of the class you've made instTester.  It looks to me however like
this variable will then immediately go out of scope because it's declared
inside of sub New, and so the handlers won't function as handlers, or will
yield an error?

Chip


> -----Original Message-----
> From: RicksPlace [mailto:[email protected]] 
> Sent: Wednesday, June 20, 2012 9:43 AM
> To: [email protected]
> Subject: Re: Followup 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.GetCur
> rentProcess().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
> 

Reply via email to