Thanks Rick for reporting back.  I've added yours and Jamal's findings as a
note to the GW wiki article "Internal and External Scripts".

Chip
 

> -----Original Message-----
> From: RicksPlace [mailto:ofbgm...@mi.rr.com] 
> Sent: Wednesday, May 09, 2012 6:07 PM
> To: gw-scripting@gwmicro.com
> Subject: Re: Visual Studio Express Accessibility
> 
> Hi Jamal:
> System.Environment.Exit(0)
> Worked.
> Actually it terminates the process but it didn't say anything 
> about clearing message pumps etc...
> So  I issue a Application.Exit() It clears the pumps and 
> performs other finalization duties if I read it right but 
> does not terminate the process.
> Then I manually call the Event Handler triggered when WE 
> Places it's call back.
> In that sub I used the
> System.Environment.Exit(0)
> The termination seems to work very well now as far as I can tell.
> I had tried that statement but had returned a -1 code, guess 
> WE wanted the 0 code or perhaps I mucked something up.
> Things were getting a little harry around that time trying 
> tons of various combinations.
> Anyway, thanks, the shutdown goes almost instantly and 
> appears to be clean.
> The kill process took some time, think WE had to wait until 
> it figured the process wasn't responding or however it shuts 
> down an application when the application fails to shut itself 
> down properly.
> One technical down and a bunch to go!
> Today I added a message that VB.net is loading and to wait, 
> and a message that VB.net is ready for work when the Main 
> Window has been loaded into the Automation Tree.
> WE had not spoken anything and sometimes there was nothing 
> for several seconds.
> Tomorrow I want to set focus using UIA to one of the 
> AutomationElement objects on the VB.net Start Page and see if 
> that also sets the WE Cursor to that object or if I have to 
> do some tweeking to get that to work.
> After that the Start Page is workable enough with WE out of 
> the box and it will be on to another part of the IDE.
> Rick USA
> ----- Original Message -----
> From: "Jamal Mazrui" <empo...@smart.net>
> To: <gw-scripting@gwmicro.com>
> Sent: Wednesday, May 09, 2012 3:53 PM
> Subject: Re: Visual Studio Express Accessibility
> 
> 
> > Hi Rick,
> > Upon further reading about that Shutdown method, it seems 
> to be part 
> > of the WPF related classes and assemblies, so would require 
> .NET  3 or 
> > above and a reference to the appropriate assembly.  Fortunately, 
> > however, there seems to be another method that is 
> independent of either WinForms or WPF.
> > I just tried it, and it seems to work.  Try the following code:
> >
> > System.Environment.Exit(0)
> > The numeric parameter to the Exit method of the Environment class 
> > specifies the exit code to pass to the operating system when the 
> > program closes.  Can you let us know whether that code 
> works?  Thanks 
> > for helping us learn more about this stuff through your research.
> >
> >  Jamal
> >
> > On Wed, 9 May 2012, RicksPlace wrote:
> >
> >> Date: Wed, 9 May 2012 14:59:24 -0400
> >> From: RicksPlace <ofbgm...@mi.rr.com>
> >> Reply-To: gw-scripting@gwmicro.com
> >> To: gw-scripting@gwmicro.com
> >> Subject: Re: Visual Studio Express Accessibility
> >>
> >> Hi:
> >> I have tried using that but I get an error message.
> >>  The Application Object in use is in:
> >>  System.Window.Forms.Application not the  
> System.Windows.Application 
> >> Class.
> >>  Here is the error when I hard code
> >>  System.Windows.Application.Current.ShutDown()
> >>  Error 1 'Application' is not a member of 'Windows'. 
> >> c:\VBNet2010Script\VBNet2010Script\LaunchApp.vb 65 1 
> VBNet2010Script  
> >> When I just use Application.Current.Shutdown()  It tells 
> me Current 
> >> is not a member of the System.Windows.Forms.Application class.
> >>  I am not sure the ShutDown command can be used with a Winforms 
> >> Project or, at least, not one set up the way this one is set up.
> >>  Thanks though and I did try it before and again just now 
> to verify 
> >> the results.
> >>  I am not sure how much documentation I will be able to 
> provide. This 
> >> is getting quite complicated indeed.
> >>  My first problem is that when I click on the shortcut to start 
> >> vb.net 2010 express WindowEyes says nothing at all.
> >>  Alt Tabbing doesn't help since it takes a few seconds for 
> vb.net to 
> >> load and get ready for work.
> >>  Even after loading WindowEyes says nothing.
> >>  So:
> >>  I put a message in the script that vb.net is loading and another 
> >> message when it is done and ready for work.
> >>  I also will try and set the focus to one of the buttons 
> on the Start 
> >> Page and read that button so things sound good and solid 
> when I click 
> >> the shortcut from the DeskTop.
> >>  It is working but I will muck with setting focus tomorrow, 
> >> dinnertime my wife tells me.
> >>  Rick USA
> >>  .if it comes up.
> >>
> >>  Rick USA
> >>  ----- Original Message -----
> >>  From: Katherine Moss
> >>  To: gw-scripting@gwmicro.com
> >>  Sent: Monday, May 07, 2012 8:51 PM
> >>  Subject: RE: Visual Studio Express Accessibility
> >>
> >>
> >>  And whatever you do get running, you should post up on 
> app central 
> >> for the rest of us who are interested.
> >>
> >>
> >>
> >>  From: Chip Orange [mailto:lists3...@comcast.net]
> >>  Sent: Monday, May 07, 2012 8:18 PM
> >>  To: gw-scripting@gwmicro.com
> >>  Subject: RE: Visual Studio Express Accessibility
> >>
> >>
> >>
> >>  Hi again Rick,
> >>
> >>
> >>
> >>  congrats and thanks for working on this.
> >>
> >>
> >>
> >>  I hope you saw Jamal's post on how to shutdown a winforms 
> .net app 
> >> using Application.Current.Shutdown()?  It certainly would 
> be better 
> >> to shut it down than to "kill" the process, and this looks 
> like he's 
> >> put his finger on the technique.  I think it would be worth a wiki 
> >> article if you develop an external app, and have this tip to pass 
> >> along to others (along with other advice on getting one running).
> >>
> >>
> >>
> >>  Chip
> >>
> >>
> >>
> >>
> >>
> >>
> >> 
> ---------------------------------------------------------------------
> >> -------
> >>
> >>    From: RicksPlace [mailto:ofbgm...@mi.rr.com]
> >>    Sent: Monday, May 07, 2012 4:50 AM
> >>    To: gw-scripting@gwmicro.com
> >>    Subject: Re: Visual Studio Express Accessibility
> >>
> >>    Hi Chip, Jamal et al:
> >>
> >>    Chip
> >>
> >>      That is correct. It was hard to explain the script 
> was created 
> >> in vb.net 2008 express for vb.net 2010 Express.
> >>
> >>      To shut the script down I had to shut down a Project (the 
> >> script) using the tools available to a vb.net project since the 
> >> executable
> >> (VBNet2010Script.exe) was created in vb.net 2008 express.
> >>
> >>      Perhaps I did not make this clear in one of the 
> posts, could be.
> >>
> >>      But you are correct, I wanted to shut down only the 
> script and 
> >> not the IDE itself.
> >>
> >>      Jamal: I will be glad to post up the HarvestWindow output and 
> >> the WinDig output now that I am getting back to working with the 
> >> script and not on trying to shut it down gracefully, which was 
> >> seemingly not possible.
> >>
> >>      I am pretty sure there are things I can do to make 
> the Express 
> >> Versions a little nicer to work with and since you guys are Gurus 
> >> with Windows Programming you might have ideas and solutions I dont 
> >> know and dont know I dont know if that makes sense.
> >>
> >>      Kate, I forget the ModuleName but the problem was that it was 
> >> the same for both vB.net 2008 Express and for VB.net 2010 
> Express and 
> >> WindowEyes uses the ModuleName to associate a script with a Target 
> >> Application so my script was firing for both versions when 
> I want it 
> >> firing for only the vb.net 2010 Express version.
> >>
> >>      Finally, Application.Exit did not shut down the 
> script so I was 
> >> trying all other methods of shutting it down gracefully 
> but only the 
> >> Killing of the Running Process worked to stop the script in 
> >> WindowEyes ScriptManager.
> >>
> >>      The discussion about using a Form was because that is 
> the normal 
> >> way a Winforms Project is shut down and handles all the 
> cleanup and 
> >> finalization automatically.
> >>
> >>      It also works correctly with WindowEyes to stop the script in 
> >> the WindowEyes ScriptManager.
> >>
> >>      The Script did not need a Form so I did not want to 
> use a Dummy 
> >> Form - not graceful but may be the best method in the long 
> run unless 
> >> WindowEyes can recognize a shutdown request via Application.Exit.
> >>
> >>      Actually WindowEyes recognizes it and fires the 
> appropriate call 
> >> back but does not terminate the calling thread so WindowEyes keeps 
> >> the Thread Running and Script Manager does not reflect the 
> attempted 
> >> termination.
> >>
> >>      Note that Application,.exit does not force a shutdown so this 
> >> may, or not, be the correct behavior for WindowEyes to 
> follow - that 
> >> is beyond my Windows Programming understanding and not 
> necessary to 
> >> get the job done at this point.
> >>
> >>      So, I will leave any discussion about that to the 
> Windows  gurus 
> >> and Software Programmers and Engineers.
> >>
> >>      There are not enough people working with External, 
> Managed Code 
> >> scripts to merrit more discussion of this on list from a 
> piker like me.
> >>
> >>      So that's it for this thread for now.
> >>
> >>      Kill is working and ok for this particular script so 
> far but I 
> >> may use a dummy Form in the future if it gets more complex.
> >>
> >>      I will likely post other threads about the Analysis 
> process and 
> >> what can be done with the available tools.
> >>
> >>      So, I think that's all I have on this thread.
> >>
> >>      Thanks for the great discussion and I look forward to 
> upcoming 
> >> threads where I can learn more by reading, experimenting 
> and asking 
> >> questions.
> >>
> >>      Rick USA
> >>
> >>      ----- Original Message -----
> >>
> >>      From: Chip Orange
> >>
> >>      To: gw-scripting@gwmicro.com
> >>
> >>      Sent: Saturday, May 05, 2012 3:44 PM
> >>
> >>      Subject: RE: Visual Studio Express Accessibility
> >>
> >>
> >>
> >>      Rick,
> >>
> >>
> >>
> >>      I see no reason why you need to kill the visual studio IDE 
> >> process itself?  You only need to stop your own script.  A script 
> >> never tries to stop the process/program which it is related to.
> >>
> >>
> >>
> >>      Chip
> >>
> >>
> >>
> >>
> >>
> >>
> >> 
> ---------------------------------------------------------------------
> >> ---
> >>
> >>        From: RicksPlace [mailto:ofbgm...@mi.rr.com]
> >>        Sent: Saturday, May 05, 2012 6:43 AM
> >>        To: gw-scripting@gwmicro.com
> >>        Subject: Visual Studio Express Accessibility
> >>
> >>        Hi:
> >>
> >>        I was looking into shutting down a Process from 
> within VB.net 
> >> Express.
> >>
> >>        To ensure all Child-processes are shut down it 
> appears folks 
> >> usually use something called the EnvDTE object.
> >>
> >>        This object also gives access to the running Process so you 
> >> can do things like click a button or change text in a TextBox from 
> >> another Process like a  WindowEyes Script.
> >>
> >>        According to a member of the Microsoft Staff, a 
> posting in a 
> >> Blog, the Express Versions do not expose the EnvDTE Object 
> to third 
> >> party applications like a WindowEyes script.
> >>
> >>        This was a quote Business decission on the part of 
> Microsoft.
> >>
> >>        This hampers using UIA, MSAA or any other method I 
> know of to 
> >> make the Express versions of Visual Studio much more 
> accessible than 
> >> they are already.
> >>
> >>        It also has thrown a monkey wrench into my plan to Kill the 
> >> running Process since Visual Studio, and I assume the Express 
> >> versions, spawn other processes that may be left hanging 
> and running 
> >> if the Main Process is Killed without due process to the child 
> >> processes if I read it correctly.
> >>
> >>        I can still make some things much more readable 
> with UIA, MSAA 
> >> and the WE Object Model but not do much, if anything, that 
> requires 
> >> information from the Underlying Visual Studio controls or any 
> >> interaction with them via a script.
> >>
> >>        At least that is my understanding of the problem so far.
> >>
> >>        Since Application.Exit doesnt work, it handles clean up and 
> >> shut down messages while kill doesn't,perhaps the shut down of a 
> >> dummy form will work as Aaron used in his original example.
> >>
> >>        I either have to find a way to work around a focus problem 
> >> using a dummy window if I can, figure out why Application.Exit 
> >> doesn't work or find another method of shutting the script 
> down ensuring no objects or
> >> processes are left     hanging.
> >>
> >>        I hope Microsoft knows this decission sucks for 
> blind users of 
> >> their free Express Versions of Visual Studio that work  extremely 
> >> well for sighted users.
> >>
> >>        Later and I will be able to do a few things even 
> without this 
> >> missing feature in the Visual Studio Express versions.
> >>
> >>        Rick USA
> >>
> >
> > 
> 

Reply via email to