Page 2 of 2

Posted: Wed Jun 18, 2014 3:25 pm
by FeyFre
AKDN_FRAME_ACTIVATE

Posted: Wed Jun 18, 2014 3:37 pm
by r0n
Thank you very much!!!

Posted: Fri Jun 20, 2014 12:44 am
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

Posted: Fri Jun 20, 2014 8:22 am
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;
}

Posted: Fri Jun 20, 2014 1:50 pm
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!)

AkelPad.MemRead, example?

Posted: Tue Nov 15, 2016 11:01 am
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]

Posted: Wed Dec 28, 2016 7:39 am
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);
}

Posted: Thu Dec 29, 2016 7:03 pm
by r0n
Thank you!!!

Posted: Thu Oct 26, 2017 12:17 pm
by julialbert
r0n wrote:Thank you!!!
Great post