How to prevent "External Editor" from launching a new editor

Get help with installing and running FastPictureViewer: ask questions here. Please do not post presumed bug reports or suggestions here.

How to prevent "External Editor" from launching a new editor

Postby kleist on Tue Sep 14, 2010 2:44 pm

Hello all FastPictureViewer users,

I've recently found this highly useful and extremely well crafted tool. However, I found it somewhat limiting that the "External Editor" function always opens a new instance of my preferred photo editor "COREL Photo-Paint X4" (which seemingly can't be configured to prevent multiple instances). After much experimentation I've finally found a solution, which I'd like to share.

The solution consists of three parts:

1. A registry modification which adds an "Edit" action to the context menu for .jpg files in Windows Explorer. This action opens the image in Photo-Paint, after starting it if necessary.

2. An old style batch file, called by FPV.

3. A Windows PowerShell script, called by the batch file, which uses DDE to open the image in Photo-Paint.

The reason for the intermediate batch file is, that by default a PowerShell opens with Notepad (which is a good thing, from a security perspective). The batch file is executed, however, which is what we want.

The following code works on my Windows 7 computer for .jpg files and Photo-Paint, but should also work on your computer for other file types and editors after some fiddling.

1. Create three new Registry keys:
Code: Select all
HKEY_CLASSES_ROOT\SystemFileAssociations\.jpg\Shell\edit\command
    "D:\local\Corel\CorelDRAW-Graphics-Suite-X4\Programs\CorelPP.exe" -DDE
   
HKEY_CLASSES_ROOT\SystemFileAssociations\.jpg\Shell\edit\ddeexec
   [open("%1")]
   
HKEY_CLASSES_ROOT\SystemFileAssociations\.jpg\Shell\edit\ddeexec\application
   CORELPP

2. The batch file "pp.bat", which is launched from FastPictureViewer by pressing ctrl+F1:
Code: Select all
@ECHO OFF
ECHO Opening image in COREL Photo-Paint...
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe E:\etc\powershell-home\scripts\pp.ps1 %1

3. The PowerShell script:
Code: Select all
# this uses DDE, so if Photo-Paint is already running the image will be opened there
start-process -verb edit $args[0]

I'm looking forward to being able to buy a full license, and the codec pack!
kleist
 
Posts: 2
Joined: Tue Sep 14, 2010 2:05 pm

Re: How to prevent "External Editor" from launching a new ed

Postby Axel on Tue Sep 14, 2010 8:18 pm

Good tip!

Indeed the program launcher does a simple job of starting the designated program with the selected file as argument.

Old (and very old) applications used to use the DDE protocol to talk to running instances and DDE verbs used to be implemented to open a new document in an already running instance of a program.

Using an intermediate script to launch and open the document for editing in a running PhotoPaint is a neat idea 8-)
Axel
Site Admin
 
Posts: 794
Joined: Thu Nov 06, 2008 1:54 am
Location: Geneva, Switzerland

Re: How to prevent "External Editor" from launching a new ed

Postby kleist on Thu Sep 30, 2010 8:40 pm

An enhancement of "pp.bat", the "-file" option makes PowerShell handling also filenames containing spaces:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -file E:\etc\powershell-home\scripts\pp.ps1 %1
kleist
 
Posts: 2
Joined: Tue Sep 14, 2010 2:05 pm


Return to User-to-User