This looks like we're making some progress, and it looks like I do have 
something else to shoot for besides networking-based applications (which is the 
main reason for me learning C#.)  Bu it would be interesting for PowerShell to 
be introduced as another language for WE scripting support.  And the funny 
thing is that PowerShell is a scripting language, Microsoft's preference over 
VBS anyway.

From: Aaron Smith [mailto:[email protected]]
Sent: Friday, April 13, 2012 10:44 AM
To: [email protected]
Subject: Re: WE And Microsoft Development Environments

Here's the VB version of my previous example:

Public Class Form1
    Private weApplication As WindowEyes.Application
    Private WithEvents weClientInformation As WindowEyes.ClientInformation
    Private mySpeech As WindowEyes.Speech
    Private myMSAAEventSource As WindowEyes.MSAAEventSource

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) 
Handles MyBase.Load
        weApplication = New WindowEyes.Application
        
weApplication.ClientIdentify(System.Diagnostics.Process.GetCurrentProcess().Id)
        weClientInformation = weApplication.ClientInformation
        AddHandler weClientInformation.OnShutdown, AddressOf 
Me.weClientInformation_OnShutdown
        Me.Hide()
    End Sub

    Private Sub myMSAAEventSource_OnObjectFocus(accObj As WindowEyes.Accessible)
        Dim handeledEvent As Boolean = False
        Try
            accObj.Prefetch(WindowEyes.AccessibleProperty.apAll)
            If accObj.role.Value = 
WindowEyes.AccessibleRoleEnum.role_SYSTEM_PUSHBUTTON Then
                mySpeech.Speak(accObj.Name & ". I has a button!")
            End If
        Catch ex As Exception
            ' Something bad happened
        End Try

        If Not handeledEvent Then
            accObj.SimulateEvent(WindowEyes.MSAAEventID.event_OBJECT_FOCUS, 
WindowEyes.AccessibleProperty.apAll)
        End If
    End Sub

    Private Sub weClientInformation_OnShutdown()
        Me.Close()
    End Sub

End Class

Aaron

On 4/12/2012 6:40 PM, RicksPlace wrote:
Hi Aaron: I dont remember the exact problem. It might have been something to do 
with that Message Processing problem I mentioned but I think  you, or one of 
the other guys, had mentioned that problem had been addressed so I'm not sure 
that was the problem.
I think I still have that VB.net project floating around and will ReVisit it.
If I get it working I will post it as another example of scripting WE from 
within the Visual Studio (VB.net Express) environment.
If not I will post up any problems I encounter.
It might take a few days as I am tied up with something else but I will give it 
another go before long.
Hay, you other folks who program are invited to give it a go in another 
language. Kate, what about Power Basic?
Rick USA
----- Original Message -----
From: Aaron Smith<mailto:[email protected]>
To: [email protected]<mailto:[email protected]>
Sent: Thursday, April 12, 2012 3:49 PM
Subject: Re: WE And Microsoft Development Environments

On 4/11/2012 6:21 PM, RicksPlace wrote:
I never got MSAA working properly and had some other problems which I couldn't 
resolve.

Do you remember what the issues were? I whipped up this example real quick 
which demonstrates speaking "I has a button" any time a button accessible gets 
focused:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WindowEyes;

namespace MSAAEventProc {
    public partial class MSAAEventProc : Form {

        private WindowEyes.Application weApplication = null;
        private WindowEyes.ClientInformation weClientInformation = null;
        private WindowEyes.Speech mySpeech = null;
        private WindowEyes.MSAAEventSource myMSAAEventSource = null;

        public MSAAEventProc() {
            Debug.WriteLine("init");
            InitializeComponent();
            // Get the application object
            weApplication = new WindowEyes.Application();

            // Introduce ourselves to Window-Eyes
            
weApplication.ClientIdentify(System.Diagnostics.Process.GetCurrentProcess().Id);
            weClientInformation = weApplication.ClientInformation;

            // Hook Shutdown so we can clean up
            weClientInformation.OnShutdown += new 
ClientInformationEvents_OnShutdownEventHandler(weClientInformation_OnShutdown);

            // Hook MSAA events
            myMSAAEventSource = weApplication.MSAAEventSource;
            myMSAAEventSource.OnObjectFocus += new 
MSAAEvents_OnObjectFocusEventHandler(myMSAAEventSource_OnObjectFocus);

            // Set up Speech so we can talk
            mySpeech = weApplication.Speech;
        }

        private void myMSAAEventSource_OnObjectFocus(WindowEyes.Accessible 
accObj) {
            bool handeledEvent = false;
            try {
                // Prefetch all the Accessible info
                accObj.Prefetch(AccessibleProperty.apAll);

                // If it's a button, we'll handle it.
                if (accObj.role.Value == 
AccessibleRoleEnum.role_SYSTEM_PUSHBUTTON) {
                    mySpeech.Speak(accObj.Name + ". I has a button!");
                }
            } catch (Exception e) {
                // Something bad happened;
            }

            if (!handeledEvent) {
                // Simulate the event
                accObj.SimulateEvent(MSAAEventID.event_OBJECT_FOCUS, 
AccessibleProperty.apAll);
            }
        }

        private void weClientInformation_OnShutdown() {
            // Bye
            Close();
        }
    }
}

Aaron




--

Aaron Smith

Web Development * App Development * Product Support Specialist

GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825

260-489-3671 * gwmicro.com



To insure that you receive proper support, please include all past

correspondence (where applicable), and any relevant information

pertinent to your situation when submitting a problem report to the GW

Micro Technical Support Team.



--

Aaron Smith

Web Development * App Development * Product Support Specialist

GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825

260-489-3671 * gwmicro.com



To insure that you receive proper support, please include all past

correspondence (where applicable), and any relevant information

pertinent to your situation when submitting a problem report to the GW

Micro Technical Support Team.

Reply via email to