Hi Aaron:
Maximize the post so it doesnt wrap so badly or I can send this and future 
posts as a txt file attachment going forward if you want.
This is my first test so I included everything so you know pretty much what is 
going on.
It seems bloody long but in subsequent tests I will trim all communications 
down to what ever level you want and perform 
whatever tests you require.
The direct code related to the Keyboard events is only a few lines long and is 
what I will change for future tests so later posts can be much, much  shorter.
For Quick Search:
<BeginBackground><EndBackground>
<BeginCode><EndCode>
<BeginWEEvent><EndWEEvent>
<BeginScriptLog><EndScriptLog>

<BeginBackground>
Originally I wanted to trap whenever a user hit a navigation or action key 
combination while working in vb.net 2010 Express.
If the Focused object was Off Screen I wanted to block WE Speech and, if an 
action key, block the KeyStroke from getting to 
vb.net 2010.
If the focused object was on screen I just wanted windoweyes to speak normally 
and pass the keystroke through to vb.net 2010 
express for normal processing.
I have tried several approaches but not yet been able to get this to work.
This is the first ReTesting of prior tests and I am just using vb.net 
AddHandler statements to delegate any vb.net 2010 
express UI Keyboard Events to  fire the OnKeyDown and OnKeyUp event handler 
functions in my script.
To try and do this in this test I used the 
WindowEyes.KeyDisposition.kdProcess
enum against the Keyboard's OnKeyUp and OnKeyDown events.
I hope I have used them correctly.

For this test I just want to:
1)  see both the OnKeyDown and OnKeyUp event  Functions in my script fire;
2) hear WindowEyes read me the vb.net 2010 UI controls as I tab to them;
3) Have keys like enter or alt+f4 or other action keys perform their actions 
within vb.net 2010.
None of the above things happen when my script is running and I have the 
Keyboard Object's OnKeyDown and OnKeyUp Event 
handlers defined.
When my script is disabled or I comment out the Keyboard Object's code for the 
OnKeyDown and OnKeyUp event handlers 
WindowEyes reads the UI Controls and hitting action keys like enter or alt+F4 
work properly while working in vb.net 2010.

For this test I used the below steps:
1) I fire up WEEvent and disable logging, open vb.net 2010 and enable WEEvent 
logging.
2) in vb.net 2010 I tab 3 times, hit enter once, hit alt+f4 to try and close 
vb.net 2010 (It wont close since it looks like 
none of the keystrokes are getting passed to vb.net 2010) and there is no 
WindowEyes speech coming from vb.net 2010.
3) I Disable WEEvent Logging  and minimize vb.net 2010.
I copied the WEEvent History file and pasted it below.
I then close WEEvent and reboot the computer.
After ReBoot I copied the ScriptLog Output text file and pasted it below the 
WEEvent Output.
Note that the OnKeyUp handler Function in my script fires but the OnKeyDown 
Function does not.
If I place the AddHandler for the OnKeyDown Event before the OnKeyUp AddHandler 
Statement in my script code then the 
OnKeyDown Event Handler Function in my script fires but the OnKeyUp function 
does not fire - This was noted in earlier tests.
<EndBackground>

<BeginCode>
' ======
' This is Test01 testing a straight up AddHandler version of using a COM DLL 
' which has been added to the project along with a Reference to the DLL.
' This app has One Module and 2 classes:
' LaunchApp is the Root, Global Module holding global variables and the "Main" 
sub.
' ProjectContextClass is the class where all project code resides.
' ScriptLog Class is a utility class that just prints a line using a 
StreamReader upon request.
' the Windoweyes dll and any other references have been added to the project.
' It is a Windows Forms Project without a Form and set up in the Project 
Properties accordingly.
' =====
Imports System.Threading
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Configuration
Imports System.IO
Imports System.Windows
Public Module LaunchApp
Public myKeyboard As WindowEyes.Keyboard
Public weApplication As WindowEyes.Application
    Public WithEvents weClientInformation As WindowEyes.ClientInformation
