Hi Tom and Rod,

I'm not sure this would ever fire in time to be useful, due to the question
itself (asking the user if he wishes to quit) actually holding the program
(and so the app tied to it) open.

Rod, if you didn't make your Itunes app a program-specific app, then the
shutdown event would not fire anyway when Itunes closes; it would only fire
when WE was shutting down, or someone manually shutdown your app.  But even
if you did, as I said I don't think the event Tom mentions will fire until
someone answers "yes", which defeats the whole point here.

I have the exact same problem in my Word Advanced Features app, and it's a
bugger to solve.
The way I solved it was to not have a separate connection to Word (or to
Itunes in your case), but to make use of the currently open instance.  This
means you don't use CreateObject to get a new Itunes object (which gets
counted as number two being open), but you make use of the currently open
Itunes object by using the GetObject() method instead.  
This means Itunes has to already be open; I can't remember how your app
works, but if you were counting on your app actually causing Itunes to start
by creating the Itunes object, then you can't use GetObject().

But lets assume you don't try to start it, you assume it's already running,
or you determine it is by finding the correct window being open.  Then, you
could attach to the Itunes object with some code like I use for Word below:


On Error Resume Next
Set wordapp = GetObject(, "word.application") ' note the object name here is
the second parameter, and the first parameter is simply omitted
On Error GoTo 0

If Not wordapp Is Nothing Then
' it worked
' finish setting up Word
DoEvents
sleep 500 ' allow Word some time to initialize
queue "setupWord"
Exit Sub
End If


Every time you go to do something with Itunes, you'll need to do the
GetObject again, or test to make sure your variable isn't nothing; but now,
the onShutdown event Tom mentions should work if you have a program-specific
app setup (although, since you did not create a new object, you don't
actually have to destroy it, your app and the original object are going away
anyway thanks to Window-Eyes shutting down your app if it's
program-specific).

A second way which may work is to make use of an Itunes object event which I
see is available named OnQuittingEvent.  You'll need to Google this event,
and perhaps just experiment, to see when it gets fired.  It may get fired
before the question gets answered, giving you time to destroy your copy of
the object (but I would doubt it).

Let me know if I can answer any further questions on this, I know it's a
bear to tackle and get working.

Chip



-----Original Message-----
From: Scripting
[mailto:scripting-bounces+chip.orange=gmail....@lists.window-eyes.com] On
Behalf Of Tom Kingston via Scripting
Sent: Sunday, February 21, 2016 4:05 PM
To: Rod Hutton; Window-Eyes Scripting List
Subject: Re: Scripting an app for a COM application

Hey Rod,

I'd connect to the ClientInformation.OnShutdown event and destroy the 
iTunes object there.

Hth,
Tom


On 2/21/2016 11:36 AM, Rod Hutton via Scripting wrote:
> Hi,
>
> In updating my Itunes Enhance app, I now get the following message when
quitting Itunes:
>
> One or more applications are using the iTunes scripting interface.
> Are you sure you want to quit?
> If you do nothing, all applications that are using the scripting interface
> will be automatically disconnected in 20 second.
> Quit Don't Quit
>
> I think I'm getting this message because, in the previous version of my
app, which controls Itunes using its COM object using hotkeys, I used to set
my Itunes object variable to Nothing after completing the commands for each
hotkey.
> Now, however, in the present version of my app, after some of the hotkey
presses, I'm continuing to monitor the state of Itunes, and so I no longer
set my Itunes variable to Nothing.
> This means that my app never nullifies my Itunes object variable, and so
if the user quits Itunes, they get the above message.
> In a way, it's no big deal, since the counter runs down, and, if the user
does nothing, all will be well.
> However, I'm just wondering if there is a way to prevent the message from
appearing, and avoid frightening the squeamish user.
>
> Thanks,
>
> Rod
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
<http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com/attachme
nts/20160221/493cba13/attachment.htm>
> _______________________________________________
> Any views or opinions presented in this email are solely those of the
author and do not necessarily represent those of Ai Squared.
>
> For membership options, visit
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/tom.kings
ton%40charter.net.
> For subscription options, visit
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
> List archives can be found at
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com
>
_______________________________________________
Any views or opinions presented in this email are solely those of the author
and do not necessarily represent those of Ai Squared.

For membership options, visit
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/chip.oran
ge%40gmail.com.
For subscription options, visit
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4152 bytes
Desc: not available
URL: 
<http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com/attachments/20160221/7be92051/attachment.bin>
_______________________________________________
Any views or opinions presented in this email are solely those of the author 
and do not necessarily represent those of Ai Squared.

For membership options, visit 
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/archive%40mail-archive.com.
For subscription options, visit 
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at 
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com

Reply via email to