Trigger (auto execute) an application when opening file

English main discussion
  • Author
  • Message
Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

AKDN_FRAME_ACTIVATE

r0n
Offline
Posts: 23
Joined: Sat Jun 14, 2014 3:56 am

Post by r0n »

Thank you very much!!!

r0n
Offline
Posts: 23
Joined: Sat Jun 14, 2014 3:56 am

Post by r0n »

And it's me again, sorry about this...

-edit- (solved original problem I posted in this post, but now I found out my applications hangs when I re-open a file that is already open).

So I need a way to put all the full paths of the currently open documents in a string.

The closest thing I found was this:
viewtopic.php?p=16297#p16297

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

r0n
Strange logic. Why you need all files? If you reopen file that is already open, message AKDN_OPENDOCUMENT_FINISH also sends, but with EOD_WINDOW_EXIST in lParam. So you can prevent reaction on file reopening.

Anyway...

Code: Select all

WScript.Echo(GetFileList());

function GetFileList()
{
  var hMainWnd=AkelPad.GetMainWnd();
  var pFileList="";
  var pFile;
  var lpFrame;
  var lpFile;
  var nTabIndex;
  
  for (nTabIndex=0;; ++nTabIndex)
  {
     if (!(lpFrame=AkelPad.SendMessage(hMainWnd, 1288 /*AKD_FRAMEFIND*/, 8 /*FWF_BYTABINDEX*/, nTabIndex)))
       break;
     lpFile=AkelPad.SendMessage(hMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 32 /*FI_FILEW*/, lpFrame);
     if (pFile=AkelPad.MemRead(lpFile, 1 /*DT_UNICODE*/))
       pFileList+=pFile + "\n";
  }
  return pFileList;
}

r0n
Offline
Posts: 23
Joined: Sat Jun 14, 2014 3:56 am

Post by r0n »

@Instructor
When you open a file it sends the filepath to the external (my) application.
If I send a string with all the currently opened filepaths in it with it, I can check if the filepath that is send to be processed already exists in the filelist string. (and then decide to continue, or not).

But the EOD_WINDOW_EXIST sounds way more effective and elegent.
Makes my chosen path seem strange indeed.

My thanks for the EOD_WINDOW_EXIST and GetFileList.js!!!
(I can always use that code!)

r0n
Offline
Posts: 23
Joined: Sat Jun 14, 2014 3:56 am

AkelPad.MemRead, example?

Post by r0n »

Sorry to kick this up.
Could someone give a AkelPad.MemRead example, based on the following filemapping path => "Global\\AkelPad"
An external script opens "Global\\AkelPad" and writes a path to that location. Now I need a .js script that can read it.

I think the green comment already gives a start, but I can't get it to work.
I basic example would help a lot.

FileMappingExample.js

Code: Select all

var hMainWnd=AkelPad.GetMainWnd();
var hMem;
var szName;
var szMem;
var dwMemSize=1000;

if (szName=AkelPad.MemAlloc(16))
{
  AkelPad.MemCopy(szName, "Global\\AkelPad", 0 /*DT_ANSI*/);

  //Create named memory object.
  if (hMem=AkelPad.SendMessage(hMainWnd, 1305 /*AKD_MEMCREATE*/, szName, dwMemSize))
  {
    if (szMem=AkelPad.SendMessage(hMainWnd, 1306 /*AKD_MEMMAP*/, hMem, dwMemSize))
    {
      AkelPad.MemCopy(szMem, "Test", 0 /*DT_ANSI*/);
      AkelPad.SendMessage(hMainWnd, 1307 /*AKD_MEMUNMAP*/, szMem, 0);
    }

    //Call external application. This application should call:
    //hMem=OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Global\\AkelPad");
    //szMem=MapViewOfFile(hMem, FILE_MAP_ALL_ACCESS, 0, 0, 1000);
    //Read szMem.
    //UnmapViewOfFile(szMem);

    AkelPad.SendMessage(hMainWnd, 1308 /*AKD_MEMCLOSE*/, hMem, 0);
  }
  AkelPad.MemFree(szName);
}
[/code]

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

Code: Select all

var hMainWnd=AkelPad.GetMainWnd();
var hMem;
var szName;
var szMem;
var pMem="";
var dwMemSize=1000;

if (szName=AkelPad.MemAlloc(16))
{
  AkelPad.MemCopy(szName, "Global\\AkelPad", 0 /*DT_ANSI*/);

  //Create named memory object.
  if (hMem=AkelPad.SendMessage(hMainWnd, 1305 /*AKD_MEMCREATE*/, szName, dwMemSize))
  {
    if (szMem=AkelPad.SendMessage(hMainWnd, 1306 /*AKD_MEMMAP*/, hMem, dwMemSize))
    {
      AkelPad.MemCopy(szMem, "Test", 0 /*DT_ANSI*/);
      AkelPad.SendMessage(hMainWnd, 1307 /*AKD_MEMUNMAP*/, szMem, 0);
    }

    //Call external application. This application should call:
    //hMem=OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Global\\AkelPad");
    //szMem=MapViewOfFile(hMem, FILE_MAP_ALL_ACCESS, 0, 0, 1000);
    //Read szMem.
    //UnmapViewOfFile(szMem);

    if (szMem=AkelPad.SendMessage(hMainWnd, 1306 /*AKD_MEMMAP*/, hMem, dwMemSize))
    {
      pMem=AkelPad.MemRead(szMem, 0 /*DT_ANSI*/);
      AkelPad.SendMessage(hMainWnd, 1307 /*AKD_MEMUNMAP*/, szMem, 0);
    }
    WScript.Echo(pMem);

    AkelPad.SendMessage(hMainWnd, 1308 /*AKD_MEMCLOSE*/, hMem, 0);
  }
  AkelPad.MemFree(szName);
}

r0n
Offline
Posts: 23
Joined: Sat Jun 14, 2014 3:56 am

Post by r0n »

Thank you!!!

Offline
Posts: 1
Joined: Fri Aug 11, 2017 12:18 pm
Contact:

Post by julialbert »

r0n wrote:Thank you!!!
Great post
Post Reply