Public mySpeech As WindowEyes.Speech
Public ProjectFatleErrorOccured As Boolean = False
Public Sub Main()
Application.Run(New ProjectContextClass)
End Sub
End Module    
Public Class ProjectContextClass
Inherits ApplicationContext
' used to indicate where an error or diagnostic message comes from within  my 
script.
Dim ClassID As String = "ProjectContextClass"
Dim MethodID As String = ""
' The optional New() sub is the default method executed the first time a Class 
is referenced.
Public Sub New()
MethodID = "New()"
' appProcess is used to filter the Keyboard Messages.
Dim AppProcess As Object
Try
' Standard WE Initialization
weApplication = New WindowEyes.Application
weApplication.ClientIdentify(System.Diagnostics.Process.GetCurrentProcess().Id)
weClientInformation = weApplication.ClientInformation
AppProcess = weClientInformation.ApplicationProcess
AddHandler weClientInformation.OnShutdown, AddressOf 
weClientInformation_OnShutdown
mySpeech = weApplication.Speech
' Keyboard Handling 
myKeyBoard = weApplication.KeyBoard
myKeyboard.FilterProcess = AppProcess
AddHandler myKeyboard.OnKeyUp, AddressOf KeyEvents_OnKeyUpEventHandler
AddHandler myKeyboard.OnKeyDown, AddressOf KeyEvents_OnKeyDownEventHandler
Catch ex As Exception
ScriptLog.WriteLine( "Catch Triggered in " & ClassID & " > " & MethodID & 
VbCrlf & ex.ToString())
ProjectFatleErrorOccured = True
GoTo ProcExit
End Try
' The following code will ensure vb.net 2010 is running.
' This script is automatically associated with both vb.net 2008 and vb.net 2010 
' when I associate it to vb.net 2010 using the WE Dialog.
' Below, ensure it runs only when vb.net 2010 is running and not vb.net 2008.
Dim VB2010 As Integer = _
AppProcess.ProductName.IndexOf( "2010")
If VB2010 < 0 Then
mySpeech.Speak( "AppProcess.ProductName Not For 2010, is: " & 
AppProcess.ProductName)
ScriptLog.WriteLine( "AppProcess.ProductName Not For 2010, is: " & 
AppProcess.ProductName)
ProjectFatleErrorOccured = True
GoTo ProcExit
End If
ProcExit:
If ProjectFatleErrorOccured Then
weClientInformation_OnShutdown()
End If
End Sub ' The New (Default) Sub
Public  Sub weClientInformation_OnShutdown()
MethodID = "weClientInformation_OnShutdown()"
ScriptLog.WriteLine( "Enter " & ClassID & " > " & MethodID)
mySpeech.Speak( "ShuttingDown Bye Bye")
RemoveHandler myKeyboard.OnKeyDown, AddressOf KeyEvents_OnKeyDownEventHandler
RemoveHandler myKeyboard.OnKeyUp, AddressOf KeyEvents_OnKeyUpEventHandler
' As I understand it, Below the first statement cleans up things
' The second statement actually closes the process
Application.Exit()
System.Environment.Exit(0)
End Sub
' Below are the KeyEvents_OnKeyDownEventHandler and 
KeyEvents_OnKeyUpEventHandler Functions.
Public Function KeyEvents_OnKeyDownEventHandler( _
ByVal ReturnedKey As Integer, ByVal ReturnedModifiers As 
WindowEyes.KeyModifiers) _
As WindowEyes.KeyDisposition
MethodID = "KeyEvents_OnKeyDownEventHandler"
ScriptLog.WriteLine( "Enter " & ClassID & " > " & MethodID)
mySpeech.Speak( ClassID & " > " & MethodID & " Fired")
ScriptLog.WriteLine( "ReturnedKey: " & ReturnedKey.ToString() )
ScriptLog.WriteLine( "ReturnedModifiers: " & ReturnedModifiers.ToString() )
Return WindowEyes.KeyDisposition.kdProcess
End Function
Public Function KeyEvents_OnKeyUpEventHandler( _
ByVal ReturnedKey As Integer, ByVal ReturnedModifiers As 
WindowEyes.KeyModifiers) _
As WindowEyes.KeyDisposition
MethodID = "KeyEvents_OnKeyUpEventHandler"
ScriptLog.WriteLine( "Enter " & ClassID & " > " & MethodID)
mySpeech.Speak( ClassID & " > " & MethodID & " Fired")
ScriptLog.WriteLine( "ReturnedKey: " & ReturnedKey.ToString() )
ScriptLog.WriteLine( "ReturnedModifiers: " & ReturnedModifiers.ToString() )
Return WindowEyes.KeyDisposition.kdProcess
End Function
End Class
Public Class ScriptLog
Public Shared Sub WriteLine( ByVal Line As String )
Dim ThisFilePath As String = _
"c:\VBNet2010WETester\VBNet2010WETester\ScriptLog.txt"
Try
File.AppendAllText( ThisFilePath, Line )
File.AppendAllText( ThisFilePath, vbCrLf )
Catch ex As Exception
MessageBox.Show( "Exception in ScriptLog, " & ex.ToString() )
End Try 
End Sub
Public Shared Sub Clear()
Dim ThisFilePath As String = _
"c:\VBNet2010WETester\VBNet2010WETester\ScriptLog.txt"
File.Delete(ThisFilePath)
WriteLine( DateTime.Now )
End Sub
End Class
<EndCode>
<BeginWEEvent>
1 Speech.OnSpeak, "Logging Enabled"
2 OnObjectStateChange, Name: "Latest News", Value: "none", Role: page tab, 
State: selected,focusable,selectable, Description: 

"none", Keyboard Shortcut: "none", Help: "none", ChildID: 0, Children: 12, 
Window Handle: 20340, Event Window Handle: 20340, 

Default Action: "Switch"
3 OnObjectNameChange, Name: "Latest News", Value: "none", Role: page tab, 
State: selected,focusable,selectable, Description: 

"none", Keyboard Shortcut: "none", Help: "none", ChildID: 0, Children: 12, 
Window Handle: 20340, Event Window Handle: 20340, 

