var nDlgID = 2004; //IDD_FIND
var sDlgID = nDlgID.toString();

while (true)
{
  sDlgID = AkelPad.InputBox(AkelPad.GetMainWnd(), WScript.ScriptName, "Dialog box ID:", sDlgID);

  if (! sDlgID)
    break;

  nDlgID = parseInt(sDlgID);
  WScript.Echo(GetDialogTitleFromResource(nDlgID));
}

function GetDialogTitleFromResource(nDlgID)
{
  var oSys     = AkelPad.SystemFunction();
  var nLangID  = AkelPad.GetLangId();
  var lpBuffer = AkelPad.MemAlloc(260 * 2); //sizeof(MAX_PATH)
  var sString  = "";
  var hLangLib;

  if (AkelPad.SendMessage(AkelPad.GetMainWnd(), 1222 /*AKD_GETMAININFO*/, 52 /*MI_LANGMODULEW*/, lpBuffer))
    hLangLib = oSys.Call("Kernel32::GetModuleHandleW", AkelPad.GetAkelDir(3 /*ADTYPE_LANGS*/) + "\\" + AkelPad.MemRead(lpBuffer, 1 /*DT_UNICODE*/));
  else //internal language
    hLangLib = AkelPad.GetInstanceExe();

  AkelPad.MemFree(lpBuffer);

  var hRes      = oSys.Call("Kernel32::FindResourceExW", hLangLib, 5 /*RT_DIALOG*/, nDlgID, nLangID);
  var hResData  = oSys.Call("Kernel32::LoadResource", hLangLib, hRes);
  var lpPointer = oSys.Call("Kernel32::LockResource", hResData);
  var nSize     = oSys.Call("Kernel32::SizeofResource", hLangLib, hRes);

  if (nSize)
  {
    //pointer to menu
    if (AkelPad.MemRead(lpPointer + 2, 4 /*DT_WORD*/) == 0xFFFF) //DLGTEMPLATEEX
      lpPointer += 26;
    else //DLGTEMPLATE
      lpPointer += 18;

    //pointer to windowClass
    if (AkelPad.MemRead(lpPointer, 4 /*DT_WORD*/) == 0xFFFF)
      lpPointer += 4;
    else
      lpPointer += AkelPad.MemRead(lpPointer, 1 /*DT_UNICODE*/).length + 2;

    //pointer to title
    if (AkelPad.MemRead(lpPointer, 4 /*DT_WORD*/) == 0xFFFF)
      lpPointer += 4;
    else
      lpPointer += AkelPad.MemRead(lpPointer, 1 /*DT_UNICODE*/).length + 2;

    sString = AkelPad.MemRead(lpPointer, 1 /*DT_UNICODE*/);
  }

  return sString;
}
