Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-13-2007, 11:28 AM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Close external program or window

Hi, i am using the code (Shell.open) below to launch a .pdf file external, which works like a charm.

But i would like to check if Adobe reader is already running - and if
so - i would like to close it first.

I've tried window.close, but thats doesn't do it.
Anyone who knows how to do it?

And is there a possibility to check if adobe reader is installed?

Code:
var path = getAppDir()+ "docs/"+selectedListing+"_"+selectedPrint+".pdf";
pdfx = createControl("AcroPDF.PDF.1", 0, 0, 0, 0);
var acrocontrol = pdfx.activex;

if (File.exists(path))
{
Shell.open(path);
} else {
// display error msg
}
Reply With Quote
  #2 (permalink)  
Old 06-13-2007, 02:28 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Close external program or window

You can use the Shell.findExecutable method to see whether the acrobat reader or the foxit reader has been installed, as shown in the following ffish script code
Code:
// get the application that is used to open pdf files
var app = Shell.findExecutable(path);
var wnd = null;
if (!app) {
Dialogs.msgBox("No application for viewing pdf files");
} else {
Shell.open(path);
}
The following ffish script code can be used to close the pdf reader
Code:
var filename = new File(path).name;
// get all windows in the system
var wnds = Window.getWindowsByName();
// find out the pdf viewer window
for (var i = 0; i < wnds.length; i++) {
// caption of the window
var caption = wnds[i].caption;
// The caption of the acrobat reader or foxit reader window will 
// contain the opened pdf filename
if (caption.indexOf(filename) == 0 && 
(caption.indexOf("Adobe Acrobat") > 0 || caption.indexOf("Foxit Reader") > 0)) {
// close the window
wnds[i].close();
break;
}
}
Reply With Quote
  #3 (permalink)  
Old 06-15-2007, 08:47 AM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Re:Close external program or window


That works like a charm.
Thanks for your great support!
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:21 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.