Default Action: "Switch"
... Rest of StartPage initialization removed for brevity
RtNote I Tab (FirstTime), no speech from vb.net 2010 only from my script.
37 Keyboard.OnKeyDown VirtualKeyCode = 9, keyModifiers  = 0
38 Keyboard.OnKeyProcessedDown VirtualKeyCode = 9, keyModifiers = 0
39 Keyboard.OnKeyUp VirtualKeyCode = 9 (Hex: 9), keyModifiers = 0
40 Speech.OnSpeak, "Project Context Class  greater than  Key Events underline  
On Key Up Event Handler Fired"
41 Keyboard.OnKeyProcessedUp VirtualKeyCode = 9, keyModifiers = 0
RtNote Tab (Second Time), no speech from vb.net 2010 only from my script..
42 Keyboard.OnKeyDown VirtualKeyCode = 9, keyModifiers  = 0
43 Keyboard.OnKeyProcessedDown VirtualKeyCode = 9, keyModifiers = 0
44 Keyboard.OnKeyUp VirtualKeyCode = 9 (Hex: 9), keyModifiers = 0
45 Speech.OnSpeak, "Project Context Class  greater than  Key Events underline  
On Key Up Event Handler Fired"
46 Keyboard.OnKeyProcessedUp VirtualKeyCode = 9, keyModifiers = 0
RtNote Tab (Third Time), no speech from vb.net 2010 only from my script..
47 Keyboard.OnKeyDown VirtualKeyCode = 9, keyModifiers  = 0
48 Keyboard.OnKeyProcessedDown VirtualKeyCode = 9, keyModifiers = 0
49 Keyboard.OnKeyUp VirtualKeyCode = 9 (Hex: 9), keyModifiers = 0
50 Speech.OnSpeak, "Project Context Class  greater than  Key Events underline  
On Key Up Event Handler Fired"
51 Keyboard.OnKeyProcessedUp VirtualKeyCode = 9, keyModifiers = 0
RtNote Hit Enter, no speech from vb.net 2010 only from my script and no MSAA or 
other actions..
52 Keyboard.OnKeyDown VirtualKeyCode = 13, keyModifiers  = 0
53 Keyboard.OnKeyProcessedDown VirtualKeyCode = 13, keyModifiers = 0
54 Keyboard.OnKeyUp VirtualKeyCode = 13 (Hex: D), keyModifiers = 0
55 Speech.OnSpeak, "Project Context Class  greater than  Key Events underline  
On Key Up Event Handler Fired"
56 Keyboard.OnKeyProcessedUp VirtualKeyCode = 13, keyModifiers = 0
57 Keyboard.OnKeyDown VirtualKeyCode = 18, keyModifiers  = 0
58 Keyboard.OnKeyProcessedDown VirtualKeyCode = 18, keyModifiers = 0
RtHere, Hit Alt+F4 to try and close vb.net 2010, no speech and did not close.
59 Keyboard.OnKeyDown VirtualKeyCode = 115, keyModifiers  = 4
60 Keyboard.OnKeyProcessedDown VirtualKeyCode = 115, keyModifiers = 4
61 Keyboard.OnKeyUp VirtualKeyCode = 115 (Hex: 73), keyModifiers = 4
62 Speech.OnSpeak, "Project Context Class  greater than  Key Events underline  
On Key Up Event Handler Fired"
63 Keyboard.OnKeyProcessedUp VirtualKeyCode = 115, keyModifiers = 4
64 Keyboard.OnKeyUp VirtualKeyCode = 18 (Hex: 12), keyModifiers = 4
65 Speech.OnSpeak, "Project Context Class  greater than  Key Events underline  
On Key Up Event Handler Fired"
66 Keyboard.OnKeyProcessedUp VirtualKeyCode = 18, keyModifiers = 4
RtHere, think this is where I hit ctrl+windows+e to stop WEEvent Logging.
67 Keyboard.OnKeyDown VirtualKeyCode = 91, keyModifiers  = 8
68 Keyboard.OnKeyDown VirtualKeyCode = 17, keyModifiers  = 10
69 Keyboard.OnKeyProcessedDown VirtualKeyCode = 91, keyModifiers = 8
70 Keyboard.OnKeyProcessedDown VirtualKeyCode = 17, keyModifiers = 10
<EndWEEvent>
<BeginScriptLog>
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 91
ReturnedModifiers: kmControl
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 17
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 9
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 9
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 9
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 13
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 115
ReturnedModifiers: kmAlt
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 18
ReturnedModifiers: kmAlt
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 91
ReturnedModifiers: kmControl
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 17
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 115
ReturnedModifiers: kmAlt
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 18
ReturnedModifiers: kmAlt
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 89
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 115
ReturnedModifiers: kmAlt
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 18
ReturnedModifiers: kmNone
Enter ProjectContextClass > KeyEvents_OnKeyUpEventHandler
ReturnedKey: 13
ReturnedModifiers: kmNone
<EndScriptLog>
EndOfDocument

Reply via email to