AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Scripts collection
Goto page Previous  1, 2, 3 ... 14, 15, 16, 17, 18  Next
 
Post new topic   Reply to topic    AkelPad Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
KDJ



Joined: 06 Mar 2010
Posts: 1334
Location: Poland

PostPosted: Sat Mar 03, 2012 10:24 pm    Post subject: Reply with quote

Manager of files and NTFS streams - Part Three.
See next post.

FileAndStream_part3.js

Code:
function Rename()
{
  var nPan2 = Number(! nCurPan);
  var sOldName;
  var sNewName;
  var sCaption;

  if (! RenameAvailable())
    return;

  GetCurFile(nPan2);

  if (aCurWnd[nCurPan] == 0)
  {
    sOldName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    if (CurFileIsDir(nCurPan))
      sCaption = sTxtRenDir;
    else
      sCaption = sTxtRenFile;
  }
  else
  {
    sOldName = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
    sCaption = sTxtRenStr;
  }

  sNewName = GetFileName(sCaption, sOldName + "\n\n" + sTxtNewName, sOldName);

  if ((sNewName) && (sNewName != sOldName))
  {
    if (! IsDriveExists(aCurDrive[nCurPan]))
    {
      MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
      return;
    }

    if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
    {
      MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
      return;
    }

    //Rename file or directory
    if (aCurWnd[nCurPan] == 0)
    {
      //File or directory already exists
      if (GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sNewName))
      {
        if (IsDirExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sNewName))
          WarningBox(hWndDlg, sNewName + "\n\n" + sTxtDirExists, sCaption);
        else
          WarningBox(hWndDlg, sNewName + "\n\n" + sTxtFileExists, sCaption);

        FillFileList(nCurPan, sNewName, 0, 1);
      }
      else
      {
        if (RenameFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sOldName, 0, sNewName))
        {
          FillFileList(nCurPan, sNewName, 0, 1);
          if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path)
            RefreshPanel(nPan2);
        }
        else
          WarningBox(hWndDlg, sTxtRenFail, sCaption);
      }
    }

    //Rename stream
    else
    {
      if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sOldName))
      {
        ShowWaitWindow(1);

        if (RenameFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sOldName, sNewName))
        {
          ShowWaitWindow(0);

          FillStreamList(nCurPan, sNewName);
          if ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path) &&
              (aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nPan2][aCurDrive[nPan2]].File))
            RefreshStreamList(nPan2);
        }
        else
        {
          ShowWaitWindow(0);
          WarningBox(hWndDlg, sTxtRenFail, sCaption);
        }
      }
      else
        MessageNoStream(sOldName);
    }
  }
}

function RenameAvailable()
{
  GetCurFile(nCurPan);

  return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
         (((aCurWnd[nCurPan] == 0) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..")) ||
          ((aCurWnd[nCurPan] == 1) && aCurDir[nCurPan][aCurDrive[nCurPan]].Stream));
}

function OpenIn(nAppType, nAppIndex)
{
  var sAppName;
  var sAppPar;

  if (! OpenInAvailable(nAppType))
    return;

  if (nAppType == 0)
    sAppName = (nAppIndex == 1) ? sViewer : sViewer2;
  else if (nAppType == 1)
    sAppName = (nAppIndex == 1) ? sEditor : sEditor2;
  else if (nAppType == 3)
    sAppName = aFavorite[nAppIndex][1];
  else
  {
    nAppIndex = GetInternalAssocIndex();
    if (nAppIndex < 0)
      return;
    sAppName = aIntAssoc[nAppIndex][1];
  }

  sAppName = ExpandFileName(sAppName);

  if (! IsFileExists(sAppName))
  {
    if (nAppType == 4)
    {
      if (SetInternalAssoc(nAppIndex, 1))
      {
        nAppIndex = GetInternalAssocIndex();
        if (nAppIndex < 0)
          return;
        sAppName = aIntAssoc[nAppIndex][1];
      }
      else
        return;
    }
    else
    {
      if (SetExternalApp(nAppType, nAppIndex, 1))
      {
        if (nAppType == 0)
          sAppName = (nAppIndex == 1) ? sViewer : sViewer2;
        else if (nAppType == 1)
          sAppName = (nAppIndex == 1) ? sEditor : sEditor2;
        else
          sAppName = aFavorite[nAppIndex][1];
      }
      else
        return;
    }
    sAppName = ExpandFileName(sAppName);
  }

  if (! IsDriveExists(aCurDrive[nCurPan]))
  {
    MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
    return;
  }

  if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
  {
    MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
    return;
  }

  if (nAppType == 0)
    sAppPar = (nAppIndex == 1) ? sViewerPar : sViewerPar2;
  else if (nAppType == 1)
    sAppPar = (nAppIndex == 1) ? sEditorPar : sEditorPar2;
  else if (nAppType == 3)
    sAppPar = aFavorite[nAppIndex][2];
  else
    sAppPar = aIntAssoc[nAppIndex][2];

  if ((aCurWnd[nCurPan] == 0) || (! aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
    AkelPad.Exec(sAppName + ' ' + sAppPar + ' "' + aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + '"');
  else
  {
    if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
      AkelPad.Exec(sAppName + ' ' + sAppPar + ' "' + aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ':'  + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream +'"');
    else
      MessageNoStream(aCurDir[nCurPan][aCurDrive[nCurPan]].Stream);
  }
}

function OpenInAvailable(nAppType)
{
  GetCurFile(nCurPan);

  if (nAppType == 4) //open in internally associated
    return (aCurWnd[nCurPan] == 0) &&
           aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
           (! CurFileIsDir(nCurPan)) &&
           (aCurDir[nCurPan][aCurDrive[nCurPan]].File.indexOf(".") >= 0);
  else
    return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
           (((aCurWnd[nCurPan] == 0) && (! CurFileIsDir(nCurPan))) ||
            ((aCurWnd[nCurPan] == 1) && GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], GetCurSelLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]), 1)));
}

function GetInternalAssocIndex()
{
  var sExt = aCurDir[nCurPan][aCurDrive[nCurPan]].File.substr(aCurDir[nCurPan][aCurDrive[nCurPan]].File.lastIndexOf(".") + 1);
  var i;

  while (true)
  {
    for (i = 0; i < aIntAssoc.length; ++i)
    {
      if (aIntAssoc[i][0].toUpperCase().indexOf(sExt.toUpperCase()) >= 0)
        return i;
    }

    if (! SetInternalAssoc(-1, 0, sExt))
      break;
  }

  return -1;
}

function Copy(bMove, bOnePan)
{
  var nToPan = (bOnePan) ? nCurPan : Number(! nCurPan);
  var sTo;
  var sPath;
  var sName;
  var sCaption;
  var sFail;

  if (! CopyAvailable(bOnePan))
    return;

  if (aCurWnd[nCurPan] == 0)
  {
    sName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    if (CurFileIsDir(nCurPan))
    {
      sCaption = bMove ? sTxtMovDir : sTxtCopDir;
      sTo      = sTxtTo;
      sPath    = aCurDir[nToPan][aCurDrive[nToPan]].Path;
    }
    else
    {
      sCaption = bMove ? sTxtMovFile : sTxtCopFile;
      if (aCurWnd[nToPan] == 0)
      {
        sTo   = sTxtToFile;
        sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path;
      }
      else
      {
        sTo   = sTxtToStream;
        sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File + ":";
      }
    }
  }
  else
  {
    sName    = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
    sCaption = bMove ? sTxtMovStr : sTxtCopStr;
    if (aCurWnd[nToPan] == 0)
    {
      sTo   = sTxtToFile;
      sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path;
    }
    else
    {
      sTo   = sTxtToStream;
      sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File + ":";
    }
  }

  //Move file to its own stream
  if (bMove &&
      (aCurWnd[nCurPan] == 0) &&
      (aCurWnd[nToPan] == 1) &&
      (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path) &&
      (aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nToPan][aCurDrive[nToPan]].File))
  {
    WarningBox(hWndDlg, sTxtFileToStr, sCaption);
    return;
  }

  sFail = bMove ? sTxtMovFail : sTxtCopFail;
  sName = GetFileName(sCaption, sName + "\n\n" + sTo + "\n\n" + sPath, sName);

  if (sName)
  {
    if (! IsDriveExists(aCurDrive[nCurPan]))
    {
      MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
      return;
    }

    //No source file/dir
    if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
    {
      MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
      return;
    }

    //No source stream
    if ((aCurWnd[nCurPan] == 1) &&
        (! IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)))
    {
      MessageNoStream(sName);
      return;
    }

    if (! IsDriveExists(aCurDrive[nToPan]))
    {
      MessageNoDrive(nToPan, aCurDrive[nToPan]);
      return;
    }

    //No parent of target dir
    if (! IsDirExists(aCurDir[nToPan][aCurDrive[nToPan]].Path))
    {
      MessageNoFile(nToPan, 1, 1);
      return;
    }

    //Copy/move to dir/file
    if (aCurWnd[nToPan] == 0)
    {
      //The same dir/file
      if ((aCurWnd[nCurPan] == 0) &&
          (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == sPath) &&
          (aCurDir[nCurPan][aCurDrive[nCurPan]].File == sName))
      {
        if (! bOnePan)
          FillFileList(nToPan, sName, 0, 1);
        return;
      }

      //Directory to its own subdirectory
      if ((aCurWnd[nCurPan] == 0) && CurFileIsDir(nCurPan) &&
          ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName) == sPath.substr(0, (aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName).length)))
      {
        WarningBox(hWndDlg, sPath + sName + "\n\n" + sTxtDirToSubdir, sCaption);
        return;
      }

      //Target dir/file already exists
      if (GetFileAttr(sPath + sName))
      {
        if (IsDirExists(sPath + sName))
        {
          WarningBox(hWndDlg, sPath + sName + "\n\n" + sTxtDirExists, sCaption);
          FillFileList(nToPan, sName);
          return;
        }

        if ((aCurWnd[nCurPan] == 0) && CurFileIsDir(nCurPan))
        {
          WarningBox(hWndDlg, sPath + sName + "\n\n" + sTxtFileExists, sCaption);
          FillFileList(nToPan, sName, 0, 1);
          return;
        }

        if (! QuestionBox(hWndDlg, sPath + sName + "\n\n" + sTxtWantReplace, sCaption))
        {
          FillFileList(nToPan, sName, 0, 1);
          return;
        }
      }

      ShowWaitWindow(1);

      if (! CopyFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File,
                     (aCurWnd[nCurPan] == 0) ? 0 : aCurDir[nCurPan][aCurDrive[nCurPan]].Stream,
                     sPath + sName,
                     0,
                     bMove))
      {
        ShowWaitWindow(0);
        WarningBox(hWndDlg, sName + "\n\n" + sFail, sCaption);
      }

      ShowWaitWindow(0);

      if (GetFileAttr(sPath + sName))
      {
        FillFileList(nToPan, sName, 0, 1);
        if ((! bOnePan) && (bMove || (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == sPath)))
          RefreshPanel(nCurPan);
      }
    }

    //Copy/move to stream
    else if (aCurWnd[nToPan] == 1)
    {
      //The same stream
      if ((aCurWnd[nCurPan] == 1) &&
          (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path) &&
          (aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nToPan][aCurDrive[nToPan]].File) &&
          (aCurDir[nCurPan][aCurDrive[nCurPan]].Stream == sName))
      {
        if (! bOnePan)
          FillStreamList(nToPan, sName);
        return;
      }

      //No target dir/file
      if (! GetFileAttr(aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File))
      {
        MessageNoFile(nToPan, CurFileIsDir(nToPan));
        return;
      }

      //Target stream already exists
      if (IsStreamExists(aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File, sName))
      {
        if (! QuestionBox(hWndDlg, sPath + sName + "\n\n" + sTxtWantReplace, sCaption))
        {
          FillStreamList(nToPan, sName);
          return;
        }
      }

      ShowWaitWindow(1);

      if (CopyFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File,
          (aCurWnd[nCurPan] == 0) ? 0 : aCurDir[nCurPan][aCurDrive[nCurPan]].Stream,
          aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File,
          sName,
          bMove))
      {
        ShowWaitWindow(0);
        FillStreamList(nToPan, sName);

        if (! bOnePan)
        {
          if (bMove && (aCurWnd[nCurPan] == 0))
          {
            RefreshPanel(nCurPan);
            if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path)
              RefreshPanel(nToPan);
          }
          else if (bMove ||
                   ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path) &&
                    (aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nToPan][aCurDrive[nToPan]].File)))
            RefreshStreamList(nCurPan);
        }
      }
      else
      {
        ShowWaitWindow(0);
        WarningBox(hWndDlg, sName + "\n\n" + sFail, sCaption);
      }
    }
  }
}

function CopyAvailable(bOnePan)
{
  var nToPan = (bOnePan) ? nCurPan : Number(! nCurPan);

  GetCurFile(nCurPan);
  GetCurFile(nToPan);

  if (bOnePan)
    return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
           (((aCurWnd[nCurPan] == 0) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..")) ||
            ((aCurWnd[nCurPan] == 1) && aCurDir[nCurPan][aCurDrive[nCurPan]].Stream));

  return ! ((! aCurDir[nCurPan][aCurDrive[nCurPan]].File) ||
            (aCurDir[nCurPan][aCurDrive[nCurPan]].File == "..") ||
            ((aCurWnd[nCurPan] == 0) && (aCurWnd[nToPan] == 1) && CurFileIsDir(nCurPan)) ||
            ((aCurWnd[nCurPan] == 1) && (! aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)) ||
            ((aCurWnd[nToPan]  == 1) && (! IsSupportStreams(aCurDrive[nToPan]))) ||
            ((aCurWnd[nToPan]  == 1) && (! aCurDir[nToPan][aCurDrive[nToPan]].File)) ||
            ((aCurWnd[nToPan]  == 1) && (aCurDir[nToPan][aCurDrive[nToPan]].File == "..")));
}

function Create(bDir)
{
  var nPan2 = Number(! nCurPan);
  var sName;
  var sCaption;

  GetCurFile(nCurPan);
  GetCurFile(nPan2);

  //Create file or directory
  if (aCurWnd[nCurPan] == 0)
  {
    if (bDir)
      sCaption = sTxtCreDir;
    else
      sCaption = sTxtCreFile;

    sName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    if (sName == "..")
      sName = "";

    sName = GetFileName(sCaption, sTxtInpName, sName);
    if (sName)
    {
      if (! IsDriveExists(aCurDrive[nCurPan]))
      {
        MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
        return;
      }

      //No parent dir
      if (! IsDirExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path))
      {
        MessageNoFile(nCurPan, 1, 1);
        return;
      }

      //File or directory already exists
      if (GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName))
      {
        if (IsDirExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName))
          WarningBox(hWndDlg, sName + "\n\n" + sTxtDirExists, sCaption);
        else
          WarningBox(hWndDlg, sName + "\n\n" + sTxtFileExists, sCaption);

        FillFileList(nCurPan, sName, 0, 1);
      }
      else
      {
        if ((bDir && oSys.Call("Kernel32::CreateDirectoryW", aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName, 0)) ||
            ((! bDir) && CreateFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName)))
        {
          FillFileList(nCurPan, sName, 0, 1);
          if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path)
            RefreshPanel(nPan2);
        }
        else
          WarningBox(hWndDlg, sName + "\n\n" + sTxtCreFail, sCaption);
      }
    }
  }

  //Create stream
  else
  {
    if (! CreateStreamAvailable())
      return;

    sName = GetFileName(sTxtCreStr, sTxtInpName, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream);
    if (sName)
    {
      if (! IsDriveExists(aCurDrive[nCurPan]))
      {
        MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
        return;
      }

      if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
      {
        MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
        return;
      }

      if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
      {
        WarningBox(hWndDlg, sName + "\n\n" + sTxtStrExists, sTxtCreStr);
        FillStreamList(nCurPan, sName);
      }
      else
      {
        if (CreateFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
        {
          FillStreamList(nCurPan, sName);
          if ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path) &&
              (aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nPan2][aCurDrive[nPan2]].File))
            RefreshStreamList(nPan2);
        }
        else
          WarningBox(hWndDlg, sName + "\n\n" + sTxtCreFail, sTxtCreStr);
      }
    }
  }
}

function CreateStreamAvailable()
{
  GetCurFile(nCurPan);

  return (aCurWnd[nCurPan] == 1) &&
         IsSupportStreams(aCurDrive[nCurPan]) &&
         aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
         (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..");
}

function Delete(bRecBin)
{
  var nPan2 = Number(! nCurPan);
  var sName;
  var sCaption;

  if (! DeleteAvailable())
    return;

  GetCurFile(nPan2);

  if (aCurWnd[nCurPan] == 0)
  {
    sName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    if (CurFileIsDir(nCurPan))
      sCaption = bRecBin ? sTxtDelDirToBin : sTxtDelDir;
    else
      sCaption = bRecBin ? sTxtDelFileToBin : sTxtDelFile;
  }
  else
  {
    sName    = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
    sCaption = sTxtDelStr;
  }

  if (QuestionBox(hWndDlg, sName + "\n\n" + sTxtWantDelete, sCaption))
  {
    if (! IsDriveExists(aCurDrive[nCurPan]))
    {
      MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
      return;
    }

    if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
    {
      MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
      return;
    }

    //Delete file or directory
    if (aCurWnd[nCurPan] == 0)
    {
      if (DeleteFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName, null, bRecBin))
      {
        RefreshPanel(nCurPan);
        if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path)
          RefreshPanel(nPan2);
      }
      else
        WarningBox(hWndDlg, sName + "\n\n" + sTxtDelFail, sCaption);
    }

    //Delete stream
    else
    {
      if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
      {
        if (DeleteFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
        {
          RefreshStreamList(nCurPan);
          if ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path) &&
              (aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nPan2][aCurDrive[nPan2]].File))
            RefreshStreamList(nPan2);
        }
        else
          WarningBox(hWndDlg, sName + "\n\n" + sTxtDelFail, sCaption);
      }
      else
        MessageNoStream(sName);
    }
  }
}

function DeleteAvailable()
{
  GetCurFile(nCurPan);

  return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
         (((aCurWnd[nCurPan] == 0) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..")) ||
          ((aCurWnd[nCurPan] == 1) && aCurDir[nCurPan][aCurDrive[nCurPan]].Stream));
}

function Compare(nAppIndex)
{
  var nPan2    = Number(! nCurPan);
  var sAppName = ExpandFileName((nAppIndex == 1) ? sComparer : sComparer2);
  var sAppPar;
  var sFile1;
  var sFile2;

  if (! CompareAvailable())
    return;

  if (! IsFileExists(sAppName))
  {
    if (SetExternalApp(2, nAppIndex, 1))
      sAppName = ExpandFileName((nAppIndex == 1) ? sComparer : sComparer2);
    else
      return;
  }

  if (! IsDriveExists(aCurDrive[nCurPan]))
  {
    MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
    return;
  }
  if (! IsDriveExists(aCurDrive[nPan2]))
  {
    MessageNoDrive(nPan2, aCurDrive[nPan2]);
    return;
  }

  if (aCurDir[nCurPan][aCurDrive[nCurPan]].File == "..")
    sFile1 = aCurDir[nCurPan][aCurDrive[nCurPan]].Path.slice(0, -1);
  else
    sFile1 = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File;

  if (! GetFileAttr(sFile1))
  {
    MessageNoFile(nCurPan, CurFileIsDir(nCurPan), (aCurDir[nCurPan][aCurDrive[nCurPan]].File == ".."));
    return;
  }

  if (aCurWnd[nCurPan] == 1)
  {
    if (aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)
    {
      if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
        sFile1 = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
      else
      {
        MessageNoStream(aCurDir[nCurPan][aCurDrive[nCurPan]].Stream);
        return;
      }
    }
  }

  if (aCurDir[nPan2][aCurDrive[nPan2]].File == "..")
    sFile2 = aCurDir[nPan2][aCurDrive[nPan2]].Path.slice(0, -1);
  else
    sFile2 = aCurDir[nPan2][aCurDrive[nPan2]].Path + aCurDir[nPan2][aCurDrive[nPan2]].File;

  if (! GetFileAttr(sFile2))
  {
    MessageNoFile(nPan2, CurFileIsDir(nPan2), (aCurDir[nPan2][aCurDrive[nPan2n]].File == ".."));
    return;
  }

  if (aCurWnd[nPan2] == 1)
  {
    if (aCurDir[nPan2][aCurDrive[nPan2]].Stream)
    {
      if (IsStreamExists(aCurDir[nPan2][aCurDrive[nPan2]].Path + aCurDir[nPan2][aCurDrive[nPan2]].File, aCurDir[nPan2][aCurDrive[nPan2]].Stream))
        sFile2 = aCurDir[nPan2][aCurDrive[nPan2]].Path + aCurDir[nPan2][aCurDrive[nPan2]].File + ":" + aCurDir[nPan2][aCurDrive[nPan2]].Stream;
      else
      {
        MessageNoStream(aCurDir[nPan2][aCurDrive[nPan2]].Stream);
        return;
      }
    }
  }

  sAppPar = (nAppIndex == 1) ? sComparerPar : sComparerPar2;

  AkelPad.Exec(sAppName + ' ' + sAppPar + ' "' + sFile1 + '" "' + sFile2 + '"');
}

function CompareAvailable()
{
  var nPan2 = Number(! nCurPan);

  GetCurFile(nCurPan);
  GetCurFile(nPan2);

  return ! ((! aCurDir[nCurPan][aCurDrive[nCurPan]].File) || (! aCurDir[nPan2][aCurDrive[nPan2]].File) ||
            ((aCurWnd[nCurPan] + aCurWnd[nPan2] == 0) && (CurFileIsDir(nCurPan) != CurFileIsDir(nPan2))) ||
            ((aCurWnd[nCurPan] == 0) && (aCurWnd[nPan2] == 1) && CurFileIsDir(nCurPan)) ||
            ((aCurWnd[nCurPan] == 1) && (aCurWnd[nPan2] == 0) && CurFileIsDir(nPan2)) ||
            ((aCurWnd[nCurPan] == 1) && (! GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], GetCurSelLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]), 1))) ||
            ((aCurWnd[nPan2] == 1) && (! GetTextLV(aWnd[IDSTREAMLV0 + nPan2][HWND], GetCurSelLV(aWnd[IDSTREAMLV0 + nPan2][HWND]), 1))));
}

function CopyNameToCB(nAction)
{
  var sText;

  GetCurFile(nCurPan);

  if (aCurDir[nCurPan][aCurDrive[nCurPan]].File)
  {
    if (nAction == 1) //File
      sText = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    else if (nAction == 3) //Path\File
      sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    else if (nAction == 5) //Path\
      sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path;
    else if (aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)
    {
      if (nAction == 4) //Stream
        sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
      else if (nAction == 6) //Path\File:Stream
        sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
      else if (nAction == 7) //File:Stream
        sText = aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
    }

    if (sText)
      AkelPad.SetClipboardText(sText);
  }
}

function CopyListToCB(nAction)
{
  var nNameLen = 0;
  var nTimeLen = 0;
  var nFirst   = 0;
  var sText;
  var i;

  GetCurFile(nCurPan);

  if (aCurDir[nCurPan][aCurDrive[nCurPan]].File)
  {
    //Files
    if (nAction == 0)
    {
      if (GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], 0, 0) == "..")
        nFirst = 1;

      if ((bColSize) || (bColTime) || (bColAttr))
      {
        for (i = nFirst; i < GetItemCountLV(aWnd[IDFILELV0 + nCurPan][HWND]); ++i)
        {
          if (nNameLen < GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 0).length)
            nNameLen = GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 0).length;
          if (nTimeLen < GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 2).length)
            nTimeLen = GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 2).length;
        }
      }

      if (nFirst < GetItemCountLV(aWnd[IDFILELV0 + nCurPan][HWND]))
        sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + "\n";

      for (i = nFirst; i < GetItemCountLV(aWnd[IDFILELV0 + nCurPan][HWND]); ++i)
      {
        sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 0), nNameLen);
        if (bColSize)
          sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 1), 15, "L");
        if (bColTime)
          sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 2), nTimeLen + 3, "L");
        if (bColAttr)
          sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 3), 7, "L");
        sText += "\n";
      }
    }

    //Steams
    else if (IsSupportStreams(aCurDrive[nCurPan]) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..") &&
             ((! CurFileIsDir(nCurPan)) || aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
    {
      if (bColSize)
      {
        for (i = 0; i < GetItemCountLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]); ++i)
        {
          if (nNameLen < GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 0).length)
            nNameLen = GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 0).length;
        }
      }

      sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + "\n";

      for (i = 0; i < GetItemCountLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]); ++i)
      {
        sText += Pad(GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 0), nNameLen);
        if (bColSize)
          sText += Pad(GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 1), 15, "L");
        sText += "\n";
      }
    }

    if (sText)
      AkelPad.SetClipboardText(sText);
  }
}

function Pad(sString, nLen, sType, sChar)
{
  var i = 0;

  if (! sType) sType = "R";
  if (! sChar) sChar = " ";

  if (sType == "R")
  {
    while (sString.length < nLen)
      sString += sChar;
  }
  else if (sType == "L")
  {
    while (sString.length < nLen)
      sString = sChar + sString;
  }

  return sString;
}

function Properties()
{
  var sFile;

  if (! PropertiesAvailable())
    return;

  if (! IsDriveExists(aCurDrive[nCurPan]))
  {
    MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
    return;
  }

  if (aCurDir[nCurPan][aCurDrive[nCurPan]].File == "..")
    sFile = aCurDir[nCurPan][aCurDrive[nCurPan]].Path.slice(0, -1);
  else
    sFile = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File;

  if (! GetFileAttr(sFile))
  {
    MessageNoFile(nCurPan, CurFileIsDir(nCurPan), (aCurDir[nCurPan][aCurDrive[nCurPan]].File == ".."));
    return;
  }

  if (! FilePropertiesDialog(sFile, hWndDlg))
    WarningBox(hWndDlg, sTxtNoFileProp, sScriptName);
}

function PropertiesAvailable()
{
  GetCurFile(nCurPan);

  return Boolean(aCurDir[nCurPan][aCurDrive[nCurPan]].File);
}

function FavoriteFolders(nPan)
{
  var MF_STRING    = 0x0000;
  var MF_GRAYED    = 0x0001;
  var MF_CHECKED   = 0x0008;
  var MF_POPUP     = 0x0010;
  var MF_SEPARATOR = 0x0800;
  var hMenu01 = oSys.Call("User32::CreatePopupMenu");
  var hMenu03 = oSys.Call("User32::CreatePopupMenu");
  var hMenu04 = oSys.Call("User32::CreatePopupMenu");
  var hMenu   = oSys.Call("User32::CreatePopupMenu");
  var oRect   = {};
  var bSet    = true;
  var nSel    = -1;
  var nFlag;
  var i;

  for (i = 0; i < aFavoriteFolder.length; ++i)
  {
    if (ExpandFileName(aFavoriteFolder[i][1]).toUpperCase() == aCurDir[nPan][aCurDrive[nPan]].Path.toUpperCase())
    {
      nFlag = MF_CHECKED;
      nSel  = i;
    }
    else
      nFlag = MF_STRING;

    oSys.Call("User32::AppendMenuW", hMenu01, nFlag, 0x0101 + i, aFavoriteFolder[i][0]);
    oSys.Call("User32::AppendMenuW", hMenu03, nFlag, 0x0301 + i, aFavoriteFolder[i][0]);
    oSys.Call("User32::AppendMenuW", hMenu04, nFlag, 0x0401 + i, aFavoriteFolder[i][0]);
  }

  oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_POPUP : MF_GRAYED, hMenu01, sTxtGoToFavFold);
  oSys.Call("User32::AppendMenuW", hMenu, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu, (aFavoriteFolder.length < 0xFF) ? MF_STRING : MF_GRAYED, 0x0200, sTxtAddFavorite);
  oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_POPUP : MF_GRAYED, hMenu03, sTxtModFavorite);
  oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_POPUP : MF_GRAYED, hMenu04, sTxtDelFavorite);
  oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_STRING : MF_GRAYED, 0x0500, sTxtCleFavorite);

  GetWindowPos(aWnd[IDFAVFOLDB0 + nPan][HWND], oRect);

  nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, 0x0180 /*TPM_NONOTIFY|TPM_RETURNCMD*/, oRect.X + oRect.W, oRect.Y, 0, hWndDlg, 0);

  oSys.Call("User32::DestroyMenu", hMenu01);
  oSys.Call("User32::DestroyMenu", hMenu03);
  oSys.Call("User32::DestroyMenu", hMenu04);
  oSys.Call("User32::DestroyMenu", hMenu);

  if ((nCmd >= 0x0101) && (nCmd <= 0x01FF))
  {
    if (nCmd - 0x0101 != nSel)
    {
      if (! IsDirExists(ExpandFileName(aFavoriteFolder[nCmd - 0x0101][1])))
        bSet = SetFavoriteFolder(nPan, nCmd - 0x0101, 1);
      if (bSet)
        ChangeDir(nPan, aFavoriteFolder[nCmd - 0x0101][1]);
    }
  }
  else if (nCmd == 0x0200)
    SetFavoriteFolder(nPan, -1); //add favorite
  else if ((nCmd >= 0x0301) && (nCmd <= 0x03FF))
    SetFavoriteFolder(nPan, nCmd - 0x0301); //modify favorite
  else if ((nCmd >= 0x0401) && (nCmd <= 0x04FF))
    RemoveFavoriteFolder(nCmd - 0x0401);
  else if (nCmd == 0x0500)
  {
    if (QuestionBox(hWndDlg, sTxtWantCleFavFo, sTxtDirectory + ": " + sTxtCleFavorite, 1))
      aFavoriteFolder = [];
  }
}

function SetFavoriteFolder(nPan, nIndex, nFocus)
{
  var bSet     = false;
  var sCaption = sTxtDirectory + ": ";
  var aDir     = new Array(2);

  if (nIndex < 0) //add favorite
  {
    sCaption += sTxtAddFavorite;
    aDir[1]   = aCurDir[nPan][aCurDrive[nPan]].Path;
    aDir[0]   = aDir[1].slice(0, -1);
    aDir[0]   = ((aDir[0].length > 2) ? aDir[0].substr(0, 2) : "") + aDir[0].substr(aDir[0].lastIndexOf("\\") + 1);
  }
  else //modify favorite
  {
    sCaption += sTxtModFavorite;
    aDir      = aFavoriteFolder[nIndex];
  }

  aDir = InputBox(hWndDlg, sCaption, [sTxtDispName + ":", sTxtPath + " (%a - " + sTxtAkelDir + ", %WinDir% - " + sTxtEnvVar + "):"], aDir, nFocus, "CheckInputPath", nIndex);

  if (aDir)
  {
    if (aDir[1].slice(-1) != "\\")
      aDir[1] += "\\";

    if (nIndex < 0)
      aFavoriteFolder.push([aDir[0], aDir[1]]);
    else
      aFavoriteFolder[nIndex] = [aDir[0], aDir[1]];

    aFavoriteFolder.sort(
      function(aA, aB)
      {
        return oSys.Call("Kernel32::lstrcmpiW", aA[0], aB[0]);
      });

    bSet = true;
  }

  return bSet;
}

function CheckInputPath(hWnd, aDir, nIndex)
{
  var sPath;

  if (! aDir[0])
  {
    WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtDispName, sScriptName);
    return 0;
  }

  if (IsNameInArray(aFavoriteFolder, aDir[0], nIndex))
  {
    WarningBox(hWnd, aDir[0] + "\n\n" + sTxtNameExists, sScriptName);
    return 0;
  }

  if (! aDir[1])
  {
    WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtPath, sScriptName);
    return 1;
  }

  sPath = ExpandFileName(aDir[1] + ((aDir[1].slice(-1) != "\\") ? "\\" : ""));
  if (! IsDirExists(sPath))
  {
    WarningBox(hWnd, sPath + "\n\n" + sTxtDirNoExists, sScriptName);
    return 1;
  }

  return -1;
}

function IsNameInArray(aArray, sName, nIndex)
{
  for (var i = 0; i < aArray.length; ++i)
  {
    if ((aArray[i][0] == sName) && (i != nIndex))
      return true;
  }

  return false;
}

function RemoveFavoriteFolder(nIndex)
{
  if (QuestionBox(hWndDlg, aFavoriteFolder[nIndex][0] + "\n" + aFavoriteFolder[nIndex][1] + "\n\n" + sTxtWantDelFav, sTxtDirectory + ": " + sTxtDelFavorite))
    aFavoriteFolder.splice(nIndex, 1);
}

function SpecialFolders(nPan)
{
  var aFolder = [];
  var oRect   = {};
  var hMenu   = oSys.Call("User32::CreatePopupMenu");
  var nSel    = -1;
  var nFlag;
  var nCmd;
  var i;

  for (i = 0; i < 63; ++i)
  {
    if (oSys.Call("Shell32::SHGetSpecialFolderPathW", 0, lpBuffer, i, 0))
      aFolder.push(AkelPad.MemRead(lpBuffer, _TSTR) + "\\");
  }

  aFolder.sort(function(sA, sB)
               {
                 return oSys.Call("Kernel32::lstrcmpiW", sA, sB);
               } );

  for (i = 0; i < aFolder.length; ++i)
  {
    if ((i == 0) || (aFolder[i] != aFolder[i - 1]))
    {
      if (aFolder[i].toUpperCase() == aCurDir[nPan][aCurDrive[nPan]].Path.toUpperCase())
      {
        nFlag = 0x0008; //MF_CHECKED
        nSel  = i;
      }
      else
        nFlag = 0x0000; //MF_STRING

      oSys.Call("User32::AppendMenuW", hMenu, nFlag, i + 1, aFolder[i]);
    }
  }

  GetWindowPos(aWnd[IDSPECFOLDB0 + nPan][HWND], oRect);
  nFlag = 0x0180; //TPM_RETURNCMD|TPM_NONOTIFY

  if (nPan == 0)
    oRect.X += oRect.W;
  else
    nFlag |= 0x0008; //TPM_RIGHTALIGN

  nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, nFlag, oRect.X, oRect.Y, 0, hWndDlg, 0);
  oSys.Call("User32::DestroyMenu", hMenu);

  if (nCmd && (--nCmd != nSel))
  {
    if (IsDirExists(aFolder[nCmd]))
      ChangeDir(nPan, aFolder[nCmd]);
    else
      WarningBox(hWndDlg, aFolder[nCmd] + "\n\n" + sTxtDirNoExists, sScriptName);
  }
}

function History(nPan)
{
  var MF_STRING    = 0x0000;
  var MF_GRAYED    = 0x0001;
  var MF_CHECKED   = 0x0008;
  var MF_SEPARATOR = 0x0800;
  var hMenu = oSys.Call("User32::CreatePopupMenu");
  var nFlag = 0x0180; //TPM_RETURNCMD|TPM_NONOTIFY
  var oRect = {};
  var i;

  GetWindowPos(aWnd[IDHISTORYB0 + nPan][HWND], oRect);

  if (nPan == 0)
    oRect.X += oRect.W;
  else
    nFlag |= 0x0008; //TPM_RIGHTALIGN

  for (i = aHistory[nPan].length - 1; i >= 0; --i)
  {
    if ((i != aCurHist[nPan]) && (! IsDirExists(aHistory[nPan][i][0])))
    {
      aHistory[nPan].splice(i, 1);
      if (i < aCurHist[nPan])
        --aCurHist[nPan];
    }
  }

  for (i = 0; i < aHistory[nPan].length; ++i)
    oSys.Call("User32::AppendMenuW", hMenu, (i == aCurHist[nPan]) ? MF_CHECKED : MF_STRING, i + 1, aHistory[nPan][i][0]);

  oSys.Call("User32::AppendMenuW", hMenu, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu, (aHistory.length > 1) ? MF_STRING : MF_GRAYED, nHistMax + 1, sTxtCleHistory);
  oSys.Call("User32::AppendMenuW", hMenu, bSaveHist ? MF_CHECKED : MF_STRING, nHistMax + 2, sTxtSaveHistory);

  nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, nFlag, oRect.X, oRect.Y, 0, hWndDlg, 0);
  oSys.Call("User32::DestroyMenu", hMenu);

  if ((nCmd > 0) && (nCmd <= nHistMax))
  {
    if (--nCmd != aCurHist[nPan])
    {
      if (IsDirExists(aHistory[nPan][nCmd][0]))
        ChangeDirFromHistory(nPan, nCmd);
      else
        WarningBox(hWndDlg, aHistory[nPan][nCmd][0] + "\n\n" + sTxtDirNoExists, sScriptName);
    }
  }
  else if (nCmd == nHistMax + 1)
  {
    aCurHist[nPan] = 0;
    aHistory[nPan] = [[aCurDir[nPan][aCurDrive[nPan]].Path, "", ""]];
  }
  else if (nCmd == nHistMax + 2)
    bSaveHist = ! bSaveHist;
}


Last edited by KDJ on Sat Apr 12, 2014 9:55 pm; edited 16 times in total
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1334
Location: Poland

PostPosted: Sat Mar 03, 2012 10:27 pm    Post subject: Reply with quote

Manager of files and NTFS streams - Part Four.
Language files - see next post.

FileAndStream_part4.js

Code:
function CheckHistory()
{
  for (var i = 0; i <= 1; ++i)
  {
    if (aHistory[i].length)
    {
      if (aCurHist[i] >= aHistory[i].length)
        aCurHist[i] = aHistory[i].length - 1;

      if (aHistory[i][aCurHist[i]][0] != aCurDir[i][aCurDrive[i]].Path)
      {
        aHistory[i].push([aCurDir[i][aCurDrive[i]].Path, "", ""]);
        aCurHist[i] = aHistory[i].length - 1;
      }

      if (aHistory[i].length > nHistMax)
      {
        if (aCurHist[i] < nHistMax)
          aHistory[i].length = nHistMax;
        else
        {
          aHistory[i].length = aCurHist[i] + 1;
          aHistory[i].splice(0, aCurHist[i] + 1 - nHistMax);
          aCurHist[i] = nHistMax - 1;
        }
      }
    }
    else
    {
      aCurHist[i] = 0;
      aHistory[i] = [[aCurDir[i][aCurDrive[i]].Path, "", ""]];
    }
  }
}

function AddHistory(nPan, sPath)
{
  aHistory[nPan].length = aCurHist[nPan] + 1;
  aHistory[nPan].push([sPath, "", ""]);

  if (aHistory[nPan].length > nHistMax)
    aHistory[nPan].shift();

  aCurHist[nPan] = aHistory[nPan].length - 1;
}

function SetInternalAssoc(nIndex, nFocus, sExt)
{
  var bSet     = false;
  var sCaption;
  var aAssoc;

  if (nIndex < 0) //add association
  {
    GetCurFile(nCurPan);
    sCaption = sTxtAddAssoc;
    aAssoc   = [sExt, aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, ""];
  }
  else //modify association
  {
    sCaption = sTxtModAssoc;
    aAssoc   = aIntAssoc[nIndex];
  }

  aAssoc = InputBox(hWndDlg, sCaption, [sTxtFileExtSep + ":", sTxtFullName + " (%a - " + sTxtAkelDir + ", %WinDir% - " + sTxtEnvVar + "):", sTxtAddPar], aAssoc, nFocus, "CheckInputInternalAssoc", nIndex);

  if (aAssoc)
  {
    aAssoc[0] = DelRedundantChars(aAssoc[0]).split(",");

    aAssoc[0].sort(
      function(sA, sB)
      {
        return oSys.Call("Kernel32::lstrcmpiW", sA, sB);
      });

    aAssoc[0] = aAssoc[0].join();

    if (nIndex < 0)
      aIntAssoc.push([aAssoc[0], aAssoc[1], aAssoc[2]]);
    else
      aIntAssoc[nIndex] = [aAssoc[0], aAssoc[1], aAssoc[2]];

    aIntAssoc.sort(
      function(aA, aB)
      {
        return oSys.Call("Kernel32::lstrcmpiW", aA[0], aB[0]);
      });

    bSet = true;
  }

  return bSet;
}

function DelRedundantChars(sText)
{
  sText = sText.replace(/^[,\s]+|\s+|[,\s]+$/, "");
  return sText.replace(/,+/, ",");
}

function CheckInputInternalAssoc(hWnd, aAssoc, nIndex)
{
  var sAppName;

  aAssoc[0] = DelRedundantChars(aAssoc[0]);

  if (! aAssoc[0])
  {
    WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtFileExtSep, sScriptName);
    return 0;
  }

  if ((typeof nIndex == "number") && (IsInternalAssocExists(hWnd, aAssoc[0], nIndex)))
    return 0;

  if (! aAssoc[1])
  {
    WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtFullName, sScriptName);
    return 1;
  }

  sAppName = ExpandFileName(aAssoc[1]);
  if (! IsFileExists(sAppName))
  {
    WarningBox(hWnd, sAppName + "\n\n" + sTxtFileNoExists, sScriptName);
    return 1;
  }

  return -1;
}

function IsInternalAssocExists(hWnd, sText, nIndex)
{
  var aExt = sText.split(",");
  var i, n;

  for (i = 0; i < aExt.length; ++i)
  {
    for (n = 0; n < aIntAssoc.length; ++n)
    {
      if ((aIntAssoc[n][0].toUpperCase().indexOf(aExt[i].toUpperCase()) >= 0) && (n != nIndex))
      {
        WarningBox(hWnd, aExt[i] + "\n\n" + sTxtAssocExists, sScriptName);
        return true;
      }
    }
  }

  return false;
}

function RemoveInternalAssoc(nIndex)
{
  if (QuestionBox(hWndDlg, aIntAssoc[nIndex][0] + "\n" + aIntAssoc[nIndex][1] + "\n\n" + sTxtWantDelAssoc, sTxtDelAssoc))
    aIntAssoc.splice(nIndex, 1);
}

function SetExternalApp(nAppType, nAppIndex, nFocus)
{
  var bSet = false;
  var sCaption;
  var aApp;

  if (nAppType == 0)
  {
    sCaption = sTxtSetViewer + " " + nAppIndex;
    aApp     = (nAppIndex == 1) ? [sViewerName, sViewer, sViewerPar] : [sViewerName2, sViewer2, sViewerPar2];
  }
  else if (nAppType == 1)
  {
    sCaption = sTxtSetEditor + " " + nAppIndex;
    aApp     = (nAppIndex == 1) ? [sEditorName, sEditor, sEditorPar] : [sEditorName2, sEditor2, sEditorPar2];
  }
  else if (nAppType == 2)
  {
    sCaption = sTxtSetComparer + " " + nAppIndex;
    aApp     = (nAppIndex == 1) ? [sComparerName, sComparer, sComparerPar] : [sComparerName2, sComparer2, sComparerPar2];
  }
  else
  {
    if (nAppIndex < 0) //add favorite
    {
      sCaption = sTxtApplications + ": " + sTxtAddFavorite;
      aApp     = ["", "", ""];
    }
    else //modify favorite
    {
      sCaption = sTxtApplications + ": " + sTxtModFavorite;
      aApp     = aFavorite[nAppIndex];
    }
  }

  if (! aApp[1])
    GetNewExternalApp(aApp);

  aApp = InputBox(hWndDlg, sCaption, [sTxtDispName + ":", sTxtFullName + " (%a - " + sTxtAkelDir + ", %WinDir% - " + sTxtEnvVar + "):", sTxtAddPar], aApp, nFocus, "CheckInputExternalApp", (nAppType == 3) ? nAppIndex : undefined);

  if (aApp)
  {
    if (nAppType == 0)
    {
      if (nAppIndex == 1)
      {
        sViewerName = aApp[0];
        sViewer     = aApp[1];
        sViewerPar  = aApp[2];
      }
      else
      {
        sViewerName2 = aApp[0];
        sViewer2     = aApp[1];
        sViewerPar2  = aApp[2];
      }
    }
    else if (nAppType == 1)
    {
      if (nAppIndex == 1)
      {
        sEditorName = aApp[0];
        sEditor     = aApp[1];
        sEditorPar  = aApp[2];
      }
      else
      {
        sEditorName2 = aApp[0];
        sEditor2     = aApp[1];
        sEditorPar2  = aApp[2];
      }
    }
    else if (nAppType == 2)
    {
      if (nAppIndex == 1)
      {
        sComparerName = aApp[0];
        sComparer     = aApp[1];
        sComparerPar  = aApp[2];
      }
      else
      {
        sComparerName2 = aApp[0];
        sComparer2     = aApp[1];
        sComparerPar2  = aApp[2];
      }
    }
    else
    {
      if (nAppIndex < 0)
        aFavorite.push([aApp[0], aApp[1], aApp[2]]);
      else
        aFavorite[nAppIndex] = [aApp[0], aApp[1], aApp[2]];

      aFavorite.sort(
        function(aA, aB)
        {
          return oSys.Call("Kernel32::lstrcmpiW", aA[0], aB[0]);
        });
    }

    bSet = true;
  }

  return bSet;
}

function GetNewExternalApp(aApp)
{
  GetCurFile(nCurPan);

  if (aCurDir[nCurPan][aCurDrive[nCurPan]].File && (! CurFileIsDir(nCurPan)))
  {
    if (aCurDir[nCurPan][aCurDrive[nCurPan]].File.indexOf(".") >= 0)
      aApp[0] = aCurDir[nCurPan][aCurDrive[nCurPan]].File.substr(0, aCurDir[nCurPan][aCurDrive[nCurPan]].File.lastIndexOf("."));
    else
      aApp[0] = aCurDir[nCurPan][aCurDrive[nCurPan]].File;

    aApp[1] = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File;
  }
}

function CheckInputExternalApp(hWnd, aApp, nIndex)
{
  var sAppName;

  if (! aApp[0])
  {
    WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtDispName, sScriptName);
    return 0;
  }

  if ((typeof nIndex == "number") && (IsNameInArray(aFavorite, aApp[0], nIndex)))
  {
    WarningBox(hWnd, aApp[0] + "\n\n" + sTxtNameExists, sScriptName);
    return 0;
  }

  if (! aApp[1])
  {
    WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtFullName, sScriptName);
    return 1;
  }

  sAppName = ExpandFileName(aApp[1]);
  if (! IsFileExists(sAppName))
  {
    WarningBox(hWnd, sAppName + "\n\n" + sTxtFileNoExists, sScriptName);
    return 1;
  }

  return -1;
}

function RemoveFavoriteApp(nIndex)
{
  if (QuestionBox(hWndDlg, aFavorite[nIndex][0] + "\n" + aFavorite[nIndex][1] + "\n\n" + sTxtWantDelFav, sTxtApplications + ": " + sTxtDelFavorite))
    aFavorite.splice(nIndex, 1);
}

function RunFavoriteApp(nAppIndex)
{
  var sAppName = ExpandFileName(aFavorite[nAppIndex][1]);

  if (! IsFileExists(sAppName))
  {
    if (SetExternalApp(3, nAppIndex, 1))
      sAppName = ExpandFileName(aFavorite[nAppIndex][1]);
    else
      return;
  }

  AkelPad.Exec(sAppName + ' ' + aFavorite[nAppIndex][2]);
}

function RunAkelScript(bArg)
{
  var sScriptsDir = AkelPad.GetAkelDir(5 /*ADTYPE_SCRIPTS*/);
  var sArgument   = "";
  var sExtension;
  var sScript;
  var nLevel;
  var i;

  GetCurFile(nCurPan);
  sExtension = aCurDir[nCurPan][aCurDrive[nCurPan]].File.substr(aCurDir[nCurPan][aCurDrive[nCurPan]].File.lastIndexOf(".") + 1).toUpperCase();

  if ((! aCurDir[nCurPan][aCurDrive[nCurPan]].File) ||
      (CurFileIsDir(nCurPan)) ||
      ((sExtension != "JS") && (sExtension != "VBS")))
  {
    WarningBox(hWndDlg, sTxtJsVbsOnly, sTxtRunScript);
    return;
  }

  if (aCurDrive[nCurPan] != sScriptsDir.substr(0, 2))
  {
    WarningBox(hWndDlg, sTxtNoRunScript, sTxtRunScript);
    return;
  }

  if (bArg)
  {
    if (aCurDir[nCurPan][aCurDrive[nCurPan]].File in oScrArg)
      sArgument = oScrArg[aCurDir[nCurPan][aCurDrive[nCurPan]].File];

    sArgument = InputBox(hWndDlg, sTxtRunScript, aCurDir[nCurPan][aCurDrive[nCurPan]].File + "\n\n" + sTxtInpArgs, sArgument);

    if (sArgument == undefined)
      return;
    else if (sArgument)
      oScrArg[aCurDir[nCurPan][aCurDrive[nCurPan]].File] = sArgument;
  }

  if (! IsDriveExists(aCurDrive[nCurPan]))
  {
    MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
    return;
  }

  //No parent dir
  if (! IsDirExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path))
  {
    MessageNoFile(nCurPan, 1, 1);
    return;
  }

  if (IsFileExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
  {
    if ((sScriptsDir + "\\").toUpperCase() == aCurDir[nCurPan][aCurDrive[nCurPan]].Path.toUpperCase())
     sScript = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    else
    {
      nLevel      = sScriptsDir.match(/\\/g).length;
      sScriptsDir = "";

      for (i = 0; i < nLevel; ++i)
        sScriptsDir += "..\\";

      sScript = sScriptsDir + aCurDir[nCurPan][aCurDrive[nCurPan]].Path.substr(3) + aCurDir[nCurPan][aCurDrive[nCurPan]].File;
    }

    AkelPad.Call("Scripts::Main", 1, sScript, sArgument);
  }
  else
    MessageNoFile(nCurPan);
}

function GetFileName(sCaption, sLabel, sName)
{
  return InputBox(hWndDlg, sCaption, sLabel, sName, null, "CheckInputFileName");
}

function CheckInputFileName(hWnd, aFile)
{
  var nIndex;

  if (aFile[0])
  {
    if (/^(CON|PRN|AUX|NUL|COM1|COM2|COM3|COM4|COM5|COM6|COM7|COM8|COM9|LPT1|LPT2|LPT3|LPT4|LPT5|LPT6|LPT7|LPT8|LPT9)$/i.test(aFile[0]))
    {
      WarningBox(hWndDlg, aFile[0] + "\n\n" + sTxtBadName, sScriptName);
      return 0;
    }

    else
    {
      nIndex = aFile[0].search(/[<>:"/\\|?*]/);
      if (nIndex >= 0)
      {
        WarningBox(hWndDlg, aFile[0] + "\n\n" + sTxtBadChar + ": " + aFile[0].substr(nIndex, 1), sScriptName);
        return 0;
      }
    }
  }

  return -1;
}

function MessageNoDrive(nPan, sDrive)
{
  WarningBox(hWndDlg, sDrive + "\n\n" + sTxtNoDrive, sScriptName);
  oSys.Call("User32::SetFocus", aWnd[IDDRIVECB0 + nPan][HWND]);
}

function MessageNoFile(nPan, bDir, bParentDir)
{
  var nSelPos = GetCurSelLV(aWnd[IDFILELV0 + nPan][HWND]);
  var sMessage;
  var sFile;
  var sSelFile;

  if (bDir)
  {
    sMessage = sTxtNoDirRefr;
    if (bParentDir)
      sFile = "";
    else
      sFile = aCurDir[nPan][aCurDrive[nPan]].File + "\\";
  }
  else
  {
    sMessage = sTxtNoFileRefr;
    sFile    = aCurDir[nPan][aCurDrive[nPan]].File;
  }

  WarningBox(hWndDlg, aCurDir[nPan][aCurDrive[nPan]].Path + sFile + "\n\n" + sMessage, sScriptName);

  while ((aCurDir[nPan][aCurDrive[nPan]].Path.length > 3) &&
         (! IsDirExists(aCurDir[nPan][aCurDrive[nPan]].Path)))
  {
    aCurDir[nCurPan][aCurDrive[nCurPan]].Path = aCurDir[nCurPan][aCurDrive[nCurPan]].Path.slice(0, -1);
    sSelFile = aCurDir[nCurPan][aCurDrive[nCurPan]].Path.substr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path.lastIndexOf("\\") + 1);
    aCurDir[nCurPan][aCurDrive[nCurPan]].Path = aCurDir[nCurPan][aCurDrive[nCurPan]].Path.substr(0, aCurDir[nCurPan][aCurDrive[nCurPan]].Path.lastIndexOf("\\") + 1);
  }

  SetWndText(aWnd[IDDIRS0 + nPan][HWND], aCurDir[nPan][aCurDrive[nPan]].Path);
  FillFileList(nPan, sSelFile, nSelPos);
  FillStreamList(nPan);
}

function MessageNoStream(sName)
{
  var nPan2 = Number(! nCurPan);

  WarningBox(hWndDlg, sName + "\n\n" + sTxtNoStreamRefr, sScriptName);
  RefreshStreamList(nCurPan);

  if ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path) &&
      (aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nPan2][aCurDrive[nPan2]].File))
    RefreshStreamList(nPan2);
}

function WarningBox(hWnd, sText, sCaption)
{
  AkelPad.MessageBox(hWnd, sText, sCaption, 0x00000030 /*MB_ICONWARNING*/);
}

function QuestionBox(hWnd, sText, sCaption, nDefButton)
{
  var nType = (nDefButton << 8) | 0x23 /*MB_ICONQUESTION|MB_YESNOCANCEL*/;

  return (AkelPad.MessageBox(hWnd, sText, sCaption, nType) == 6 /*IDYES*/);
}

function MainMenu()
{
  var MF_STRING    = 0x0000;
  var MF_GRAYED    = 0x0001;
  var MF_CHECKED   = 0x0008;
  var MF_POPUP     = 0x0010;
  var MF_SEPARATOR = 0x0800;
  var hMenu0102 = oSys.Call("User32::CreatePopupMenu");
  var hMenu0103 = oSys.Call("User32::CreatePopupMenu");
  var hMenu0105 = oSys.Call("User32::CreatePopupMenu");
  var hMenu01   = oSys.Call("User32::CreatePopupMenu");
  var hMenu02   = oSys.Call("User32::CreatePopupMenu");
  var hMenu03   = oSys.Call("User32::CreatePopupMenu");
  var hMenu04   = oSys.Call("User32::CreatePopupMenu");
  var hMenu0504 = oSys.Call("User32::CreatePopupMenu");
  var hMenu05   = oSys.Call("User32::CreatePopupMenu");
  var hMenu06   = oSys.Call("User32::CreatePopupMenu");
  var hMenu07   = oSys.Call("User32::CreatePopupMenu");
  var hMenu0708 = oSys.Call("User32::CreatePopupMenu");
  var hMenu0709 = oSys.Call("User32::CreatePopupMenu");
  var hMenu0801 = oSys.Call("User32::CreatePopupMenu");
  var hMenu0802 = oSys.Call("User32::CreatePopupMenu");
  var hMenu08   = oSys.Call("User32::CreatePopupMenu");
  var hMenu     = oSys.Call("User32::CreatePopupMenu");
  var oRect     = {};
  var nCmd;
  var i;

  //File
  for (i = 0; i < aIntAssoc.length; ++i)
  {
    oSys.Call("User32::AppendMenuW", hMenu0102, MF_STRING, 0x010201 + i, aIntAssoc[i][0]);
    oSys.Call("User32::AppendMenuW", hMenu0103, MF_STRING, 0x010301 + i, aIntAssoc[i][0]);
  }
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010501, sTxtFile + "\tCtrl+Ins");
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010502, sTxtPath + "\\" + sTxtFile + "\tCtrl+Shift+Ins");
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010503, sTxtPath + "\tCtrl+Atl+Ins");
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010504, sTxtStream + "\tAlt+Ins");
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010505, sTxtPath + "\\" + sTxtFile + ":" + sTxtStream + "\tShift+Alt+Ins");
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010506, sTxtFile + ":" + sTxtStream + "\tCtrl+Shift+Atl+Ins");
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010507, sTxtFilesList + "\tCtrl+C");
  oSys.Call("User32::AppendMenuW", hMenu0105, MF_STRING, 0x010508, sTxtStreamsList + "\tAlt+C");
  oSys.Call("User32::AppendMenuW", hMenu01, (aIntAssoc.length < 0xFF) ? MF_STRING : MF_GRAYED, 0x010100, sTxtAddAssoc);
  oSys.Call("User32::AppendMenuW", hMenu01, aIntAssoc.length ? MF_POPUP : MF_GRAYED, hMenu0102, sTxtModAssoc);
  oSys.Call("User32::AppendMenuW", hMenu01, aIntAssoc.length ? MF_POPUP : MF_GRAYED, hMenu0103, sTxtDelAssoc);
  oSys.Call("User32::AppendMenuW", hMenu01, aIntAssoc.length ? MF_STRING : MF_GRAYED, 0x010400, sTxtCleAssoc);
  oSys.Call("User32::AppendMenuW", hMenu01, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu01, MF_POPUP, hMenu0105, sTxtCopyNames);
  oSys.Call("User32::AppendMenuW", hMenu01, MF_STRING,  0x010600, sTxtProperties + "\tAlt+Enter");

  //Drive
  oSys.Call("User32::AppendMenuW", hMenu02, ((bDualPan || (nCurPan == 0)) ? MF_STRING : MF_GRAYED), 0x020100, sTxtLeftPanel + "\tAlt+F1");
  oSys.Call("User32::AppendMenuW", hMenu02, ((bDualPan || (nCurPan == 1)) ? MF_STRING : MF_GRAYED), 0x020200, sTxtRightPanel + "\tAlt+F2");

  //Directory
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030100, sTxtGoToParent + "\t<-");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030200, sTxtGoToSubDir + "\t->");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030300, sTxtGoToMain + "\tCtrl+\\");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030400, sTxtFavFolders + "\tAlt+F");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030500, sTxtSpecFolders + "\tAlt+S");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030600, sTxtHistory + "\tAlt+H");
  oSys.Call("User32::AppendMenuW", hMenu03, (aCurHist[nCurPan] > 0) ? MF_STRING : MF_GRAYED, 0x030700, sTxtUndo + "\tAlt+<-");
  oSys.Call("User32::AppendMenuW", hMenu03, (aCurHist[nCurPan] < aHistory[nCurPan].length - 1) ? MF_STRING : MF_GRAYED, 0x030800, sTxtRedo + "\tAlt+->");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030900, sTxtRightToLeft + "\tCtrl+<-");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030A00, sTxtLeftToRight + "\tCtrl+->");
  oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x030B00, sTxtSwapPanels + "\tCtrl+U");

  //Filter
  oSys.Call("User32::AppendMenuW", hMenu04, ((bDualPan || (nCurPan == 0)) ? MF_STRING : MF_GRAYED), 0x040100, sTxtLeftPanel + "\tAlt+1");
  oSys.Call("User32::AppendMenuW", hMenu04, ((bDualPan || (nCurPan == 1)) ? MF_STRING : MF_GRAYED), 0x040200, sTxtRightPanel + "\tAlt+2");

  //Show
  oSys.Call("User32::AppendMenuW", hMenu0504, (! (bColSize || bColTime || bColAttr) ? MF_CHECKED : MF_STRING), 0x050401, sTxtOnlyName + "\tShift+F1");
  oSys.Call("User32::AppendMenuW", hMenu0504, (bColSize ? MF_CHECKED : MF_STRING), 0x050402, sTxtSize + "\tShift+F2");
  oSys.Call("User32::AppendMenuW", hMenu0504, (bColTime ? MF_CHECKED : MF_STRING), 0x050403, sTxtTime + "\tShift+F3");
  oSys.Call("User32::AppendMenuW", hMenu0504, (bColAttr ? MF_CHECKED : MF_STRING), 0x050404, sTxtAttributes + "\tShift+F4");
  oSys.Call("User32::AppendMenuW", hMenu05, ((bDualPan || (nCurPan == 0)) ? MF_CHECKED : MF_STRING), 0x050100, sTxtLeftPanel + "\tCtrl+F1");
  oSys.Call("User32::AppendMenuW", hMenu05, ((bDualPan || (nCurPan == 1)) ? MF_CHECKED : MF_STRING), 0x050200, sTxtRightPanel + "\tCtrl+F2");
  oSys.Call("User32::AppendMenuW", hMenu05, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu05, (bQuickView ? MF_CHECKED : MF_STRING), 0x050300, sTxtQuickView + "\tCtrl+Q");
  oSys.Call("User32::AppendMenuW", hMenu05, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu05, MF_POPUP, hMenu0504, sTxtColumns);

  //Window
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060100, sTxtMoveLeft + "\tShift+Alt+<-");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060200, sTxtMoveRight + "\tShift+Alt+->");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060300, sTxtMoveUp + "\tShift+Alt+Up");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060400, sTxtMoveDown + "\tShift+Alt+Down");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060500, sTxtToLeftEdge + "\tShift+Alt+Home");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060600, sTxtToRightEdge + "\tShift+Alt+End");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060700, sTxtToTopEdge + "\tShift+Alt+PgUp");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060800, sTxtToBottomEdge + "\tShift+Alt+PgDn");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060900, sTxtCenter + "\tShift+Alt+C");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x060A00, sTxtMaximize + "\tShift+Alt+M");

  //Applications
  for (i = 0; i < aFavorite.length; ++i)
  {
    oSys.Call("User32::AppendMenuW", hMenu0708, MF_STRING, 0x070801 + i, aFavorite[i][0]);
    oSys.Call("User32::AppendMenuW", hMenu0709, MF_STRING, 0x070901 + i, aFavorite[i][0]);
  }
  oSys.Call("User32::AppendMenuW", hMenu07, MF_STRING, 0x070100, sTxtViewer + " 1: " + sViewerName + "\tCtrl+Shift+F3");
  oSys.Call("User32::AppendMenuW", hMenu07, MF_STRING, 0x070200, sTxtViewer + " 2: " + sViewerName2 + "\tCtrl+Alt+F3");
  oSys.Call("User32::AppendMenuW", hMenu07, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu07, MF_STRING, 0x070300, sTxtEditor + " 1: " + sEditorName + "\tCtrl+Shift+F4");
  oSys.Call("User32::AppendMenuW", hMenu07, MF_STRING, 0x070400, sTxtEditor + " 2: " + sEditorName2 + "\tCtrl+Alt+F4");
  oSys.Call("User32::AppendMenuW", hMenu07, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu07, MF_STRING, 0x070500, sTxtComparer + " 1: " + sComparerName + "\tCtrl+Shift+F12");
  oSys.Call("User32::AppendMenuW", hMenu07, MF_STRING, 0x070600, sTxtComparer + " 2: " + sComparerName2 + "\tCtrl+Alt+F12");
  oSys.Call("User32::AppendMenuW", hMenu07, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu07, (aFavorite.length < 0xFF) ? MF_STRING : MF_GRAYED, 0x070700, sTxtAddFavorite);
  oSys.Call("User32::AppendMenuW", hMenu07, aFavorite.length ? MF_POPUP : MF_GRAYED, hMenu0708, sTxtModFavorite);
  oSys.Call("User32::AppendMenuW", hMenu07, aFavorite.length ? MF_POPUP : MF_GRAYED, hMenu0709, sTxtDelFavorite);
  oSys.Call("User32::AppendMenuW", hMenu07, aFavorite.length ? MF_STRING : MF_GRAYED, 0x070A00, sTxtCleFavorite);

  //Run
  oSys.Call("User32::AppendMenuW", hMenu0801, MF_STRING, 0x080101, sTxtWithoutArgs + "\tCtrl+Enter");
  oSys.Call("User32::AppendMenuW", hMenu0801, MF_STRING, 0x080102, sTxtWithArgs + "\tCtrl+Shift+Enter");
  for (i = 0; i < aFavorite.length; ++i)
    oSys.Call("User32::AppendMenuW", hMenu0802, MF_STRING, 0x080201 + i, aFavorite[i][0]);
  oSys.Call("User32::AppendMenuW", hMenu08, MF_POPUP, hMenu0801, sTxtAkelScript);
  oSys.Call("User32::AppendMenuW", hMenu08, aFavorite.length ? MF_POPUP : MF_GRAYED, hMenu0802, sTxtFavorites);
  oSys.Call("User32::AppendMenuW", hMenu08, MF_STRING, 0x080300, sTxtCommandLine);

  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu01, sTxtFile);
  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu02, sTxtDrive);
  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu03, sTxtDirectory);
  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu04, sTxtFilter);
  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu05, sTxtShow);
  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu06, sTxtWindow);
  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu07, sTxtApplications);
  oSys.Call("User32::AppendMenuW", hMenu, MF_POPUP, hMenu08, sTxtRun);
  oSys.Call("User32::AppendMenuW", hMenu, MF_STRING, 0x090000, sTxtExit);

  GetWindowPos(aWnd[IDMENUB][HWND], oRect);

  nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, 0x01A0 /*TPM_NONOTIFY|TPM_RETURNCMD|TPM_BOTTOMALIGN*/, oRect.X, oRect.Y, 0, hWndDlg, 0);

  oSys.Call("User32::DestroyMenu", hMenu0102);
  oSys.Call("User32::DestroyMenu", hMenu0103);
  oSys.Call("User32::DestroyMenu", hMenu0105);
  oSys.Call("User32::DestroyMenu", hMenu01);
  oSys.Call("User32::DestroyMenu", hMenu02);
  oSys.Call("User32::DestroyMenu", hMenu03);
  oSys.Call("User32::DestroyMenu", hMenu04);
  oSys.Call("User32::DestroyMenu", hMenu0504);
  oSys.Call("User32::DestroyMenu", hMenu05);
  oSys.Call("User32::DestroyMenu", hMenu06);
  oSys.Call("User32::DestroyMenu", hMenu07);
  oSys.Call("User32::DestroyMenu", hMenu0708);
  oSys.Call("User32::DestroyMenu", hMenu0709);
  oSys.Call("User32::DestroyMenu", hMenu0801);
  oSys.Call("User32::DestroyMenu", hMenu0802);
  oSys.Call("User32::DestroyMenu", hMenu08);
  oSys.Call("User32::DestroyMenu", hMenu);

  switch (nCmd)
  {
    case 0x010100 : SetInternalAssoc(-1); //add internal association
      break;
    case 0x010400 :
      if (QuestionBox(hWndDlg, sTxtWantCleAssoc, sTxtCleAssoc, 1))
        aIntAssoc = [];
      break;
    case 0x010501 : CopyNameToCB(1);
      break;
    case 0x010502 : CopyNameToCB(3);
      break;
    case 0x010503 : CopyNameToCB(5);
      break;
    case 0x010504 : CopyNameToCB(4);
      break;
    case 0x010505 : CopyNameToCB(6);
      break;
    case 0x010506 : CopyNameToCB(7);
      break;
    case 0x010507 : CopyListToCB(0);
      break;
    case 0x010508 : CopyListToCB(1);
      break;
    case 0x010600 : Properties();
      break;
    case 0x020100 : oSys.Call("User32::SetFocus", aWnd[IDDRIVECB0][HWND]);
      break;
    case 0x020200 : oSys.Call("User32::SetFocus", aWnd[IDDRIVECB1][HWND]);
      break;
    case 0x030100 : Open(nCurPan, -1);
      break;
    case 0x030200 : Open(nCurPan, 1);
      break;
    case 0x030300 : Open(nCurPan, -2);
      break;
    case 0x030400 : FavoriteFolders(nCurPan);
      break;
    case 0x030500 : SpecialFolders(nCurPan);
      break;
    case 0x030600 : History(nCurPan);
      break;
    case 0x030700 : ChangeDirFromHistory(nCurPan, 0, -1);
      break;
    case 0x030800 : ChangeDirFromHistory(nCurPan, 0, 1);
      break;
    case 0x030900 : ClonePanel(0);
      break;
    case 0x030A00 : ClonePanel(1);
      break;
    case 0x030B00 : SwapPanels();
      break;
    case 0x040100 : oSys.Call("User32::SetFocus", aWnd[IDFILTERCB0][HWND]);
      break;
    case 0x040200 : oSys.Call("User32::SetFocus", aWnd[IDFILTERCB1][HWND]);
      break;
    case 0x050100 : ShowPanel(0);
      break;
    case 0x050200 : ShowPanel(1);
      break;
    case 0x050300 : ShowQuickView();
      break;
    case 0x050401 : ShowColumn(1);
      break;
    case 0x050402 : ShowColumn(2);
      break;
    case 0x050403 : ShowColumn(3);
      break;
    case 0x050404 : ShowColumn(4);
      break;
    case 0x060100 : MoveDialog("L");
      break;
    case 0x060200 : MoveDialog("R");
      break;
    case 0x060300 : MoveDialog("U");
      break;
    case 0x060400 : MoveDialog("D");
      break;
    case 0x060500 : MoveDialog("H");
      break;
    case 0x060600 : MoveDialog("E");
      break;
    case 0x060700 : MoveDialog("T");
      break;
    case 0x060800 : MoveDialog("B");
      break;
    case 0x060900 : MoveDialog("C");
      break;
    case 0x060A00 : MoveDialog("M");
      break;
    case 0x070100 : SetExternalApp(0, 1);
      break;
    case 0x070200 : SetExternalApp(0, 2);
      break;
    case 0x070300 : SetExternalApp(1, 1);
      break;
    case 0x070400 : SetExternalApp(1, 2);
      break;
    case 0x070500 : SetExternalApp(2, 1);
      break;
    case 0x070600 : SetExternalApp(2, 2);
      break;
    case 0x070700 : SetExternalApp(3, -1); //add favorite app
      break;
    case 0x070A00 :
      if (QuestionBox(hWndDlg, sTxtWantCleFavAp, sTxtApplications + ": " + sTxtCleFavorite, 1))
        aFavorite = [];
      break;
    case 0x080101 : RunAkelScript(0);
      break;
    case 0x080102 : RunAkelScript(1);
      break;
    case 0x080300 : AkelPad.Exec("cmd.exe", aCurDir[nCurPan][aCurDrive[nCurPan]].Path);
      break;
    case 0x090000 : oSys.Call("User32::PostMessageW", hWndDlg, 16 /*WM_CLOSE*/, 0, 0);
      break;
    default :
      if ((nCmd >= 0x010201) && (nCmd <= 0x0102FF))
        SetInternalAssoc(nCmd - 0x010201); //modify internal association
      else if ((nCmd >= 0x010301) && (nCmd <= 0x0103FF))
        RemoveInternalAssoc(nCmd - 0x010301);
      else if ((nCmd >= 0x070801) && (nCmd <= 0x0708FF))
        SetExternalApp(3, nCmd - 0x070801); //modify favorite app
      else if ((nCmd >= 0x070901) && (nCmd <= 0x0709FF))
        RemoveFavoriteApp(nCmd - 0x070901);
      else if ((nCmd >= 0x080201) && (nCmd <= 0x0802FF))
        RunFavoriteApp(nCmd - 0x080201);
  }
}

function ContextMenu(hWnd, lpPoint)
{
  var MF_STRING    = 0x0000;
  var MF_GRAYED    = 0x0001;
  var MF_POPUP     = 0x0010;
  var MF_SEPARATOR = 0x0800;
  var hMenu03 = oSys.Call("User32::CreatePopupMenu");
  var hMenu05 = oSys.Call("User32::CreatePopupMenu");
  var hMenu06 = oSys.Call("User32::CreatePopupMenu");
  var hMenu07 = oSys.Call("User32::CreatePopupMenu");
  var hMenu09 = oSys.Call("User32::CreatePopupMenu");
  var hMenu0A = oSys.Call("User32::CreatePopupMenu");
  var hMenu0B = oSys.Call("User32::CreatePopupMenu");
  var hMenu   = oSys.Call("User32::CreatePopupMenu");
  var lpRect;
  var nCmd;
  var nX, nY;
  var i;

  for (i = 0; i < aFavorite.length; ++i)
    oSys.Call("User32::AppendMenuW", hMenu03, MF_STRING, 0x0301 + i, aFavorite[i][0]);

  oSys.Call("User32::AppendMenuW", hMenu05, MF_STRING, 0x0501, (sViewerName ? sViewerName : sTxtViewer + " 1") + "\tF3");
  oSys.Call("User32::AppendMenuW", hMenu05, MF_STRING, 0x0502, (sViewerName2 ? sViewerName2 : sTxtViewer + " 2") + "\tCtrl+F3");

  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x0601, (sEditorName ? sEditorName : sTxtEditor + " 1") + "\tF4");
  oSys.Call("User32::AppendMenuW", hMenu06, MF_STRING, 0x0602, (sEditorName2 ? sEditorName2 : sTxtEditor + " 2") + "\tCtrl+F4");

  oSys.Call("User32::AppendMenuW", hMenu07, CopyAvailable(0) ? MF_STRING : MF_GRAYED, 0x0701, sTxtToSecPanel + "\tF5");
  oSys.Call("User32::AppendMenuW", hMenu07, CopyAvailable(1) ? MF_STRING : MF_GRAYED, 0x0702, sTxtToOwnPanel + "\tShift+F5");

  oSys.Call("User32::AppendMenuW", hMenu09, (aCurWnd[nCurPan] == 0) ? MF_STRING : MF_GRAYED, 0x0901, sTxtDirectory + "\tF7");
  oSys.Call("User32::AppendMenuW", hMenu09, (aCurWnd[nCurPan] == 0) ? MF_STRING : MF_GRAYED, 0x0902, sTxtFile + "\tShift+F7");
  oSys.Call("User32::AppendMenuW", hMenu09, CreateStreamAvailable() ? MF_STRING : MF_GRAYED, 0x0903, sTxtStream + "\tF7");

  oSys.Call("User32::AppendMenuW", hMenu0A, (aCurWnd[nCurPan] == 0) ? MF_STRING : MF_GRAYED, 0x0A01, sTxtToRecBin + "\tF8");
  oSys.Call("User32::AppendMenuW", hMenu0A, (aCurWnd[nCurPan] == 0) ? MF_STRING : MF_GRAYED, 0x0A02, sTxtFromDisk + "\tShift+F8");
  oSys.Call("User32::AppendMenuW", hMenu0A, (aCurWnd[nCurPan] == 1) ? MF_STRING : MF_GRAYED, 0x0A03, sTxtDelStr + "\tF8");

  oSys.Call("User32::AppendMenuW", hMenu0B, MF_STRING, 0x0B01, (sComparerName ? sComparerName : sTxtComparer + " 1") + "\tF12");
  oSys.Call("User32::AppendMenuW", hMenu0B, MF_STRING, 0x0B02, (sComparerName2 ? sComparerName2 : sTxtComparer + " 2") + "\tCtrl+F12");

  if (aCurWnd[nCurPan] == 0)
  {
    oSys.Call("User32::AppendMenuW", hMenu, OpenAvailable(nCurPan, 0) ? MF_STRING : MF_GRAYED, 0x0100, sTxtOpenWin + "\tEnter");
    oSys.Call("User32::AppendMenuW", hMenu, OpenInAvailable(4) ? MF_STRING : MF_GRAYED, 0x0200, sTxtOpenInAssoc + "\tShift+Enter");
  }

  oSys.Call("User32::AppendMenuW", hMenu, (OpenInAvailable(3) && aFavorite.length) ? MF_POPUP : MF_GRAYED, hMenu03, sTxtOpenInFavor);
  oSys.Call("User32::AppendMenuW", hMenu, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu, RenameAvailable() ? MF_STRING : MF_GRAYED, 0x0400, sTxtRename + "\tF2");
  oSys.Call("User32::AppendMenuW", hMenu, OpenInAvailable(0) ? MF_POPUP : MF_GRAYED, hMenu05, sTxtView);
  oSys.Call("User32::AppendMenuW", hMenu, OpenInAvailable(1) ? MF_POPUP : MF_GRAYED, hMenu06, sTxtEdit);
  oSys.Call("User32::AppendMenuW", hMenu, CopyAvailable(0) || CopyAvailable(1) ? MF_POPUP : MF_GRAYED, hMenu07, sTxtCopy);
  oSys.Call("User32::AppendMenuW", hMenu, CopyAvailable(0) ? MF_STRING : MF_GRAYED, 0x0800, sTxtMove + "\tF6");
  oSys.Call("User32::AppendMenuW", hMenu, (aCurWnd[nCurPan] == 0) || CreateStreamAvailable() ? MF_POPUP : MF_GRAYED, hMenu09, sTxtCreate);
  oSys.Call("User32::AppendMenuW", hMenu, DeleteAvailable() ? MF_POPUP : MF_GRAYED, hMenu0A, sTxtDelete);
  oSys.Call("User32::AppendMenuW", hMenu, CompareAvailable() ? MF_POPUP : MF_GRAYED, hMenu0B, sTxtCompare);
  oSys.Call("User32::AppendMenuW", hMenu, MF_SEPARATOR, 0);
  oSys.Call("User32::AppendMenuW", hMenu, PropertiesAvailable() ? MF_STRING : MF_GRAYED, 0x0C00, sTxtProperties + "\tAlt+Enter");

  //menu from mouse r-click
  if (lpPoint)
  {
    oSys.Call("User32::ClientToScreen", hWnd, lpPoint);
    nX = AkelPad.MemRead(lpPoint, DT_DWORD);
    nY = AkelPad.MemRead(lpPoint + 4, DT_DWORD);
  }
  //menu from keyboard
  else
  {
    lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
    AkelPad.SendMessage(hWnd, 0x100E /*LVM_GETITEMRECT*/, GetCurSelLV(hWnd), lpRect);

    oSys.Call("User32::ClientToScreen", hWnd, lpRect);
    oSys.Call("User32::ClientToScreen", hWnd, lpRect + 8);
    nX = AkelPad.MemRead(lpRect,      DT_DWORD) + 40;
    nY = AkelPad.MemRead(lpRect + 12, DT_DWORD);

    AkelPad.MemFree(lpRect);
  }

  nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, 0x0180 /*TPM_NONOTIFY|TPM_RETURNCMD*/, nX, nY, 0, hWndDlg, 0);

  oSys.Call("User32::DestroyMenu", hMenu03);
  oSys.Call("User32::DestroyMenu", hMenu05);
  oSys.Call("User32::DestroyMenu", hMenu06);
  oSys.Call("User32::DestroyMenu", hMenu07);
  oSys.Call("User32::DestroyMenu", hMenu09);
  oSys.Call("User32::DestroyMenu", hMenu0A);
  oSys.Call("User32::DestroyMenu", hMenu0B);
  oSys.Call("User32::DestroyMenu", hMenu);

  switch (nCmd)
  {
    case 0x0100 : Open(nCurPan, 0);
      break;
    case 0x0200 : OpenIn(4);
      break;
    case 0x0400 : Rename();
      break;
    case 0x0501 : OpenIn(0, 1);
      break;
    case 0x0502 : OpenIn(0, 2);
      break;
    case 0x0601 : OpenIn(1, 1);
      break;
    case 0x0602 : OpenIn(1, 2);
      break;
    case 0x0701 : Copy(0, 0);
      break;
    case 0x0702 : Copy(0, 1);
      break;
    case 0x0800 : Copy(1, 0);
      break;
    case 0x0901 : Create(1);
      break;
    case 0x0902 :
    case 0x0903 : Create(0);
      break;
    case 0x0A01 : Delete(1);
      break;
    case 0x0A02 :
    case 0x0A03 : Delete(0);
      break;
    case 0x0B01 : Compare(1);
      break;
    case 0x0B02 : Compare(2);
      break;
    case 0x0C00 : Properties();
      break;
    default :
      if ((nCmd >= 0x0301) && (nCmd <= 0x03FF))
        OpenIn(3, nCmd - 0x0301); //open in favorite
  }
}

function ReadWriteIni(bWrite)
{
  var sIniFile = WScript.ScriptFullName.substring(0, WScript.ScriptFullName.lastIndexOf(".")) + ".ini";
  var sIniTxt;
  var oError;
  var i;

  if (bWrite)
  {
    GetCurFile(0);
    GetCurFile(1);

    if (! bSaveHist)
    {
      aCurHist = [0, 0];
      aHistory = [[], []];
    }

    sIniTxt =
      'bDualPan='       + bDualPan + ';\r\n' +
      'bColSize='       + bColSize + ';\r\n' +
      'bColTime='       + bColTime + ';\r\n' +
      'bColAttr='       + bColAttr + ';\r\n' +
      'bQuickView='     + bQuickView + ';\r\n' +
      'bSaveHist='      + bSaveHist + ';\r\n' +
      'sViewerName='    + '"' + sViewerName.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sViewer='        + '"' + sViewer.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sViewerPar='     + '"' + sViewerPar.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sViewerName2='   + '"' + sViewerName2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sViewer2='       + '"' + sViewer2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sViewerPar2='    + '"' + sViewerPar2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sEditorName='    + '"' + sEditorName.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sEditor='        + '"' + sEditor.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sEditorPar='     + '"' + sEditorPar.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sEditorName2='   + '"' + sEditorName2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sEditor2='       + '"' + sEditor2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sEditorPar2='    + '"' + sEditorPar2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sComparerName='  + '"' + sComparerName.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sComparer='      + '"' + sComparer.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sComparerPar='   + '"' + sComparerPar.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sComparerName2=' + '"' + sComparerName2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sComparer2='     + '"' + sComparer2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'sComparerPar2='  + '"' + sComparerPar2.replace(/[\\"]/g, "\\$&") + '";\r\n' +
      'nCurPan='        + nCurPan + ';\r\n' +
      'aCurFilter=["'   + aCurFilter[0].replace(/[\\"]/g, "\\$&") + '","' + aCurFilter[1].replace(/[\\"]/g, "\\$&") + '"];\r\n' +
      'aCurHist=['      + aCurHist[0] + ',' + aCurHist[1] + '];\r\n' +
      'aCurWnd=['       + aCurWnd[0] + ',' + aCurWnd[1] + '];\r\n' +
      'aCurDrive=["'    + aCurDrive[0] + '","' + aCurDrive[1] + '"];\r\n' +
      'aCurDir[0]={';

    for (i in aCurDir[0])
      sIniTxt += '"' + i +
                 '":{Path:"'  + aCurDir[0][i].Path.replace(/[\\"]/g, "\\$&") +
                 '",File:"'   + aCurDir[0][i].File.replace(/[\\"]/g, "\\$&") +
                 '",Stream:"' + aCurDir[0][i].Stream.replace(/[\\"]/g, "\\$&") + '"},';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '};\r\naCurDir[1]={';

    for (i in aCurDir[1])
      sIniTxt += '"' + i +
                 '":{Path:"'  + aCurDir[1][i].Path.replace(/[\\"]/g, "\\$&") +
                 '",File:"'   + aCurDir[1][i].File.replace(/[\\"]/g, "\\$&") +
                 '",Stream:"' + aCurDir[1][i].Stream.replace(/[\\"]/g, "\\$&") + '"},';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '};\r\naFilter=[';

    for (i = 0; i < aFilter.length; ++i)
      sIniTxt += '"' + aFilter[i].replace(/[\\"]/g, "\\$&") + '",';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '];\r\naSort=[';

    for (i = 0; i < aSort.length; ++i)
      sIniTxt += '[' + aSort[i][0] + ',' + aSort[i][1] + '],';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '];\r\naFavorite=[';

    for (i = 0; i < aFavorite.length; ++i)
      sIniTxt += '["' + aFavorite[i][0].replace(/[\\"]/g, "\\$&") + '","' + aFavorite[i][1].replace(/[\\"]/g, "\\$&") + '","' + aFavorite[i][2].replace(/[\\"]/g, "\\$&") + '"],';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '];\r\naFavoriteFolder=[';

    for (i = 0; i < aFavoriteFolder.length; ++i)
      sIniTxt += '["' + aFavoriteFolder[i][0].replace(/[\\"]/g, "\\$&") + '","' + aFavoriteFolder[i][1].replace(/[\\"]/g, "\\$&") + '"],';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '];\r\naIntAssoc=[';

    for (i = 0; i < aIntAssoc.length; ++i)
      sIniTxt += '["' + aIntAssoc[i][0].replace(/[\\"]/g, "\\$&") + '","' + aIntAssoc[i][1].replace(/[\\"]/g, "\\$&") + '","' + aIntAssoc[i][2].replace(/[\\"]/g, "\\$&") + '"],';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '];\r\naHistory[0]=[';

    for (i = 0; i < aHistory[0].length; ++i)
      sIniTxt += '["' + aHistory[0][i][0].replace(/[\\"]/g, "\\$&") + '","' + aHistory[0][i][1].replace(/[\\"]/g, "\\$&") + '","' + aHistory[0][i][2].replace(/[\\"]/g, "\\$&") + '"],';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '];\r\naHistory[1]=[';

    for (i = 0; i < aHistory[1].length; ++i)
      sIniTxt += '["' + aHistory[1][i][0].replace(/[\\"]/g, "\\$&") + '","' + aHistory[1][i][1].replace(/[\\"]/g, "\\$&") + '","' + aHistory[1][i][2].replace(/[\\"]/g, "\\$&") + '"],';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '];\r\noScrArg={';

    for (i in oScrArg)
      sIniTxt += '"' + i +'":"' + oScrArg[i].replace(/[\\"]/g, "\\$&") + '",';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '};\r\noWndPos={';

    for (i in oWndPos)
      sIniTxt += i + ':' + oWndPos[i] + ',';
    if (sIniTxt.slice(-1) == ",")
      sIniTxt = sIniTxt.slice(0, -1);
    sIniTxt += '};';

    WriteFile(sIniFile, null, sIniTxt, 1);
  }

  else if (IsFileExists(sIniFile))
  {
    try
    {
      eval(AkelPad.ReadFile(sIniFile));
    }
    catch (oError)
    {
    }
  }
}

function GetLangStrings()
{
  var sLangFile = WScript.ScriptFullName.substring(0, WScript.ScriptFullName.lastIndexOf(".")) + "_" + AkelPad.GetLangId(0 /*LANGID_FULL*/).toString() + ".lng";

  if (! IsFileExists(sLangFile))
  {
    sLangFile = WScript.ScriptFullName.substring(0, WScript.ScriptFullName.lastIndexOf(".")) + "_1033.lng";
    if (! IsFileExists(sLangFile))
    {
      WScript.Echo("File does not exists:\n" + sLangFile);
      return false;
    }
  }

  eval(AkelPad.ReadFile(sLangFile));
  return true;
}


Last edited by KDJ on Sat Apr 12, 2014 9:57 pm; edited 16 times in total
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1334
Location: Poland

PostPosted: Fri Mar 16, 2012 9:47 pm    Post subject: Reply with quote

Interface language files for FileAndStream.js.

FileAndStream_1033.lng

Code:
/**************************************
FileAndStream.js ver. 2013-09-14
Interface language
Language:      English (1033)
Translated by: KDJ
**************************************/
sTxtFilter       = "Filter";
sTxtFileName     = "File name";
sTxtStrName      = "NTFS stream name";
sTxtSize         = "Size";
sTxtTime         = "Time";
sTxtAttrib       = "Attrib.";
sTxtOpenWin      = "Open (Windows)";
sTxtMenu         = "Menu";
sTxtRename       = "Rename";
sTxtView         = "View";
sTxtEdit         = "Edit";
sTxtCopy         = "Copy";
sTxtToSecPanel   = "To second panel";
sTxtToOwnPanel   = "To its own panel";
sTxtMove         = "Move";
sTxtCreate       = "Create";
sTxtDelete       = "Delete";
sTxtRefresh      = "Refresh";
sTxtCompare      = "Compare";
sTxtNoFiles      = "<no files>";
sTxtNoStreams    = "<no streams>";
sTxtNoSupport    = "<drive does not supports NTFS streams>";
sTxtMainStream   = "<unnamed - main stream>";
sTxtNoDrive      = "Drive is not available. Please select another.";
sTxtNoDirRefr    = "Directory does not exists. List of files will be refreshed.";
sTxtNoFileRefr   = "File does not exists. List of files will be refreshed.";
sTxtNoStreamRefr = "Stream does not exists. List of streams will be refreshed.";
sTxtNoDirAcc     = "Access denied to this directory.";
sTxtNoExists     = "Does not exists.";
sTxtDirNoExists  = "Directory does not exists.";
sTxtFileNoExists = "File does not exists.";
sTxtDirExists    = "Directory already exists.";
sTxtFileExists   = "File already exists.";
sTxtStrExists    = "Stream already exists.";
sTxtNameExists   = "Name already exists.";
sTxtRenDir       = "Rename directory";
sTxtRenFile      = "Rename file";
sTxtRenStr       = "Rename stream";
sTxtRenFail      = "Failed to rename.";
sTxtNewName      = "new name:";
sTxtCopDir       = "Copy directory";
sTxtCopFile      = "Copy file";
sTxtCopStr       = "Copy stream";
sTxtCopFail      = "Failed to copy.";
sTxtMovDir       = "Move directory";
sTxtMovFile      = "Move file";
sTxtMovStr       = "Move stream";
sTxtMovFail      = "Failed to move.";
sTxtWantReplace  = "Already exists. Do you want to replace it?";
sTxtDirToSubdir  = "You can not copy/move directory to its own subdirectory.";
sTxtFileToStr    = "You can not move file to its own stream.";
sTxtCreDir       = "Create new directory";
sTxtCreFile      = "Create new file";
sTxtCreStr       = "Create new stream";
sTxtCreFail      = "Failed to create.";
sTxtInpName      = "Input name:";
sTxtDelDir       = "Delete directory from disk";
sTxtDelDirToBin  = "Delete directory to Recycle Bin";
sTxtDelFile      = "Delete file from disk";
sTxtDelFileToBin = "Delete file to Recycle Bin";
sTxtDelStr       = "Delete stream";
sTxtDelFail      = "Failed to delete.";
sTxtWantDelete   = "Do you want to delete?";
sTxtToRecBin     = "To Recycle Bin";
sTxtFromDisk     = "From disk";
sTxtTo           = "to:";
sTxtToFile       = "to file:";
sTxtToStream     = "to stream:";
sTxtBadName      = "Illegal name.";
sTxtBadChar      = "The name contains illegal character";
sTxtRunScript    = "Run AkelPad script";
sTxtJsVbsOnly    = "You can run only files .JS and .VBS";
sTxtNoRunScript  = "AkelPad script can be run only from the drive, on which you installed AkelPad.";
sTxtInpArgs      = "Input arguments:";
sTxtNoFileProp   = "Error: unable to display file properties.";
sTxtSetViewer    = "Set external viewer of files";
sTxtSetEditor    = "Set external editor of files";
sTxtSetComparer  = "Set external comparer of files";
sTxtDispName     = "Displayed name";
sTxtFullName     = "Full name of executable file with path";
sTxtAkelDir      = "AkelPad directory";
sTxtEnvVar       = "environment variable";
sTxtAddPar       = "Additional parameters:";
sTxtMustSpecify  = "You must specify";
sTxtFavorites    = "Favorites";
sTxtAddFavorite  = "Add to favorites";
sTxtModFavorite  = "Modify favorite";
sTxtDelFavorite  = "Remove from favorites";
sTxtCleFavorite  = "Clear favorites list";
sTxtWantDelFav   = "Do you want to remove from favorites?";
sTxtWantCleFavAp = "Do you want to remove all favorites applications?";
sTxtWantCleFavFo = "Do you want to remove all favorites folders?";
sTxtOpenInFavor  = "Open in favorite";
sTxtGoToFavFold  = "Go to favorite folder";
sTxtCleHistory   = "Clear history of directories";
sTxtSaveHistory  = "Save history on exit";
sTxtAddAssoc     = "Add internal association";
sTxtModAssoc     = "Modify association";
sTxtDelAssoc     = "Remove association";
sTxtCleAssoc     = "Clear associations list";
sTxtFileExtSep   = "File name extensions separated by commas";
sTxtAssocExists  = "Association already exists."
sTxtWantDelAssoc = "Do you want to remove internal association of files?";
sTxtWantCleAssoc = "Do you want to remove all internal associations of files?";
sTxtOpenInAssoc  = "Open (internal association)";
sTxtWait         = "Please wait...";

//Menu
sTxtFile         = "File";
sTxtDrive        = "Drive";
sTxtDirectory    = "Directory";
sTxtShow         = "Show";
sTxtWindow       = "Window";
sTxtApplications = "Applications";
sTxtRun          = "Run";
sTxtExit         = "Exit";
sTxtProperties   = "Properties";
sTxtCopyNames    = "Copy names";
sTxtPath         = "Path";
sTxtStream       = "Stream";
sTxtFilesList    = "Files list in directory";
sTxtStreamsList  = "Streams list in file";
sTxtLeftPanel    = "Left panel";
sTxtRightPanel   = "Right panel";
sTxtGoToParent   = "Go to parent";
sTxtGoToSubDir   = "Go to subdir";
sTxtGoToMain     = "Go to main";
sTxtFavFolders   = "Favorite folders";
sTxtSpecFolders  = "Special folders";
sTxtHistory      = "History";
sTxtUndo         = "Undo";
sTxtRedo         = "Redo";
sTxtRightToLeft  = "Right to left";
sTxtLeftToRight  = "Left to right";
sTxtSwapPanels   = "Swap panels";
sTxtQuickView    = "Quick view";
sTxtColumns      = "Columns";
sTxtOnlyName     = "Only name";
sTxtAttributes   = "Attributes";
sTxtMoveLeft     = "Move left";
sTxtMoveRight    = "Move right";
sTxtMoveUp       = "Move up";
sTxtMoveDown     = "Move down";
sTxtToLeftEdge   = "To left edge";
sTxtToRightEdge  = "To right edge";
sTxtToTopEdge    = "To top edge";
sTxtToBottomEdge = "To bottom edge";
sTxtCenter       = "Center";
sTxtMaximize     = "Maximize";
sTxtViewer       = "Viewer";
sTxtEditor       = "Editor";
sTxtComparer     = "Comparer";
sTxtCommandLine  = "Command line";
sTxtAkelScript   = "AkelPad script";
sTxtWithoutArgs  = "Without arguments";
sTxtWithArgs     = "With arguments";
- English

FileAndStream_1045.lng

Code:
/**************************************
FileAndStream.js ver. 2013-09-14
Interface language
Language:      Polish (1045)
Translated by: KDJ
**************************************/
sTxtFilter       = "Filtr";
sTxtFileName     = "Nazwa pliku";
sTxtStrName      = "Nazwa strumienia NTFS";
sTxtSize         = "Rozmiar";
sTxtTime         = "Czas";
sTxtAttrib       = "Atryb.";
sTxtOpenWin      = "Otwórz (Windows)";
sTxtMenu         = "Menu";
sTxtRename       = "Zmień nazwę";
sTxtView         = "Podgląd";
sTxtEdit         = "Edytuj";
sTxtCopy         = "Kopiuj";
sTxtToSecPanel   = "Do drugiego panela";
sTxtToOwnPanel   = "Do własnego panela";
sTxtMove         = "Przenieś";
sTxtCreate       = "Utwórz";
sTxtDelete       = "Usuń";
sTxtRefresh      = "Odśwież";
sTxtCompare      = "Porównaj";
sTxtNoFiles      = "<brak plików>";
sTxtNoStreams    = "<brak strumieni>";
sTxtNoSupport    = "<dysk nie obsługuje strumieni NTFS>";
sTxtMainStream   = "<nienazwany - główny strumień>";
sTxtNoDrive      = "Dysk jest niedostępny. Proszę wybrać inny.";
sTxtNoDirRefr    = "Katalog nie istnieje. Lista plików zostanie odświeżona.";
sTxtNoFileRefr   = "Plik nie istnieje. Lista plików zostanie odświeżona.";
sTxtNoStreamRefr = "Strumień nie istnieje. Lista strumieni zostanie odświeżona.";
sTxtNoDirAcc     = "Brak dostępu do tego katalogu.";
sTxtNoExists     = "Nie istnieje.";
sTxtDirNoExists  = "Katalog nie istnieje.";
sTxtFileNoExists = "Plik nie istnieje.";
sTxtDirExists    = "Katalog już istnieje.";
sTxtFileExists   = "Plik już istnieje.";
sTxtStrExists    = "Strumień już istnieje.";
sTxtNameExists   = "Nazwa już istnieje.";
sTxtRenDir       = "Zmień nazwę katalogu";
sTxtRenFile      = "Zmień nazwę pliku";
sTxtRenStr       = "Zmień nazwę strumienia";
sTxtRenFail      = "Nie można zmienić nazwy.";
sTxtNewName      = "nowa nazwa:";
sTxtCopDir       = "Kopiuj katalog";
sTxtCopFile      = "Kopiuj plik";
sTxtCopStr       = "Kopiuj strumień";
sTxtCopFail      = "Nie można skopiować.";
sTxtMovDir       = "Przenieś katalog";
sTxtMovFile      = "Przenieś plik";
sTxtMovStr       = "Przenieś strumień";
sTxtMovFail      = "Nie można przenieść.";
sTxtWantReplace  = "Już istnieje. Czy chcesz go zastąpić?";
sTxtDirToSubdir  = "Nie możesz skopiować/przenieść katalogu do jego własnego podkatalogu.";
sTxtFileToStr    = "Nie możesz przenieść pliku do jego własnego strumienia.";
sTxtCreDir       = "Utwórz nowy katalog";
sTxtCreFile      = "Utwórz nowy plik";
sTxtCreStr       = "Utwórz nowy strumień";
sTxtCreFail      = "Nie można utworzyć.";
sTxtInpName      = "Podaj nazwę:";
sTxtDelDir       = "Usuń katalog z dysku";
sTxtDelDirToBin  = "Usuń katalog do kosza";
sTxtDelFile      = "Usuń plik z dysku";
sTxtDelFileToBin = "Usuń plik do kosza";
sTxtDelStr       = "Usuń strumień";
sTxtDelFail      = "Nie można usunąć.";
sTxtWantDelete   = "Czy chcesz usunąć?";
sTxtToRecBin     = "Do kosza";
sTxtFromDisk     = "Z dysku";
sTxtTo           = "do:";
sTxtToFile       = "do pliku:";
sTxtToStream     = "do strumienia:";
sTxtBadName      = "Niedozwolona nawa.";
sTxtBadChar      = "Nazwa zawiera niedozwolony znak";
sTxtRunScript    = "Uruchom skrypt AkelPad'a";
sTxtJsVbsOnly    = "Można uruchamiać tylko pliki .JS i .VBS";
sTxtNoRunScript  = "Skrypt AkelPad'a można uruchomić tylko z dysku, na którym jest zainstalowany AkelPad.";
sTxtInpArgs      = "Podaj argumenty:";
sTxtNoFileProp   = "Błąd: nie można wyświetlić właściwości pliku.";
sTxtSetViewer    = "Zewnętrzny program do podglądu plików";
sTxtSetEditor    = "Zewnętrzny edytor plików";
sTxtSetComparer  = "Zewnętrzny program do porównywania plików";
sTxtDispName     = "Wyświetlana nazwa";
sTxtFullName     = "Pełna nazwa pliku wykonywalnego ze ścieżką";
sTxtAkelDir      = "katalog AkelPad";
sTxtEnvVar       = "zmienna środowiskowa";
sTxtAddPar       = "Dodatkowe parametry:";
sTxtMustSpecify  = "Musisz podać";
sTxtFavorites    = "Ulubione";
sTxtAddFavorite  = "Dodaj do ulubionych";
sTxtModFavorite  = "Modyfikuj ulubione";
sTxtDelFavorite  = "Usuń z ulubionych";
sTxtCleFavorite  = "Wyczyść listę ulubionych";
sTxtWantDelFav   = "Czy chcesz usunąć z ulubionych?";
sTxtWantCleFavAp = "Czy chcesz usunąć wszystkie ulubione programy?";
sTxtWantCleFavFo = "Czy chcesz usunąć wszystkie ulubione foldery?";
sTxtOpenInFavor  = "Otwórz w ulubionym";
sTxtGoToFavFold  = "Przejdź do ulubionego foldera";
sTxtCleHistory   = "Wyczyść historię katalogów";
sTxtSaveHistory  = "Zapisuj historię przy wyjściu";
sTxtAddAssoc     = "Dodaj wewnętrzne skojarzenie";
sTxtModAssoc     = "Modyfikuj skojarzenie";
sTxtDelAssoc     = "Usuń skojarzenie";
sTxtCleAssoc     = "Wyczyść listę skojarzeń";
sTxtFileExtSep   = "Rozszerzenia nazw plików oddzielone przecinkami";
sTxtAssocExists  = "Skojarzenie już istnieje."
sTxtWantDelAssoc = "Czy chcesz usunąć wewnętrzne skojarzenie plików?";
sTxtWantCleAssoc = "Czy chcesz usunąć wszystkie wewnętrzne skojarzenia plików?";
sTxtOpenInAssoc  = "Otwórz (wewnętrzne skojarzenie)";
sTxtWait         = "Proszę czekać...";

//Menu
sTxtFile         = "Plik";
sTxtDrive        = "Dysk";
sTxtDirectory    = "Katalog";
sTxtShow         = "Pokaż";
sTxtWindow       = "Okno";
sTxtApplications = "Programy";
sTxtRun          = "Uruchom";
sTxtExit         = "Zakończ";
sTxtProperties   = "Właściwości";
sTxtCopyNames    = "Kopiuj nazwy";
sTxtPath         = "Ścieżka";
sTxtStream       = "Strumień";
sTxtFilesList    = "Lista plików w katalogu";
sTxtStreamsList  = "Lista strumieni w pliku";
sTxtLeftPanel    = "Lewy panel";
sTxtRightPanel   = "Prawy panel";
sTxtGoToParent   = "Przejdź do nadrzędnego";
sTxtGoToSubDir   = "Przejdź do podkatalogu";
sTxtGoToMain     = "Przejdź do głównego";
sTxtFavFolders   = "Ulubione foldery";
sTxtSpecFolders  = "Specjalne foldery";
sTxtHistory      = "Historia";
sTxtUndo         = "Cofnij";
sTxtRedo         = "Powtórz";
sTxtRightToLeft  = "Prawy do lewego";
sTxtLeftToRight  = "Lewy do prawego";
sTxtSwapPanels   = "Zamień panele";
sTxtQuickView    = "Szybki podgląd";
sTxtColumns      = "Kolumny";
sTxtOnlyName     = "Tylko nazwa";
sTxtAttributes   = "Atrybuty";
sTxtMoveLeft     = "Przesuń w lewo";
sTxtMoveRight    = "Przesuń w prawo";
sTxtMoveUp       = "Przesuń w górę";
sTxtMoveDown     = "Przesuń w dół";
sTxtToLeftEdge   = "Do lewej krawędzi";
sTxtToRightEdge  = "Do prawej krawędzi";
sTxtToTopEdge    = "Do górnej krawędzi";
sTxtToBottomEdge = "Do dolnej krawędzi";
sTxtCenter       = "Wyśrodkuj";
sTxtMaximize     = "Maksymalizuj";
sTxtViewer       = "Podgląd plików";
sTxtEditor       = "Edytor";
sTxtComparer     = "Porównywanie plików";
sTxtCommandLine  = "Linia poleceń";
sTxtAkelScript   = "Skrypt AkelPad'a";
sTxtWithoutArgs  = "Bez  argumentów";
sTxtWithArgs     = "Z argumentami";
- Polish

FileAndStream_1049.lng

Code:
/**************************************
FileAndStream.js ver. 2013-09-14
Interface language
Language:      Russian (1049)
Translated by: Аверин Андрей http://tc-image.3dn.ru
**************************************/
sTxtFilter       = "Фильтр";
sTxtFileName     = "Имя";
sTxtStrName      = "Имя NTFS потока";
sTxtSize         = "Размер";
sTxtTime         = "Дата";
sTxtAttrib       = "Атрибуты";
sTxtOpenWin      = "Открыть (Windows)";
sTxtMenu         = "Меню";
sTxtRename       = "Переимен.";
sTxtView         = "Просмотр";
sTxtEdit         = "Правка";
sTxtCopy         = "Копировать";
sTxtToSecPanel   = "В другую панель";
sTxtToOwnPanel   = "В текущую панель";
sTxtMove         = "Переместить";
sTxtCreate       = "Создать";
sTxtDelete       = "Удалить";
sTxtRefresh      = "Обновить";
sTxtCompare      = "Сравнить";
sTxtNoFiles      = "<нет файлов>";
sTxtNoStreams    = "<нет потоков>";
sTxtNoSupport    = "<диск не поддерживает NTFS потоки>";
sTxtMainStream   = "<без названия - основной поток>";
sTxtNoDrive      = "Диск не доступен. Пожалуйста, выберите другой.";
sTxtNoDirRefr    = "Каталог не существует. Список файлов будет обновлен.";
sTxtNoFileRefr   = "Файл не существует. Список файлов будет обновлен.";
sTxtNoStreamRefr = "Поток не существует. Список потоков будет обновлен.";
sTxtNoDirAcc     = "Отказано в доступе в этот каталог.";
sTxtNoExists     = "Не существует.";
sTxtDirNoExists  = "Каталог не существует.";
sTxtFileNoExists = "Файл не существует.";
sTxtDirExists    = "Каталог уже существует.";
sTxtFileExists   = "Файл уже существует.";
sTxtStrExists    = "Поток уже существует.";
sTxtNameExists   = "Имя уже существует.";
sTxtRenDir       = "Переименование папки";
sTxtRenFile      = "Переименование файла";
sTxtRenStr       = "Переименование потока";
sTxtRenFail      = "Не удалось переименовать.";
sTxtNewName      = "новое имя:";
sTxtCopDir       = "Копирование папки";
sTxtCopFile      = "Копирование файла";
sTxtCopStr       = "Копирование потока";
sTxtCopFail      = "Не удалось скопировать.";
sTxtMovDir       = "Перемещение папки";
sTxtMovFile      = "Перемещение файла";
sTxtMovStr       = "Перемещение потока";
sTxtMovFail      = "Не удалось переместить.";
sTxtWantReplace  = "Уже существует. Хотите заменить его?";
sTxtDirToSubdir  = "Вы не можете копировать/перемещать каталог в подкаталог.";
sTxtFileToStr    = "Вы не можете переместить файл в свой поток.";
sTxtCreDir       = "Создать новый каталог";
sTxtCreFile      = "Создать новый файл";
sTxtCreStr       = "Создать новый поток";
sTxtCreFail      = "Не удалось создать.";
sTxtInpName      = "Введите имя:";
sTxtDelDir       = "Удаление каталога с диска";
sTxtDelDirToBin  = "Удаление каталога в корзину";
sTxtDelFile      = "Удалить файл с диска";
sTxtDelFileToBin = "Удалить файл в корзину";
sTxtDelStr       = "Удалить поток";
sTxtDelFail      = "Не удалось удалить.";
sTxtWantDelete   = "Вы хотите удалить?";
sTxtToRecBin     = "В корзину";
sTxtFromDisk     = "С диска";
sTxtTo           = "в:";
sTxtToFile       = "в file:";
sTxtToStream     = "в поток:";
sTxtBadName      = "Неверное имя.";
sTxtBadChar      = "Имя содержит недопустимый символ";
sTxtRunScript    = "Запуск скрипта AkelPad";
sTxtJsVbsOnly    = "Вы можете запустить только файлы .JS и .VBS";
sTxtNoRunScript  = "Скрипт может быть запущен только с диска, на котором установлен AkelPad.";
sTxtInpArgs      = "Введите аргументы:";
sTxtNoFileProp   = "Ошибка: не может отобразить свойства файла.";
sTxtSetViewer    = "Выберите внешний просмотрщик файлов";
sTxtSetEditor    = "Выберите внешний редактор";
sTxtSetComparer  = "Выберите программу сравнения файлов";
sTxtDispName     = "Отображаемое имя";
sTxtFullName     = "Полный путь к исполняемому файлу";
sTxtAkelDir      = "каталог AkelPad";
sTxtEnvVar       = "переменная окружения";
sTxtAddPar       = "Дополнительные параметры:";
sTxtMustSpecify  = "Вы должны указать";
sTxtFavorites    = "Избранные";
sTxtAddFavorite  = "Добавить в избранное";
sTxtModFavorite  = "Изменить избранное";
sTxtDelFavorite  = "Удалить из избранного";
sTxtCleFavorite  = "Очистить избранное";
sTxtWantDelFav   = "Вы хотите, удалить из избранного?";
sTxtWantCleFavAp = "Вы хотите, чтобы удалить все избранные приложения?";
sTxtWantCleFavFo = "Вы хотите, чтобы удалить все избранные папки?";
sTxtOpenInFavor  = "Открыть в избранном";
sTxtGoToFavFold  = "Перейти в избранную папку";
sTxtCleHistory   = "Очистить историю каталогов";
sTxtSaveHistory  = "Сохранить историю при выходе";
sTxtAddAssoc     = "Добавить внутренние ассоциации";
sTxtModAssoc     = "Изменить ассоциацию";
sTxtDelAssoc     = "Удалить ассоциацию";
sTxtCleAssoc     = "Очистить список ассоциаций";
sTxtFileExtSep   = "Расширения файлов через запятую";
sTxtAssocExists  = "Ассоциация уже существует."
sTxtWantDelAssoc = "Вы хотите удалить внутреннюю ассоциацию файлов?";
sTxtWantCleAssoc = "Вы хотите удалить все внутренние ассоциации файлов?";
sTxtOpenInAssoc  = "Открыть (внутр. ассоц.)";
sTxtWait         = "Пожалуйста, подождите ...";

//Menu
sTxtFile         = "Файл";
sTxtDrive        = "Диск";
sTxtDirectory    = "Каталог";
sTxtShow         = "Вид";
sTxtWindow       = "Окно";
sTxtApplications = "Команды";
sTxtRun          = "Запуск";
sTxtExit         = "Выход";
sTxtProperties   = "Свойства";
sTxtCopyNames    = "Копировать в буфер...";
sTxtPath         = "Путь";
sTxtStream       = "Поток";
sTxtFilesList    = "Список файлов в каталоге";
sTxtStreamsList  = "Список потоков в файл";
sTxtLeftPanel    = "Левая панель";
sTxtRightPanel   = "Правая панель";
sTxtGoToParent   = "В родительский";
sTxtGoToSubDir   = "В подкаталог";
sTxtGoToMain     = "В корневой";
sTxtFavFolders   = "Избранные папки";
sTxtSpecFolders  = "Специальные папки";
sTxtHistory      = "История";
sTxtUndo         = "Назад";
sTxtRedo         = "Вперёд";
sTxtRightToLeft  = "Справа налево";
sTxtLeftToRight  = "Слева направо";
sTxtSwapPanels   = "Поменять панели";
sTxtQuickView    = "Быстрый просмотр";
sTxtColumns      = "Колонки";
sTxtOnlyName     = "Только имя";
sTxtAttributes   = "Атрибуты";
sTxtMoveLeft     = "Переместить влево";
sTxtMoveRight    = "Переместить вправо";
sTxtMoveUp       = "Переместить вверх";
sTxtMoveDown     = "Переместить вниз";
sTxtToLeftEdge   = "По левому краю";
sTxtToRightEdge  = "По правому краю";
sTxtToTopEdge    = "По верхнему краю";
sTxtToBottomEdge = "По нижнему краю";
sTxtCenter       = "По центру";
sTxtMaximize     = "Развернуть/Вернуть";
sTxtViewer       = "Просмотр";
sTxtEditor       = "Правка";
sTxtComparer     = "Сравнить";
sTxtCommandLine  = "Командная строка";
sTxtAkelScript   = "Скрипт AkelPad";
sTxtWithoutArgs  = "Без аргументов";
sTxtWithArgs     = "С аргументами";
- Russian - by Andrey_A_A

FileAndStream_2052.lng

Code:
/**************************************
FileAndStream.js ver. 2013-09-14
Interface language
Language:      ChineseSimplified (2052)
Translated by: cnnnc
**************************************/
sTxtFilter       = "筛选";
sTxtFileName     = "文件名";
sTxtStrName      = "NTFS 数据流名";
sTxtSize         = "大小";
sTxtTime         = "时间";
sTxtAttrib       = "属性";
sTxtOpenWin      = "打开 (Windows)";
sTxtMenu         = "菜单";
sTxtRename       = "重命名";
sTxtView         = "查看";
sTxtEdit         = "编辑";
sTxtCopy         = "复制";
sTxtToSecPanel   = "到第二个窗格";
sTxtToOwnPanel   = "到其所属窗格";
sTxtMove         = "移动";
sTxtCreate       = "创建";
sTxtDelete       = "删除";
sTxtRefresh      = "刷新";
sTxtCompare      = "比较";
sTxtNoFiles      = "<无文件>";
sTxtNoStreams    = "<无数据流>";
sTxtNoSupport    = "<驱动器未支持 NTFS 数据流>";
sTxtMainStream   = "<未命名 - 主数据流>";
sTxtNoDrive      = "驱动器不可用。请选择其它驱动器。";
sTxtNoDirRefr    = "目录不存在。将刷新文件列表。";
sTxtNoFileRefr   = "文件不存在。将刷新文件列表。";
sTxtNoStreamRefr = "数据流不存在。将刷新数据流列表。";
sTxtNoDirAcc     = "拒绝访问此目录。";
sTxtNoExists     = "不存在。";
sTxtDirNoExists  = "目录不存在。";
sTxtFileNoExists = "文件不存在。";
sTxtDirExists    = "目录已经存在。";
sTxtFileExists   = "文件已经存在。";
sTxtStrExists    = "数据流已经存在。";
sTxtNameExists   = "名称已经存在。";
sTxtRenDir       = "重命名目录";
sTxtRenFile      = "重命名文件";
sTxtRenStr       = "重命名数据流";
sTxtRenFail      = "重命名失败。";
sTxtNewName      = "新名称:";
sTxtCopDir       = "复制目录";
sTxtCopFile      = "复制文件";
sTxtCopStr       = "复制数据流";
sTxtCopFail      = "复制失败。";
sTxtMovDir       = "移动目录";
sTxtMovFile      = "移动文件";
sTxtMovStr       = "移动数据流";
sTxtMovFail      = "移动失败。";
sTxtWantReplace  = "已经存在。是否想要替换?";
sTxtDirToSubdir  = "你不能 复制/移动 目录到其子目录。";
sTxtFileToStr    = "你不能 移动 文件到其所属的数据流。";
sTxtCreDir       = "创建新目录";
sTxtCreFile      = "创建新文件";
sTxtCreStr       = "创建新数据流";
sTxtCreFail      = "创建失败。";
sTxtInpName      = "请输入名称:";
sTxtDelDir       = "从磁盘上删除目录";
sTxtDelDirToBin  = "删除目录到回收站";
sTxtDelFile      = "从磁盘上删除文件";
sTxtDelFileToBin = "删除文件到回收站";
sTxtDelStr       = "删除数据流";
sTxtDelFail      = "删除失败。";
sTxtWantDelete   = "是否想要删除?";
sTxtToRecBin     = "到回收站";
sTxtFromDisk     = "从磁盘";
sTxtTo           = "到:";
sTxtToFile       = "到文件:";
sTxtToStream     = "到数据流:";
sTxtBadName      = "非法名称。";
sTxtBadChar      = "名称中含有非法字符。";
sTxtRunScript    = "运行 AkelPad 脚本";
sTxtJsVbsOnly    = "仅可以运行扩展为 .JS 或 .VBS 的文件";
sTxtNoRunScript  = "只能运行 AkelPad 安装所在的驱动器上的 AkelPad 脚本。";
sTxtInpArgs      = "请输入参数:";
sTxtNoFileProp   = "错误: 无法显示文件属性。";
sTxtSetViewer    = "设置外置文件查看器";
sTxtSetEditor    = "设置外置编辑器";
sTxtSetComparer  = "设置外置文件比较器";
sTxtDispName     = "显示名称";
sTxtFullName     = "带完整路径的可执行文件名";
sTxtAkelDir      = "AkelPad 目录";
sTxtEnvVar       = "环境变量";
sTxtAddPar       = "附加参数:";
sTxtMustSpecify  = "您必须指定";
sTxtFavorites    = "收藏夹";
sTxtAddFavorite  = "添加收藏";
sTxtModFavorite  = "修改收藏";
sTxtDelFavorite  = "删除收藏";
sTxtCleFavorite  = "清除收藏列表";
sTxtWantDelFav   = "是否想要从收藏中删除?";
sTxtWantCleFavAp = "是否想要删除所有收藏的程序?";
sTxtWantCleFavFo = "是否想要删除所有收藏夹?";
sTxtOpenInFavor  = "打开方式";
sTxtGoToFavFold  = "转到收藏夹";
sTxtCleHistory   = "清除历史目录";
sTxtSaveHistory  = "退出时保存历史";
sTxtAddAssoc     = "添加内部关联";
sTxtModAssoc     = "修改关联";
sTxtDelAssoc     = "删除关联";
sTxtCleAssoc     = "清除关联列表";
sTxtFileExtSep   = "文件名扩展以逗号分隔";
sTxtAssocExists  = "已经存在关联。";
sTxtWantDelAssoc = "是否想要删除文件的内部关联?";
sTxtWantCleAssoc = "是否想要删除所有文件的内部关联?";
sTxtOpenInAssoc  = "打开 (内部关联)";
sTxtWait         = "请稍候...";

//Menu
sTxtFile         = "文件";
sTxtDrive        = "驱动器";
sTxtDirectory    = "目录";
sTxtShow         = "显示";
sTxtWindow       = "窗口";
sTxtApplications = "程序";
sTxtRun          = "运行";
sTxtExit         = "退出";
sTxtProperties   = "属性";
sTxtCopyNames    = "复制名称";
sTxtPath         = "路径";
sTxtStream       = "数据流";
sTxtFilesList    = "目录中的文件列表";
sTxtStreamsList  = "文件中的数据流列表";
sTxtLeftPanel    = "左窗";
sTxtRightPanel   = "右窗";
sTxtGoToParent   = "转到上一层";
sTxtGoToSubDir   = "转到下一层";
sTxtGoToMain     = "转到根目录";
sTxtFavFolders   = "收藏夹";
sTxtSpecFolders  = "特殊文件夹";
sTxtHistory      = "历史";
sTxtUndo         = "撤消";
sTxtRedo         = "恢复";
sTxtRightToLeft  = "右 -> 左";
sTxtLeftToRight  = "左 -> 右";
sTxtSwapPanels   = "交换窗口";
sTxtQuickView    = "快速查看";
sTxtColumns      = "列";
sTxtOnlyName     = "仅名称";
sTxtAttributes   = "属性";
sTxtMoveLeft     = "左移";
sTxtMoveRight    = "右移";
sTxtMoveUp       = "上移";
sTxtMoveDown     = "下移";
sTxtToLeftEdge   = "到左边缘";
sTxtToRightEdge  = "到右边缘";
sTxtToTopEdge    = "到顶边缘";
sTxtToBottomEdge = "到底边缘";
sTxtCenter       = "居中";
sTxtMaximize     = "最大化";
sTxtViewer       = "查看器";
sTxtEditor       = "编辑器";
sTxtComparer     = "比较器";
sTxtCommandLine  = "命令提示符";
sTxtAkelScript   = "AkelPad 脚本";
sTxtWithoutArgs  = "无参数";
sTxtWithArgs     = "带参数";
- ChineseSimplified - by cnnnc


Last edited by KDJ on Mon Jan 06, 2014 12:48 pm; edited 18 times in total
Back to top
View user's profile Send private message
Infocatcher



Joined: 06 Aug 2007
Posts: 1612

PostPosted: Sat Mar 17, 2012 7:21 pm    Post subject: Reply with quote

moveResizeWindow.js
Code:
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=17270#17270
// http://infocatcher.ucoz.net/js/akelpad_scripts/moveResizeWindow.js

// (c) Infocatcher 2012
// version 0.1.1 - 2012-04-17

// Move or/and align AkelPad's main window

// Icons for context menu:
//   http://infocatcher.ucoz.net/js/akelpad_scripts/moveResizeWindow_icons.zip
//   (based on Actual Window Manager's icons: http://www.actualtools.com/windowmanager/)

// Arguments:
//   -resize={width}*{height}
//          =800*600          - resize window to 800 x 600
//          =100%*            - resize window to 100% of work area width
//          =*100%            - resize window to 100% of work area height
//          =100%*100%        - resize window to work area (like maximize)
//   -move={x}*{y}
//        =center*center      - move window to center of work area
//        =left*top           - move window to top left corner of work area
//        =right*top          - move window to top right corner of work area
//        =left*bottom        - move window to bottom left corner of work area
//        =right*bottom       - move window to bottom right corner of work area
//        =left*              - move window to left side of work area
//        =10*150             - move to x=10, y=150
//   -allowRestore=true       - allow save last used size and position and restore them after second call

var hMainWnd = AkelPad.GetMainWnd();
var oSys = AkelPad.SystemFunction();

if(hMainWnd && !AkelPad.IsInclude()) {
   var resize = AkelPad.GetArgValue("resize", "");
   var move   = AkelPad.GetArgValue("move",   "");

   var allowRestore = AkelPad.GetArgValue("allowRestore", true);
   if(allowRestore)
      var pos = getWindowPos(hMainWnd);
   var changed = false;
   if(resize)
      resizeWindow(hMainWnd, resize) && (changed = true);
   if(move)
      moveWindow(hMainWnd, move) && (changed = true);
   if(allowRestore) {
      if(changed)
         saveWindowPos("main", hMainWnd, pos);
      else
         restoreWindowPos("main", hMainWnd);
   }
}

function resizeWindow(hWnd, resize, hWndParent) {
   var tokens = resize.split("*");
   var rsW = tokens[0];
   var rsH = tokens[1];

   var rcWnd = getWindowRect(hWnd);
   var rcWork = hWndParent
      ? getWindowRect(hWndParent)
      : getWorkArea(hWnd);

   var ww = rcWork.right - rcWork.left;
   var wh = rcWork.bottom - rcWork.top;

   var w = rcWnd.right - rcWnd.left;
   var h = rcWnd.bottom - rcWnd.top;

   if(rsW.charAt(rsW.length - 1) == "%")
      rsW = Math.round(parseFloat(rsW)/100*ww);
   else if(!rsW)
      rsW = w;
   else
      rsW = parseInt(rsW);

   if(rsH.charAt(rsH.length - 1) == "%")
      rsH = Math.round(parseFloat(rsH)/100*wh);
   else if(!rsH)
      rsH = h;
   else
      rsH = parseInt(rsH);

   rsW = Math.min(ww, rsW);
   rsH = Math.min(wh, rsH);

   if(rsW == w && rsH == h)
      return false;
   return _resizeWindow(hWnd, rsW, rsH);
}
function moveWindow(hWnd, move, hWndParent) {
   var tokens = move.split("*");
   var mvX = tokens[0];
   var mvY = tokens[1];

   var rcWnd = getWindowRect(hWnd);
   var rcWork = hWndParent
      ? getWindowRect(hWndParent)
      : getWorkArea(hWnd);

   var w = rcWnd.right - rcWnd.left;
   var h = rcWnd.bottom - rcWnd.top;

   if     (mvX == "left")   mvX = rcWork.left;
   else if(mvX == "center") mvX = centerX(rcWnd, rcWork);
   else if(mvX == "right")  mvX = rcWork.right - w;
   else if(!mvX)            mvX = rcWnd.left;
   else                     mvX = parseInt(mvX);

   if     (mvY == "top")    mvY = rcWork.top;
   else if(mvY == "center") mvY = centerY(rcWnd, rcWork);
   else if(mvY == "bottom") mvY = rcWork.bottom - h;
   else if(!mvY)            mvY = rcWnd.top;
   else                     mvY = parseInt(mvY);

   mvX = Math.max(rcWork.left, Math.min(rcWork.right - w,  mvX));
   mvY = Math.max(rcWork.top,  Math.min(rcWork.bottom - h, mvY));

   if(mvX == rcWnd.left && mvY == rcWnd.top)
      return false;
   return _moveWindow(hWnd, mvX, mvY);
}
function centerX(rcWnd, rcWndParent) {
   return rcWndParent.left + ((rcWndParent.right - rcWndParent.left)/2 - (rcWnd.right - rcWnd.left)/2);
}
function centerY(rcWnd, rcWndParent) {
   return rcWndParent.top + ((rcWndParent.bottom - rcWndParent.top)/2 - (rcWnd.bottom - rcWnd.top)/2);
}

function getWindowPos(hWnd) {
   var rcWnd = getWindowRect(hWnd);
   if(!rcWnd)
      return false;
   return rcWnd.left + "x" + rcWnd.top + "|"
      + (rcWnd.right - rcWnd.left) + "x" + (rcWnd.bottom - rcWnd.top);
}
function saveWindowPos(windowId, hWnd, pos) {
   if(!pos)
      pos = getWindowPos(hWnd);
   if(!pos)
      return;

   var oSet = AkelPad.ScriptSettings();
   if(!oSet.Begin(WScript.ScriptBaseName, 0x2 /*POB_SAVE*/))
      return false;

   oSet.Write(windowId, 3 /*PO_STRING*/, pos);
   return oSet.End();
}
function restoreWindowPos(windowId, hWnd) {
   var oSet = AkelPad.ScriptSettings();
   if(!oSet.Begin(WScript.ScriptBaseName, 0x1 /*POB_READ*/))
      return false;

   var pos = oSet.Read(windowId, 3 /*PO_STRING*/, "");
   oSet.End();
   if(!/^(\d+)x(\d+)\|(\d+)x(\d+)$/.test(pos))
      return false;

   var x = +RegExp.$1;
   var y = +RegExp.$2;
   var w = +RegExp.$3;
   var h = +RegExp.$4;
   return oSys.Call("user32::SetWindowPos", hWnd, 0, x, y, w, h, 0x14 /*SWP_NOZORDER|SWP_NOACTIVATE*/);
}

function getWorkArea(hWnd) {
   var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
   if(!lpRect)
      return null;
   oSys.Call("user32::GetWindowRect", hWnd, lpRect);

   var hMonitor = oSys.Call("user32::MonitorFromRect", lpRect, 0x2 /*MONITOR_DEFAULTTONEAREST*/);

   if(hMonitor) {
      //typedef struct tagMONITORINFO {
      //  DWORD cbSize;
      //  RECT  rcMonitor;
      //  RECT  rcWork;
      //  DWORD dwFlags;
      //} MONITORINFO, *LPMONITORINFO;
      var sizeofMonitorInfo = 4 + 16 + 16 + 4;
      var lpMi = AkelPad.MemAlloc(sizeofMonitorInfo);
      if(lpMi) {
         AkelPad.MemCopy(lpMi, sizeofMonitorInfo, 3 /*DT_DWORD*/);
         oSys.Call("user32::GetMonitorInfo" + _TCHAR, hMonitor, lpMi);
         var rcWork = parseRect(lpMi + 4 + 16);
         AkelPad.MemFree(lpMi);
      }
   }
   else { //?
      oSys.Call("user32::SystemParametersInfo" + _TCHAR, 48 /*SPI_GETWORKAREA*/, 0, lpRect, 0);
      var rcWork = parseRect(lpRect);
   }
   AkelPad.MemFree(lpRect);
   return rcWork;
}
function _moveWindow(hWnd, x, y) {
   return oSys.Call("user32::SetWindowPos", hWnd, 0, x, y, 0, 0, 0x15 /*SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE*/);
}
function _resizeWindow(hWnd, w, h) {
   return oSys.Call("user32::SetWindowPos", hWnd, 0, 0, 0, w, h, 0x16 /*SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE*/);
}
function getWindowRect(hWnd) {
   var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
   if(!lpRect)
      return null;
   oSys.Call("user32::GetWindowRect", hWnd, lpRect);
   var rcWnd = parseRect(lpRect);
   AkelPad.MemFree(lpRect);
   return rcWnd;
}
function parseRect(lpRect) {
   return {
      left:   AkelPad.MemRead(lpRect,      3 /*DT_DWORD*/),
      top:    AkelPad.MemRead(lpRect +  4, 3 /*DT_DWORD*/),
      right:  AkelPad.MemRead(lpRect +  8, 3 /*DT_DWORD*/),
      bottom: AkelPad.MemRead(lpRect + 12, 3 /*DT_DWORD*/)
   };
}
<download>
Move or/and align AkelPad's main window
Context menu example (Russian)


Code:
  "В&ыровнять"
  {
    -"&Вверх влево"      Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=left*top")      Icon("%a\AkelFiles\Plugs\icons\window_align_left-top.ico", 0)
    -"&Вверх"            Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=center*top")    Icon("%a\AkelFiles\Plugs\icons\window_align_center-top.ico", 0)
    -"&Вверх вправо"     Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=right*top")     Icon("%a\AkelFiles\Plugs\icons\window_align_right-top.ico", 0)
    SEPARATOR                                                                                                                             
    -"По &центру влево"  Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=left*center")   Icon("%a\AkelFiles\Plugs\icons\window_align_left-center.ico", 0)
    -"По &центру"        Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=center*center") Icon("%a\AkelFiles\Plugs\icons\window_align_center-center.ico", 0)
    -"По &центру вправо" Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=right*center")  Icon("%a\AkelFiles\Plugs\icons\window_align_right-center.ico", 0)
    SEPARATOR                                                                                                                             
    -"В&низ влево"       Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=left*bottom")   Icon("%a\AkelFiles\Plugs\icons\window_align_left-bottom.ico", 0)
    -"В&низ по центру"   Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=center*bottom") Icon("%a\AkelFiles\Plugs\icons\window_align_center-bottom.ico", 0)
    -"В&низ вправо"      Call("Scripts::Main", 1, "moveResizeWindow.js", "-move=right*bottom")  Icon("%a\AkelFiles\Plugs\icons\window_align_right-bottom.ico", 0)
  }
  "Рас&тянуть"
  {
    -"В&низ влево + 1280x720" Call("Scripts::Main", 1, "moveResizeWindow.js", "-resize=1280*720 -move=left*bottom")
    SEPARATOR
    -"Растянуть по &ширине" Call("Scripts::Main", 1, "moveResizeWindow.js", "-resize=100%%* -move=left*") Icon("%a\AkelFiles\Plugs\icons\window_stretch_width.ico", 0)
    -"Растянуть по &высоте" Call("Scripts::Main", 1, "moveResizeWindow.js", "-resize=*100%% -move=*top")  Icon("%a\AkelFiles\Plugs\icons\window_stretch_height.ico", 0)
  }



Last edited by Infocatcher on Tue Apr 17, 2012 8:23 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Infocatcher



Joined: 06 Aug 2007
Posts: 1612

PostPosted: Sat Mar 17, 2012 7:23 pm    Post subject: Reply with quote

tileTabs.js
Code:
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=17271#17271
// http://infocatcher.ucoz.net/js/akelpad_scripts/tileTabs.js
// https://github.com/Infocatcher/AkelPad_scripts/blob/master/tileTabs.js

// (c) Infocatcher 2012-2014
// version 0.1.3 - 2014-04-13

// Tile current tab with next selected:
// select first tab, call script and then select second tab.
// Required MDI window mode and timer.js library!
// https://github.com/Infocatcher/AkelPad_scripts/blob/master/Include/timer.js
// (or use -noBlink=true argument to work without timer.js)

// Usage:
//   Call("Scripts::Main", 1, "tileTabs.js")         - tile vertical
//   Call("Scripts::Main", 1, "tileTabs.js", "o")    - tile vertical and preserve tabs order
//   Call("Scripts::Main", 1, "tileTabs.js", "h")    - tile horizontal
//   Call("Scripts::Main", 1, "tileTabs.js", "h o")  - tile horizontal and preserve tabs order

// Also use -noBlink=true to disable blink in status bar (and just show "Select tab!" text)

function _localize(s) {
   var strings = {
      "No tabs!": {
         ru: "Отсутствуют вкладки!"
      },
      "MDI window mode required!": {
         ru: "Требуется оконный режим MDI!"
      },
      "Select tab!": {
         ru: "Выберите вкладку!"
      }
   };
   var lng;
   switch(AkelPad.GetLangId(1 /*LANGID_PRIMARY*/)) {
      case 0x19: lng = "ru"; break;
      default:   lng = "en";
   }
   _localize = function(s) {
      return strings[s] && strings[s][lng] || s;
   };
   return _localize(s);
}

var hScript = AkelPad.ScriptHandle(WScript.ScriptName, 3 /*SH_FINDSCRIPT*/);
if(hScript && AkelPad.ScriptHandle(hScript, 13 /*SH_GETMESSAGELOOP*/)) {
   // Script is running, second call close it
   AkelPad.ScriptHandle(hScript, 33 /*SH_CLOSESCRIPT*/);
   WScript.Quit();
}

var hMainWnd = AkelPad.GetMainWnd();
var oSys = AkelPad.SystemFunction();

if(
   hMainWnd
   && AkelPad.IsMDI() == 1 /*WMD_MDI*/
) {
   var hMdiClient = AkelPad.SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 12 /*MI_WNDMDICLIENT*/, 0);
   var lpFrame = AkelPad.SendMessage(hMainWnd, 1288 /*AKD_FRAMEFIND*/, 1 /*FWF_CURRENT*/, 0);
   var lpFrame2;

   if(hMdiClient && lpFrame) {
      var statusbar = new Statusbar();
      statusbar.save();
      var statusMsg = _localize("Select tab!");
      statusbar.set(statusMsg);

      if(
         !AkelPad.GetArgValue("noBlink", false)
         && AkelPad.Include("timer.js")
      ) {
         var showDelay = 600;
         var hideDelay = 150;
         // show -> [showDelay] -> hide -> [hideDelay] -> show -> [showDelay] -> hide
         var timerHide = setTimeout(function() {
            statusbar.set("");
            clearTimeout(timerHide);
            timerHide = setInterval(function() {
               statusbar.set("");
            }, showDelay + hideDelay, timerHide);
         }, showDelay);
         var timerShow = setInterval(function() {
            statusbar.set(statusMsg);
         }, showDelay + hideDelay);
         var stopTimers = function() {
            clearInterval(timerHide);
            clearInterval(timerShow);
         };
      }
   }

   if(
      hMdiClient && lpFrame
      && AkelPad.WindowSubClass(
         1 /*WSC_MAINPROC*/,
         mainCallback,
         0x416 /*AKDN_FRAME_ACTIVATE*/,
         0x418 /*AKDN_FRAME_DESTROY*/
      )
   ) {
      AkelPad.ScriptNoMutex(); // Allow other scripts running
      AkelPad.WindowGetMessage(); // Message loop
      AkelPad.WindowUnsubClass(1 /*WSC_MAINPROC*/);

      stopTimers && stopTimers();
      statusbar.restore();
      if(lpFrame2) {
         var tileHorizontal, useTabsOrder;
         for(var i = 0, l = WScript.Arguments.length; i < l; ++i) {
            switch(WScript.Arguments(i)) {
               case "h": tileHorizontal = true; break;
               case "o": useTabsOrder = true;
            }
         }
         tileTabs(lpFrame, lpFrame2, tileHorizontal, useTabsOrder);
      }
      //AkelPad.SendMessage(hMainWnd, 1285 /*AKD_FRAMEACTIVATE*/, 0, lpFrame);
   }
   else {
      stopTimers && stopTimers();
      statusbar && statusbar.restore();
      AkelPad.MessageBox(hMainWnd, _localize("No tabs!"), WScript.ScriptName, 48 /*MB_ICONEXCLAMATION*/);
   }
}
else {
   AkelPad.MessageBox(hMainWnd, _localize("MDI window mode required!"), WScript.ScriptName, 48 /*MB_ICONEXCLAMATION*/);
}
function mainCallback(hWnd, uMsg, wParam, lParam) {
   if(uMsg == 0x416 /*AKDN_FRAME_ACTIVATE*/) {
      if(lParam != lpFrame) {
         lpFrame2 = lParam;
         oSys.Call("user32::PostQuitMessage", 0); // Exit message loop
      }
   }
   else if(uMsg == 0x418 /*AKDN_FRAME_DESTROY*/) {
      if(lParam == lpFrame)
         oSys.Call("user32::PostQuitMessage", 0); // Exit message loop
   }
}

function tileTabs(lpFrame, lpFrame2, tileHorizontal, useTabsOrder) {
   var lpRect = AkelPad.MemAlloc(16 /*sizeof(RECT)*/);
   if(!lpRect)
      return;
   var rcClient = oSys.Call("user32::GetClientRect", hMdiClient, lpRect)
      && parseRect(lpRect);
   AkelPad.MemFree(lpRect);
   if(!rcClient)
      return;

   var hWndMdi  = AkelPad.SendMessage(hMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 1 /*FI_WNDEDITPARENT*/, lpFrame);
   var hWndMdi2 = AkelPad.SendMessage(hMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 1 /*FI_WNDEDITPARENT*/, lpFrame2);

   AkelPad.SendMessage(hMdiClient, 0x0223 /*WM_MDIRESTORE*/, hWndMdi2, 0);
   AkelPad.SendMessage(hMdiClient, 0x0223 /*WM_MDIRESTORE*/, hWndMdi, 0);
   AkelPad.SendMessage(hMainWnd, 1285 /*AKD_FRAMEACTIVATE*/, 0, lpFrame2);

   var w = rcClient.right - rcClient.left;
   var h = rcClient.bottom - rcClient.top;

   if(useTabsOrder) {
      var pos  = AkelPad.SendMessage(hMainWnd, 1294 /*AKD_FRAMEINDEX*/, 0, lpFrame);
      var pos2 = AkelPad.SendMessage(hMainWnd, 1294 /*AKD_FRAMEINDEX*/, 0, lpFrame2);
      if(pos2 < pos) {
         var tmp = hWndMdi;
         hWndMdi = hWndMdi2;
         hWndMdi2 = tmp;
      }
   }

   if(tileHorizontal) {
      h /= 2;
      moveMdiWindow(hWndMdi,  rcClient.left, rcClient.top,     w, h);
      moveMdiWindow(hWndMdi2, rcClient.left, rcClient.top + h, w, h);
   }
   else {
      w /= 2;
      moveMdiWindow(hWndMdi,  rcClient.left,     rcClient.top, w, h);
      moveMdiWindow(hWndMdi2, rcClient.left + w, rcClient.top, w, h);
   }
}
function moveMdiWindow(hWndMdi, x, y, w, h) {
   oSys.Call("user32::MoveWindow", hWndMdi, x, y, w, h, true /*bRepaint*/);
}
function parseRect(lpRect) {
   return {
      left:   AkelPad.MemRead(lpRect,      3 /*DT_DWORD*/),
      top:    AkelPad.MemRead(lpRect +  4, 3 /*DT_DWORD*/),
      right:  AkelPad.MemRead(lpRect +  8, 3 /*DT_DWORD*/),
      bottom: AkelPad.MemRead(lpRect + 12, 3 /*DT_DWORD*/)
   };
}

function Statusbar() {
   this.get = this.set = this.save = this.restore = function() {};

   // Based on Instructor's code: http://akelpad.sourceforge.net/forum/viewtopic.php?p=13656#13656
   var hWndStatus = oSys.Call("user32::GetDlgItem", hMainWnd, 10002 /*ID_STATUS*/);
   if(!hWndStatus || !oSys.Call("user32::IsWindowVisible", hWndStatus))
      return;
   var nParts = AkelPad.SendMessage(hWndStatus, 1030 /*SB_GETPARTS*/, 0, 0);
   if(nParts <= 5)
      return;
   var _origStatus, _customStatus;
   var _this = this;
   function buffer(callback) {
      var lpTextBuffer = AkelPad.MemAlloc(1024 * _TSIZE);
      if(lpTextBuffer) {
         var ret = callback.call(_this, lpTextBuffer);
         AkelPad.MemFree(lpTextBuffer);
         return ret;
      }
      return undefined;
   }
   this.get = function() {
      return buffer(function(lpTextBuffer) {
         AkelPad.SendMessage(hWndStatus, _TSTR ? 1037 /*SB_GETTEXTW*/ : 1026 /*SB_GETTEXTA*/, nParts - 1, lpTextBuffer);
         return AkelPad.MemRead(lpTextBuffer, _TSTR);
      });
   };
   this.set = function(pStatusText) {
      buffer(function(lpTextBuffer) {
         _customStatus = pStatusText;
         AkelPad.MemCopy(lpTextBuffer, pStatusText, _TSTR);
         AkelPad.SendMessage(hWndStatus, _TSTR ? 1035 /*SB_SETTEXTW*/ : 1025 /*SB_SETTEXTA*/, nParts - 1, lpTextBuffer);
      });
   };
   this.save = function() {
      _origStatus = this.get();
   };
   this.restore = function() {
      if(_origStatus != undefined && this.get() == _customStatus)
         this.set(_origStatus);
   };
}
<download | mirror | development version>
Tile current tab with next selected: select first tab, call script and then select second tab.
Required MDI window mode and timer.js library!


Last edited by Infocatcher on Sat Apr 12, 2014 8:40 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1334
Location: Poland

PostPosted: Wed Mar 21, 2012 9:17 pm    Post subject: Reply with quote

Operations on the text from plugins: Coder, ContextMenu, Hotkeys, SpecialChar and ToolBar.
Required to include: FileAndStream_functions.js
For syntax highlighting uses: akelmenu.coder by Infocatcher.

This is extended version of the script: PlugTextReadFromIni.js

PluginText.js

Code:
// PluginText.js - ver. 2013-09-17 (x86/x64)
//
// Operations on the text from plugins: Coder, ContextMenu, Hotkeys, SpecialChar and ToolBar*.
// The text is read from plugin settings (.ini file or registry).
//
// Usage:
// Call("Scripts::Main", 1, "PluginText.js")
// Required to include: FileAndStream_functions.js
//
// For the syntax highlighting uses akelmenu.coder by Infocatcher:
// http://infocatcher.ucoz.net/akelpad/coder/_akelmenu.coder
//
// Some keyboard shortcuts:
// F8 (Del) - move text file to the Recycle Bin,
// Shift+F8 (Shift+Del) - remove text file from disk,
// Ctrl+A - select all items on list.

var oSys       = AkelPad.SystemFunction();
var hInstDLL   = AkelPad.GetInstanceDll();
var sClassName = "AkelPad::Scripts::" + WScript.ScriptName + "::" + hInstDLL;
var hWndDlg    = oSys.Call("User32::FindWindowExW", 0, 0, sClassName, 0);

if (hWndDlg)
{
  if (! oSys.Call("User32::IsWindowVisible", hWndDlg))
    oSys.Call("User32::ShowWindow", hWndDlg, 8 /*SW_SHOWNA*/);
  if (oSys.Call("User32::IsIconic", hWndDlg))
    oSys.Call("User32::ShowWindow", hWndDlg, 9 /*SW_RESTORE*/);

  oSys.Call("User32::SetForegroundWindow", hWndDlg);
}
else
{
  if (! AkelPad.Include("FileAndStream_functions.js"))
    WScript.Quit();

  var sTxtNoTexts      = "There are no any texts in plugins settings.";
  var sTxtSetInReg     = "Settings stored in registry";
  var sTxtSetInIni     = "Settings stored in file AkelPad.ini";
  var sTxtDir          = "Directory for text files: ";
  var sTxtPlugin       = "Plugin";
  var sTxtKeyTextName  = "Key - text name";
  var sTxtTextFile     = "Text file associated with the key";
  var sTxtEditText     = "Edit plugin text";
  var sTxtSaveTextFile = "Save plugin text in text file";
  var sTxtEditIniFile  = "Edit .ini file";
  var sTxtOpenRegEdit  = "Open in RegEdit";
  var sTxtEditTextFile = "Edit text file";
  var sTxtLoadText     = "Load text file to plugin key";
  var sTxtRenameFile   = "Rename text file";
  var sTxtDeleteFile   = "Delete text file";
  var sTxtChangeDir    = "Change directory for text files";
  var sTxtSaved        = "Saved:";
  var sTxtNoSaved      = "Not saved:";
  var sTxtNoFiles      = "No file(s):";
  var sTxtWantSave     = "Do you want to extract selected plugin keys and save in text files?";
  var sTxtWantLoad     = "Do you want to load selected text files to plugin keys?";
  var sTxtNewName      = "new name:";
  var sTxtBadName      = "Illegal name.";
  var sTxtBadChar      = "Illegal character in the name.";
  var sTxtWantDelete   = "Do you want to delete selected text files?";
  var sTxtDeleted      = "Deleted:";
  var sTxtNoDeleted    = "Not deleted:";
  var sTxtEnvVar       = "environment variable";
  var sTxtAkelDir      = "AkelPad directory";
  var sTxtPlugDir      = "plugins directory";
  var sTxtDirNoExists  = "This directory does not exist. Do you want to create it?";
  var sTxtDirCreFail   = "Failed to create this directory.";

  var DT_UNICODE = 1;
  var DT_QWORD   = 2;
  var DT_DWORD   = 3;
  var DT_WORD    = 4;
  var DT_BYTE    = 5;

  var hMainWnd    = AkelPad.GetMainWnd();
  var sScriptName = "Plugin Text";
  var bSetInReg   = IsSettingsInRegistry();
  var nBufSize    = 1024;
  var lpBuffer    = AkelPad.MemAlloc(nBufSize);
  var lpLVITEM    = AkelPad.MemAlloc(_X64 ? 72 : 60); //sizeof(LVITEM)

  AkelPad.MemCopy(lpLVITEM, 0x0001 /*LVIF_TEXT*/, DT_DWORD);
  AkelPad.MemCopy(lpLVITEM + (_X64 ? 24 : 20), lpBuffer, DT_QWORD);
  AkelPad.MemCopy(lpLVITEM + (_X64 ? 32 : 24), nBufSize, DT_DWORD);

  var nWndPosX  = 240;
  var nWndPosY  = 160;
  var nWndPosW  = 460;
  var nWndPosH  = 340;
  var oPlugText = {};
  var sTextDirS;
  var hWndDlg;
  var hSubClass;

  ReadWriteIni(false);

  if ((! sTextDirS) || (! IsDirExists(ExpandDirName(sTextDirS))))
    sTextDirS = AkelPad.GetAkelDir(4 /*ADTYPE_PLUGS*/) + "\\";
  else if (sTextDirS.slice(-1) != "\\")
    sTextDirS += "\\";

  var CLASS = 0;
  var HWND  = 1;
  var STYLE = 2;
  var TXT   = 3;

  var aWnd     = [];
  var IDINFOS  = 2000;
  var IDDIRS   = 2001;
  var IDPLUGLV = 2002;
  var IDF1B    = 2003;
  var IDF2B    = 2004;
  var IDF3B    = 2005;
  var IDF4B    = 2006;
  var IDF5B    = 2007;
  var IDF7B    = 2008;
  var IDF8B    = 2009;
  var IDF9B    = 2010;

  //0x50000000 - WS_VISIBLE|WS_CHILD
  //0x50000080 - WS_VISIBLE|WS_CHILD|SS_NOPREFIX
  //0x50808009 - WS_VISIBLE|WS_CHILD|WS_BORDER|LVS_NOSORTHEADER|LVS_SHOWSELALWAYS|LVS_REPORT
  //Windows       CLASS,        HWND,      STYLE, TXT
  aWnd[IDINFOS ]=["STATIC",        0, 0x50000080, bSetInReg ? sTxtSetInReg : sTxtSetInIni];
  aWnd[IDDIRS  ]=["STATIC",        0, 0x50000080, sTxtDir + ExpandDirName(sTextDirS)];
  aWnd[IDPLUGLV]=["SysListView32", 0, 0x50808009, ""];
  aWnd[IDF1B   ]=["BUTTON",        0, 0x50000000, sTxtEditText     + " (F1)"];
  aWnd[IDF2B   ]=["BUTTON",        0, 0x50000000, sTxtSaveTextFile + " (F2)"];
  aWnd[IDF3B   ]=["BUTTON",        0, 0x50000000, (bSetInReg ? sTxtOpenRegEdit : sTxtEditIniFile) + " (F3)"];
  aWnd[IDF4B   ]=["BUTTON",        0, 0x50000000, sTxtEditTextFile + " (F4)"];
  aWnd[IDF5B   ]=["BUTTON",        0, 0x50000000, sTxtLoadText     + " (F5)"];
  aWnd[IDF7B   ]=["BUTTON",        0, 0x50000000, sTxtRenameFile   + " (F7)"];
  aWnd[IDF8B   ]=["BUTTON",        0, 0x50000000, sTxtDeleteFile   + " (F8)"];
  aWnd[IDF9B   ]=["BUTTON",        0, 0x50000000, sTxtChangeDir    + " (F9)"];

  AkelPad.WindowRegisterClass(sClassName);

  hWndDlg =
    oSys.Call("User32::CreateWindowEx" + _TCHAR,
      0,              //dwExStyle
      sClassName,     //lpClassName
      sScriptName,    //lpWindowName
      0x90CC0000,     //WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX
      nWndPosX,       //x
      nWndPosY,       //y
      nWndPosW,       //nWidth
      nWndPosH,       //nHeight
      hMainWnd,       //hWndParent
      0,              //ID
      hInstDLL,       //hInstance
      DialogCallback);//Script function callback. To use it class must be registered by WindowRegisterClass.

  //Allow other scripts running
  AkelPad.ScriptNoMutex();

  //Message loop
  AkelPad.WindowGetMessage();

  AkelPad.WindowUnregisterClass(sClassName);
  AkelPad.MemFree(lpBuffer);
  AkelPad.MemFree(lpLVITEM);
}

function DialogCallback(hWnd, uMsg, wParam, lParam)
{
  if (uMsg == 1) //WM_CREATE
  {
    var hGuiFont = oSys.Call("Gdi32::GetStockObject", 17 /*DEFAULT_GUI_FONT*/);
    var i;

    for (i = 2000; i < aWnd.length; ++i)
    {
      aWnd[i][HWND] =
        oSys.Call("User32::CreateWindowEx" + _TCHAR,
          0,              //dwExStyle
          aWnd[i][CLASS], //lpClassName
          0,              //lpWindowName
          aWnd[i][STYLE], //dwStyle
          0,              //x
          0,              //y
          0,              //nWidth
          0,              //nHeight
          hWnd,           //hWndParent
          i,              //ID
          hInstDLL,       //hInstance
          0);             //lpParam

      //Set font and text
      AkelPad.SendMessage(aWnd[i][HWND], 48 /*WM_SETFONT*/, hGuiFont, true);
      oSys.Call("User32::SetWindowText" + _TCHAR, aWnd[i][HWND], aWnd[i][TXT]);
    }

    //To capture NM_RETURN and LVN_KEYDOWN in ListView
    hSubClass = AkelPad.WindowSubClass(aWnd[IDPLUGLV][HWND], ListCallback, 0x87 /*WM_GETDLGCODE*/, 256 /*WM_KEYDOWN*/);

    //Insert columns and set extended style to ListView
    InsertColumnsLV();

    FillPlugList();
    if (! GetItemCountLV())
    {
      AkelPad.MessageBox(hWnd, sTxtNoTexts, sScriptName, 0x00000030 /*MB_ICONWARNING*/);
      AkelPad.SendMessage(hWnd, 16 /*WM_CLOSE*/, 0, 0);
    }
  }

  else if (uMsg == 7) //WM_SETFOCUS
    oSys.Call("User32::SetFocus", aWnd[IDPLUGLV][HWND]);

  else if (uMsg == 36) //WM_GETMINMAXINFO
  {
    var oRect = {};
    GetWindowPos(oSys.Call("User32::GetDesktopWindow"), oRect);
    AkelPad.MemCopy(lParam + 24, 350,          DT_DWORD); //ptMinTrackSize_x
    AkelPad.MemCopy(lParam + 28, 271,          DT_DWORD); //ptMinTrackSize_y
    AkelPad.MemCopy(lParam + 32, oRect.W - 30, DT_DWORD); //ptMaxTrackSize_x
    AkelPad.MemCopy(lParam + 36, oRect.H - 30, DT_DWORD); //ptMaxTrackSize_y
  }

  else if (uMsg == 5) //WM_SIZE
    ResizeWindow(hWnd);

  else if (uMsg == 15) //WM_PAINT
    PaintSizeGrip(hWnd);

  else if ((uMsg == 0x004E /*WM_NOTIFY*/) && (wParam == IDPLUGLV))
  {
    if (AkelPad.MemRead(lParam + (_X64 ? 16 : 8), DT_DWORD) == -155 /*LVN_KEYDOWN*/)
    {
      switch (AkelPad.MemRead(lParam + (_X64 ? 24 : 12), DT_WORD))
      {
        case 0x70 /*VK_F1*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            EditText();
          break;
        case 0x71 /*VK_F2*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            EditText(1);
          break;
        case 0x72 /*VK_F3*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            bSetInReg ? OpenInRegEdit() : EditIniFile();
          break;
        case 0x73 /*VK_F4*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            EditTextFile();
          break;
        case 0x74 /*VK_F5*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            LoadTextFileToPlugin();
          break;
        case 0x76 /*VK_F7*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            RenameTextFile();
          break;
        case 0x77 /*VK_F8*/ :
        case 0x2E /*VK_DELETE*/ :
          if ((! Ctrl()) && (! Alt()))
            DeleteTextFile(! Shift());
          break;
        case 0x78 /*VK_F9*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            ChangeTextsDir();
          break;
        case 0x41 /*A key*/ :
          if (Ctrl() && (! Shift()) && (! Alt()))
          {
            for (var i = 0; i < GetItemCountLV(); ++i)
               SetSelLV(i);
          }
          break;
        case 0x1B /*VK_ESCAPE*/ :
          if ((! Ctrl()) && (! Shift()) && (! Alt()))
            oSys.Call("User32::PostMessage" + _TCHAR, hWnd, 16 /*WM_CLOSE*/, 0, 0);
      }
    }
  }

  else if (uMsg == 273) //WM_COMMAND
  {
    var nLowParam = wParam & 0xFFFF;

    if ((nLowParam >= IDF1B) && (nLowParam <= IDF9B))
    {
      AkelPad.SendMessage(lParam, 0x00F4 /*BM_SETSTYLE*/, 0 /*BS_PUSHBUTTON*/, 0);

      if (nLowParam == IDF1B)
        EditText();
      else if (nLowParam == IDF2B)
        EditText(1);
      else if (nLowParam == IDF3B)
        bSetInReg ? OpenInRegEdit() : EditIniFile();
      else if (nLowParam == IDF4B)
        EditTextFile();
      else if (nLowParam == IDF5B)
        LoadTextFileToPlugin();
      else if (nLowParam == IDF7B)
        RenameTextFile();
      else if (nLowParam == IDF8B)
        DeleteTextFile();
      else if (nLowParam == IDF9B)
        ChangeTextsDir();

      oSys.Call("User32::SetFocus", aWnd[IDPLUGLV][HWND]);
    }
  }

  else if (uMsg == 16) //WM_CLOSE
  {
    AkelPad.WindowUnsubClass(aWnd[IDPLUGLV][HWND]);
    ReadWriteIni(true);
    oSys.Call("User32::DestroyWindow", hWnd); //Destroy dialog
  }

  else if (uMsg == 2) //WM_DESTROY
    oSys.Call("User32::PostQuitMessage", 0); //Exit message loop

  return 0;
}

function ListCallback(hWnd, uMsg, wParam, lParam)
{
  if (uMsg == 0x87) //WM_GETDLGCODE
  {
    AkelPad.WindowNoNextProc(hSubClass);
    return 0x4; //DLGC_WANTALLKEYS
  }

  return 0;
}

function Shift()
{
  return Boolean(oSys.Call("User32::GetKeyState", 0x10 /*VK_SHIFT*/) & 0x8000);
}

function Ctrl()
{
  return Boolean(oSys.Call("User32::GetKeyState", 0x11 /*VK_CONTROL*/) & 0x8000);
}

function Alt()
{
  return Boolean(oSys.Call("User32::GetKeyState", 0x12 /*VK_MENU*/) & 0x8000);
}

function GetWindowPos(hWnd, oRect)
{
  var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)

  oSys.Call("User32::GetWindowRect", hWnd, lpRect);

  oRect.X = AkelPad.MemRead(lpRect,      DT_DWORD);
  oRect.Y = AkelPad.MemRead(lpRect +  4, DT_DWORD);
  oRect.W = AkelPad.MemRead(lpRect +  8, DT_DWORD) - oRect.X;
  oRect.H = AkelPad.MemRead(lpRect + 12, DT_DWORD) - oRect.Y;

  AkelPad.MemFree(lpRect);
}

function ResizeWindow(hWnd)
{
  var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
  var nW, nH, nBW;
  var i;

  oSys.Call("User32::GetClientRect", hWnd, lpRect);
  nW  = AkelPad.MemRead(lpRect +  8, DT_DWORD);
  nH  = AkelPad.MemRead(lpRect + 12, DT_DWORD);
  nBW = Math.round((nW - 3 * 8) / 2);
  AkelPad.MemFree(lpRect);

  for (i = 0; i < 2; ++i)
  {
    oSys.Call("User32::SetWindowPos",
              aWnd[IDINFOS + i][HWND], 0,
              8,
              10 + 15 * i,
              nW - 2 * 8,
              13,
              0x14 /*SWP_NOZORDER|SWP_NOACTIVATE*/);
  }

  oSys.Call("User32::SetWindowPos",
            aWnd[IDPLUGLV][HWND], 0,
            8,
            45,
            nW - 2 * 8,
            nH - 4 * 23 - 3 * 2 - 2 * 8 - 45,
            0x14 /*SWP_NOZORDER|SWP_NOACTIVATE*/);

  for (i = 0; i < 4; ++i)
  {
    oSys.Call("User32::SetWindowPos",
              aWnd[IDF1B + i][HWND], 0,
              8,
              nH - 4 * 23 - 3 * 2 - 8 + 25 * i,
              nBW,
              23,
              0x14 /*SWP_NOZORDER|SWP_NOACTIVATE*/);

    oSys.Call("User32::SetWindowPos",
              aWnd[IDF5B + i][HWND], 0,
              nW - nBW - 8,
              nH - 4 * 23 - 3 * 2 - 8 + 25 * i,
              nBW,
              23,
              0x14 /*SWP_NOZORDER|SWP_NOACTIVATE*/);
  }

  for (i = 0; i < 3; ++i)
    AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x101E /*LVM_SETCOLUMNWIDTH*/, i, -2 /*LVSCW_AUTOSIZE_USEHEADER*/);

  AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1013 /*LVM_ENSUREVISIBLE*/, GetNextSelLV(-1), false);
}

function PaintSizeGrip(hWnd)
{
  var lpPaint = AkelPad.MemAlloc(_X64 ? 72 : 64); //sizeof(PAINTSTRUCT)
  var lpRect  = AkelPad.MemAlloc(16); //sizeof(RECT)
  var hDC;

  if (hDC = oSys.Call("User32::BeginPaint", hWnd, lpPaint))
  {
    oSys.Call("User32::GetClientRect", hWnd, lpRect);

    AkelPad.MemCopy(lpRect,     AkelPad.MemRead(lpRect +  8, DT_DWORD) - oSys.Call("User32::GetSystemMetrics",  2 /*SM_CXVSCROLL*/), DT_DWORD);
    AkelPad.MemCopy(lpRect + 4, AkelPad.MemRead(lpRect + 12, DT_DWORD) - oSys.Call("User32::GetSystemMetrics", 20 /*SM_CYVSCROLL*/), DT_DWORD);

    oSys.Call("User32::DrawFrameControl", hDC, lpRect, 3 /*DFC_SCROLL*/, 0x8 /*DFCS_SCROLLSIZEGRIP*/);
    oSys.Call("User32::EndPaint", hWnd, lpPaint);
  }

  AkelPad.MemFree(lpPaint);
  AkelPad.MemFree(lpRect);
}

function IsSettingsInRegistry()
{
  if (AkelPad.SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 5 /*MI_SAVESETTINGS*/, 0) == 2 /*SS_INI*/)
    return false;

  return true;
}

function GetItemCountLV()
{
  return AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1004 /*LVM_GETITEMCOUNT*/, 0, 0);
}

function GetItemTextLV(nItem, nSubItem)
{
  AkelPad.MemCopy(lpLVITEM + 8, nSubItem, DT_DWORD);
  AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1073 /*LVM_GETITEMTEXTW*/, nItem, lpLVITEM);
  return AkelPad.MemRead(lpBuffer, _TSTR);
}

function SetItemTextLV(nItem, nSubItem, sText)
{
  AkelPad.MemCopy(lpLVITEM + 4, nItem,    DT_DWORD);
  AkelPad.MemCopy(lpLVITEM + 8, nSubItem, DT_DWORD);
  AkelPad.MemCopy(lpBuffer, sText, _TSTR);

  AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1074 /*LVM_SETITEMTEXTW*/, nItem, lpLVITEM);
}

function GetNextSelLV(nItem)
{
  return AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x100C /*LVM_GETNEXTITEM*/, nItem, 0x0002 /*LVNI_SELECTED*/);
}

function GetSelArrayLV()
{
  var aSel  = [];
  var nItem = -1;

  while (true)
  {
    nItem = GetNextSelLV(nItem);

    if (nItem < 0)
      break;

    aSel.push(nItem);
  }

  return aSel;
}

function SetSelLV(nItem)
{
  AkelPad.MemCopy(lpLVITEM + 12, 0x0003 /*LVIS_SELECTED|LVIS_FOCUSED*/, DT_DWORD);
  AkelPad.MemCopy(lpLVITEM + 16, 0x0003 /*LVIS_SELECTED|LVIS_FOCUSED*/, DT_DWORD);
  AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x102B /*LVM_SETITEMSTATE*/, nItem, lpLVITEM);
  AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1013 /*LVM_ENSUREVISIBLE*/, nItem, false);
}

function IsItemSel(nItem)
{
  return Boolean(AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x102C /*LVM_GETITEMSTATE*/, nItem, 0x0002 /*LVIS_SELECTED*/));
}

function InsertItemLV(nItem, aItems)
{
  var i;

  AkelPad.MemCopy(lpLVITEM + 4, nItem, DT_DWORD);
  AkelPad.MemCopy(lpLVITEM + 8,     0, DT_DWORD);
  AkelPad.MemCopy(lpBuffer, aItems[0], _TSTR);
  AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x104D /*LVM_INSERTITEMW*/, 0, lpLVITEM);

  for (i = 1; i < aItems.length; ++i)
  {
    AkelPad.MemCopy(lpLVITEM + 8, i, DT_DWORD);
    AkelPad.MemCopy(lpBuffer, aItems[i], _TSTR);
    AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1074 /*LVM_SETITEMTEXTW*/, nItem, lpLVITEM);
  }
}

function InsertColumnsLV()
{
  var lpLVCOLUMN = AkelPad.MemAlloc(_X64 ? 56 : 44); //sizeof(LVCOLUMN)
  var nMask      = 5; //LVCF_FMT|LVCF_TEXT
  var aFmt       = [0 /*LVCFMT_LEFT*/, 0, 0]; //Alignment of the column header
  var aText      = [AkelPad.MemStrPtr(sTxtPlugin), AkelPad.MemStrPtr(sTxtKeyTextName), AkelPad.MemStrPtr(sTxtTextFile)];
  var i;

  AkelPad.MemCopy(lpLVCOLUMN, nMask, DT_DWORD);

  AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1036 /*LVM_SETEXTENDEDLISTVIEWSTYLE*/, 0x0020 /*LVS_EX_FULLROWSELECT*/, 0x0020);

  for (i = 0; i < aFmt.length; ++i)
  {
    AkelPad.MemCopy(lpLVCOLUMN + 4, aFmt[i], DT_DWORD);
    AkelPad.MemCopy(lpLVCOLUMN + (_X64 ? 16 : 12), aText[i], DT_QWORD);

    AkelPad.SendMessage(aWnd[IDPLUGLV][HWND], 0x1061 /*LVM_INSERTCOLUMNW*/, i, lpLVCOLUMN);
  }

  AkelPad.MemFree(lpLVCOLUMN);
}

function FillPlugList()
{
  var aPlugList = [];
  var i;

  if (bSetInReg)
    GetPluginsFromReg(aPlugList);
  else
    GetPluginsFromIni(aPlugList);

  for (i = 0; i < aPlugList.length; ++i)
  {
    if (oPlugText[aPlugList[i][0]] &&
        oPlugText[aPlugList[i][0]][aPlugList[i][1]] &&
        oPlugText[aPlugList[i][0]][aPlugList[i][1]].File)
      aPlugList[i].push(oPlugText[aPlugList[i][0]][aPlugList[i][1]].File);
    else
      aPlugList[i].push(aPlugList[i][0] + "." + aPlugList[i][1].replace(/[<>:"/\\|?*]/g, "_") + ".akelmenu");

    InsertItemLV(i, aPlugList[i]);

    if (oPlugText[aPlugList[i][0]] &&
        oPlugText[aPlugList[i][0]][aPlugList[i][1]] &&
        oPlugText[aPlugList[i][0]][aPlugList[i][1]].Sel)
      SetSelLV(i);
  }

  if (GetNextSelLV(-1) < 0)
    SetSelLV(0);
}

function GetPluginsFromIni(aPlugList)
{
  var oRE1      = /^\/.+(?==)/gm;
  var oRE2      = /^.+Text(?==)/gm;
  var aPlugName = [["Coder", oRE1], ["ContextMenu", oRE2], ["Hotkeys", oRE2], ["SpecialChar", oRE2]];
  var sPlugDir  = AkelPad.GetAkelDir(4 /*ADTYPE_PLUGS*/) + "\\";
  var hFindFile = oSys.Call("Kernel32::FindFirstFileW", sPlugDir + "ToolBar*.ini", lpBuffer);
  var sToolBarName;
  var aText;
  var i, n;

  if (hFindFile != -1) //INVALID_HANDLE_VALUE
  {
    do
    {
      if (! (AkelPad.MemRead(lpBuffer, DT_DWORD) & 16 /*FILE_ATTRIBUTE_DIRECTORY*/))
      {
        sToolBarName = AkelPad.MemRead(lpBuffer + 44 /*offsetof(WIN32_FIND_DATAW, cFileName)*/, _TSTR);
        sToolBarName = sToolBarName.substring(sToolBarName.lastIndexOf("\\") + 1, sToolBarName.lastIndexOf("."));
        aPlugName.push([sToolBarName, oRE2]);
      }
    }
    while (oSys.Call("Kernel32::FindNextFileW", hFindFile, lpBuffer));

    oSys.Call("Kernel32::FindClose", hFindFile);
  }

  for (i = 0; i < aPlugName.length; ++i)
  {
    if ((IsFileExists(sPlugDir + aPlugName[i][0] + ".ini")) &&
        (aText = AkelPad.ReadFile(sPlugDir + aPlugName[i][0] + ".ini").match(aPlugName[i][1])))
    {
      for (n = 0; n < aText.length; ++n)
        aPlugList.push([aPlugName[i][0], aText[n]]);
    }
  }
}

function GetPluginsFromReg(aPlugList)
{
  var oRE1       = /^\/.+/;
  var oRE2       = /.+Text$/;
  var aPlugName  = [["Coder", oRE1], ["ContextMenu", oRE2], ["Hotkeys", oRE2], ["SpecialChar", oRE2]];
  var sPlugKey   = "Software\\Akelsoft\\AkelPad\\Plugs";
  var hKey       = GetRegKeyHandle(0x80000001 /*HKEY_CURRENT_USER*/, sPlugKey, 0x0009 /*KEY_ENUMERATE_SUB_KEYS|KEY_QUERY_VALUE*/);
  var lpCount    = AkelPad.MemAlloc(4);
  var lpNameLen  = AkelPad.MemAlloc(4);
  var lpType     = AkelPad.MemAlloc(4);
  var lpName;
  var nNameLen;
  var sToolBarName;
  var sValueName;
  var i;

  if (hKey)
  {
    if (! oSys.Call("Advapi32::RegQueryInfoKey" + _TCHAR,
                    hKey,      //hKey
                    0,         //lpClass
                    0,         //lpcClass
                    0,         //lpReserved
                    lpCount,   //lpcSubKeys
                    lpNameLen, //lpcMaxSubKeyLen
                    0,         //lpcMaxClassLen
                    0,         //lpcValues
                    0,         //lpcMaxValueNameLen
                    0,         //lpcMaxValueLen
                    0,         //lpcbSecurityDescri
                    0))        //lpftLastWriteTime
    {
      nNameLen = AkelPad.MemRead(lpNameLen, DT_DWORD) + 1;
      lpName   = AkelPad.MemAlloc(nNameLen * 2);

      for (i = 0; i < AkelPad.MemRead(lpCount, DT_DWORD); ++i)
      {
        AkelPad.MemCopy(lpNameLen, nNameLen, DT_DWORD);
        if (! oSys.Call("Advapi32::RegEnumKeyEx" + _TCHAR,
                        hKey,      //hKey
                        i,         //dwIndex
                        lpName,    //lpName
                        lpNameLen, //lpcName
                        0,         //lpReserved
                        0,         //lpClass
                        0,         //lpcClass
                        0))        //lpftLastWriteTime
        {
          sToolBarName = AkelPad.MemRead(lpName, DT_UNICODE);
          if (sToolBarName.indexOf("ToolBar") == 0)
            aPlugName.push([sToolBarName, oRE2]);
        }
      }
      AkelPad.MemFree(lpName);
    }
    oSys.Call("Advapi32::RegCloseKey", hKey);
  }

  for (i = 0; i < aPlugName.length; ++i)
  {
    hKey = GetRegKeyHandle(0x80000001 /*HKEY_CURRENT_USER*/, sPlugKey + "\\" + aPlugName[i][0], 0x0001 /*KEY_QUERY_VALUE*/);
    if (hKey)
    {
      if (! oSys.Call("Advapi32::RegQueryInfoKey" + _TCHAR,
                      hKey,      //hKey
                      0,         //lpClass
                      0,         //lpcClass
                      0,         //lpReserved
                      0,         //lpcSubKeys
                      0,         //lpcMaxSubKeyLen
                      0,         //lpcMaxClassLen
                      lpCount,   //lpcValues
                      lpNameLen, //lpcMaxValueNameLen
                      0,         //lpcMaxValueLen
                      0,         //lpcbSecurityDescri
                      0))        //lpftLastWriteTime
      {
        nNameLen = AkelPad.MemRead(lpNameLen, DT_DWORD) + 1;
        lpName   = AkelPad.MemAlloc(nNameLen * 2);

        for (n = 0; n < AkelPad.MemRead(lpCount, DT_DWORD); ++n)
        {
          AkelPad.MemCopy(lpNameLen, nNameLen, DT_DWORD);
          if (! oSys.Call("Advapi32::RegEnumValue" + _TCHAR,
                          hKey,      //hKey
                          n,         //dwIndex
                          lpName,    //lpValueName
                          lpNameLen, //lpcchValueName
                          0,         //lpReserved
                          lpType,    //lpType
                          0,         //lpData
                          0))        //lpcbData
          {
            sValueName = AkelPad.MemRead(lpName, DT_UNICODE);
            if (aPlugName[i][1].test(sValueName) && (AkelPad.MemRead(lpType, DT_DWORD) == 3 /*REG_BINARY*/))
              aPlugList.push([aPlugName[i][0], sValueName]);
          }
        }
        AkelPad.MemFree(lpName);
      }
      oSys.Call("Advapi32::RegCloseKey", hKey);
    }
  }

  AkelPad.MemFree(lpCount);
  AkelPad.MemFree(lpNameLen);
  AkelPad.MemFree(lpType);
}

function GetRegKeyHandle(hParentKey, sSubKey, nAccess)
{
  var lpKey  = AkelPad.MemAlloc(_X64 ? 8 : 4);
  var hKey   = 0;
  var nError = oSys.Call("Advapi32::RegOpenKeyEx" + _TCHAR,
                         hParentKey, //hKey
                         sSubKey,    //lpSubKey
                         0,          //ulOptions
                         nAccess,    //samDesired
                         lpKey);     //phkResult

  if (! nError)
    hKey = AkelPad.MemRead(lpKey, DT_QWORD);

  AkelPad.MemFree(lpKey);

  return hKey;
}

function EditText(bSave)
{
  var sTextDir = ExpandDirName(sTextDirS);
  var sPlugDir = AkelPad.GetAkelDir(4 /*ADTYPE_PLUGS*/) + "\\";
  var aSel     = GetSelArrayLV();
  var aSaved   = [];
  var aNoSaved = [];
  var sMessage = "";
  var hKey;
  var lpType;
  var lpData;
  var lpDataLen;
  var sIniFile;
  var oRE;
  var bWasSaved;
  var i, n;

  if (bSave &&
      (AkelPad.MessageBox(hWndDlg, sTxtWantSave, sScriptName,
                          0x00000023 /*MB_DEFBUTTON1|MB_ICONQUESTION|MB_YESNOCANCEL*/) != 6 /*IDYES*/))
    return;

  if (bSetInReg)
  {
    lpType    = AkelPad.MemAlloc(4);
    lpDataLen = AkelPad.MemAlloc(4);

    for (i = 0; i < aSel.length; ++i)
    {
      bWasSaved = false;
      hKey      = GetRegKeyHandle(0x80000001 /*HKEY_CURRENT_USER*/, "Software\\Akelsoft\\AkelPad\\Plugs\\" + GetItemTextLV(aSel[i], 0), 0x0001 /*KEY_QUERY_VALUE*/);

      if (hKey)
      {
        oSys.Call("Advapi32::RegQueryInfoKey" + _TCHAR,
                  hKey,      //hKey
                  0,         //lpClass
                  0,         //lpcClass
                  0,         //lpReserved
                  0,         //lpcSubKeys
                  0,         //lpcMaxSubKeyLen
                  0,         //lpcMaxClassLen
                  0,         //lpcValues
                  0,         //lpcMaxValueNameLen
                  lpDataLen, //lpcMaxValueLen
                  0,         //lpcbSecurityDescri
                  0);        //lpftLastWriteTime

        lpData = AkelPad.MemAlloc(lpDataLen);

        if ((! oSys.Call("Advapi32::RegQueryValueEx" + _TCHAR,
                         hKey,                      //hKey
                         GetItemTextLV(aSel[i], 1), //lpValueName
                         0,                         //lpReserved
                         lpType,                    //lpType
                         lpData,                    //lpData
                         lpDataLen))                //lpcbData
            && (AkelPad.MemRead(lpType, DT_DWORD) == 3 /*REG_BINARY*/))
        {
          if (bSave)
          {
            if (WriteFile(sTextDir + GetItemTextLV(aSel[i], 2), null, AkelPad.MemRead(lpData, DT_UNICODE), 1))
            {
              aSaved.push(aSel[i]);
              bWasSaved = true;
            }
          }
          else
            OpenText(lpData);
        }

        oSys.Call("Advapi32::RegCloseKey", hKey);
        AkelPad.MemFree(lpData);
      }

      if (bSave && (! bWasSaved))
        aNoSaved.push(aSel[i]);
    }

    AkelPad.MemFree(lpType);
    AkelPad.MemFree(lpDataLen);
  }

  else
  {
    for (i = 0; i < aSel.length; ++i)
    {
      bWasSaved = false;
      sIniFile  = sPlugDir + GetItemTextLV(aSel[i], 0) + ".ini";

      if (IsFileExists(sIniFile))
      {
        oRE = new RegExp(escapeRegExp(GetItemTextLV(aSel[i], 1)) + "=([\\dA-F]*)");

        if (oRE.test(AkelPad.ReadFile(sIniFile)))
        {
          lpData = AkelPad.MemAlloc(RegExp.$1.length / 2);

          for (n = 0; n < RegExp.$1.length; n += 2)
            AkelPad.MemCopy(lpData + n / 2, parseInt(RegExp.$1.substr(n, 2), 16), DT_BYTE);

          if (bSave)
          {
            if (WriteFile(sTextDir + GetItemTextLV(aSel[i], 2), null, AkelPad.MemRead(lpData, DT_UNICODE), 1))
            {
              aSaved.push(aSel[i]);
              bWasSaved = true;
            }
          }
          else
            OpenText(lpData);

          AkelPad.MemFree(lpData);
        }
      }

      if (bSave && (! bWasSaved))
        aNoSaved.push(aSel[i]);
    }
  }

  if (bSave)
  {
    if (aSaved.length)
    {
      sMessage += sTxtSaved + "\n";
      for (i = 0; i < aSaved.length; ++i)
        sMessage += sTextDir + GetItemTextLV(aSaved[i], 2) + "\n";
    }

    if (aNoSaved.length)
    {
      sMessage += "\n" + sTxtNoSaved + "\n";
      for (i = 0; i < aNoSaved.length; ++i)
        sMessage += sTextDir + GetItemTextLV(aNoSaved[i], 2) + "\n";
    }

    AkelPad.MessageBox(hWndDlg, sMessage, sScriptName, 0x00000040 /*MB_ICONINFORMATION*/);
  }
}

function OpenText(lpData)
{
  AkelPad.SendMessage(hMainWnd, 273 /*WM_COMMAND*/, 4101 /*wParam=MAKEWPARAM(0,IDM_FILE_NEW)*/, 1 /*lParam=TRUE*/);
  AkelPad.Command(4125); //Reopen as UTF-16LE
  oSys.Call("User32::SetWindowTextW", AkelPad.GetEditWnd(), lpData);

  if (AkelPad.IsPluginRunning("Coder::HighLight"))
    AkelPad.Call("Coder::Settings", 1, "akelmenu");
}

function EditIniFile()
{
  var sPlugDir = AkelPad.GetAkelDir(4 /*ADTYPE_PLUGS*/) + "\\";
  var aSel     = GetSelArrayLV();
  var aNoFile  = [];
  var sIniFile;
  var nSelStart;
  var sMessage;
  var i;

  for (i = 0; i < aSel.length; ++i)
  {
    sIniFile = sPlugDir + GetItemTextLV(aSel[i], 0) + ".ini";

    if (IsFileExists(sIniFile))
    {
      if (AkelPad.OpenFile(sIniFile) == 0 /*EOD_SUCCESS*/)
      {
        nSelStart = AkelPad.TextFind(AkelPad.GetEditWnd(), GetItemTextLV(aSel[i], 1), 0x00200001 /*FR_DOWN|FR_BEGINNING*/);
        if (nSelStart > -1)
          AkelPad.SetSel(nSelStart, nSelStart + GetItemTextLV(aSel[i], 1).length);
      }
    }
    else
      aNoFile.push(aSel[i]);
  }

  if (aNoFile.length)
  {
    sMessage = sTxtNoFiles + "\n";
    for (i = 0; i < aNoFile.length; ++i)
      sMessage += sPlugDir + GetItemTextLV(aSel[i], 0) + ".ini" + "\n";

    AkelPad.MessageBox(hWndDlg, sMessage, sScriptName, 0x00000030 /*MB_ICONWARNING*/);
  }
}

function OpenInRegEdit()
{
  var aSel     = GetSelArrayLV();
  var hKey     = GetRegKeyHandle(0x80000001 /*HKEY_CURRENT_USER*/, "Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit", 0x0002 /*KEY_SET_VALUE*/);
  var sValue   = "HKEY_CURRENT_USER\\Software\\Akelsoft\\AkelPad\\Plugs\\" + GetItemTextLV(aSel[0], 0);
  var nSize    = (sValue.length + 1) * 2;
  var lpData   = AkelPad.MemAlloc(nSize);
  var sProcess = "regedit.exe";

  TerminateProcess(sProcess);

  AkelPad.MemCopy(lpData, sValue, DT_UNICODE);

  oSys.Call("Advapi32::RegSetValueEx" + _TCHAR,
            hKey,      //hKey
            "LastKey", //lpValueName
            0,         //Reserved
            1,         //dwType = REG_SZ
            lpData,    //lpData
            nSize);    //cbData
 
  oSys.Call("Advapi32::RegCloseKey", hKey);
  AkelPad.MemFree(lpData);

  AkelPad.Exec("rundll32.exe shell32, ShellExec_RunDLL " + sProcess);
}

function TerminateProcess(sProcess)
{
  var lpPIDs  = AkelPad.MemAlloc(4000);
  var lpBytes = AkelPad.MemAlloc(4);
  var lpName  = AkelPad.MemAlloc(260 * _TSIZE);
  var hProcess;
  var i;

  sProcess = sProcess.toUpperCase();

  oSys.Call("Psapi::EnumProcesses", lpPIDs, 4000, lpBytes);

  for (i = 0; i < AkelPad.MemRead(lpBytes, DT_DWORD) / 4; ++i)
  {
    if (hProcess = oSys.Call("Kernel32::OpenProcess",
                             0x0411 /*PROCESS_QUERY_INFORMATION|PROCESS_VM_READ|PROCESS_TERMINATE*/,
                             0,
                             AkelPad.MemRead(lpPIDs + i * 4, DT_DWORD)))
    {
      oSys.Call("Psapi::GetModuleBaseName" + _TCHAR, hProcess, 0, lpName, 260);

      if (AkelPad.MemRead(lpName, _TSTR).toUpperCase() == sProcess)
        oSys.Call("Kernel32::TerminateProcess", hProcess, 0);

      oSys.Call("Kernel32::CloseHandle", hProcess);
    }
  }

  AkelPad.MemFree(lpPIDs);
  AkelPad.MemFree(lpBytes);
  AkelPad.MemFree(lpName);
}

function EditTextFile()
{
  var sTextDir = ExpandDirName(sTextDirS);
  var aSel     = GetSelArrayLV();
  var aNoFile  = [];
  var sTextFile;
  var i;

  for (i = 0; i < aSel.length; ++i)
  {
    sTextFile = sTextDir + GetItemTextLV(aSel[i], 2);

    if (IsFileExists(sTextFile))
      AkelPad.OpenFile(sTextFile);
    else
      aNoFile.push(aSel[i]);
  }

  if (aNoFile.length)
  {
    sMessage = sTxtNoFiles + "\n";
    for (i = 0; i < aNoFile.length; ++i)
      sMessage += sTextDir + GetItemTextLV(aNoFile[i], 2) + "\n";

    AkelPad.MessageBox(hWndDlg, sMessage, sScriptName, 0x00000030 /*MB_ICONWARNING*/);
  }
}

function LoadTextFileToPlugin()
{
  var sTextDir  = ExpandDirName(sTextDirS);
  var sPlugDir  = AkelPad.GetAkelDir(4 /*ADTYPE_PLUGS*/) + "\\";
  var aSel      = GetSelArrayLV();
  var aSaved    = [];
  var aNoSaved  = [];
  var sMessage  = "";
  var sPrevPlug = "";
  var hKey;
  var lpType;
  var sTextFile;
  var sRegFile;
  var sIniBack;
  var sIniFile;
  var sText;
  var sIniText;
  var nSize;
  var lpData;
  var oRE;
  var bWasSaved;
  var i, n;

  if (AkelPad.MessageBox(hWndDlg, sTxtWantLoad, sScriptName,
                         0x00000023 /*MB_DEFBUTTON1|MB_ICONQUESTION|MB_YESNOCANCEL*/) != 6 /*IDYES*/)
    return;

  if (bSetInReg)
  {
    lpType = AkelPad.MemAlloc(4);

    for (i = 0; i < aSel.length; ++i)
    {
      bWasSaved = false;
      sTextFile = sTextDir + GetItemTextLV(aSel[i], 2);
      sRegFile  = sTextDir + GetItemTextLV(aSel[i], 0) + ".reg.bak";
      hKey      = GetRegKeyHandle(0x80000001 /*HKEY_CURRENT_USER*/, "Software\\Akelsoft\\AkelPad\\Plugs\\" + GetItemTextLV(aSel[i], 0), 0x0003 /*KEY_SET_VALUE|KEY_QUERY_VALUE*/);

      if (hKey
          && (! oSys.Call("Advapi32::RegQueryValueEx" + _TCHAR,
                          hKey,                      //hKey
                          GetItemTextLV(aSel[i], 1), //lpValueName
                          0,                         //lpReserved
                          lpType,                    //lpType
                          0,                         //lpData
                          0))                        //lpcbData
          && (AkelPad.MemRead(lpType, DT_DWORD) == 3 /*REG_BINARY*/)
          && IsFileExists(sTextFile)
          && (sText = AkelPad.ReadFile(sTextFile)))
      {
        //create registry key backup file
        if (GetItemTextLV(aSel[i], 0) != sPrevPlug)
        {
          DeleteFile(sRegFile);
          AkelPad.Exec("reg.exe export HKEY_CURRENT_USER\\Software\\Akelsoft\\AkelPad\\Plugs\\" + GetItemTextLV(aSel[i], 0) + " " + sRegFile, "", 1);
          sPrevPlug = GetItemTextLV(aSel[i], 0);
        }

        nSize  = (sText.length + 1) * 2;
        lpData = AkelPad.MemAlloc(nSize);
        AkelPad.MemCopy(lpData, sText, DT_UNICODE);

        if ((! oSys.Call("Advapi32::RegSetValueEx" + _TCHAR,
                         hKey,                      //hKey
                         GetItemTextLV(aSel[i], 1), //lpValueName
                         0,                         //Reserved
                         3,                         //dwType = REG_BINARY
                         lpData,                    //lpData
                         nSize)))                   //cbData
        {
          aSaved.push(aSel[i]);
          bWasSaved = true;
        }

        AkelPad.MemFree(lpData);
      }

      oSys.Call("Advapi32::RegCloseKey", hKey);
      if (! bWasSaved)
        aNoSaved.push(aSel[i]);
    }

    AkelPad.MemFree(lpType);
  }

  else
  {
    for (i = 0; i < aSel.length; ++i)
    {
      bWasSaved = false;
      sTextFile = sTextDir + GetItemTextLV(aSel[i], 2);
      sIniBack  = sTextDir + GetItemTextLV(aSel[i], 0) + ".ini.bak";
      sIniFile  = sPlugDir + GetItemTextLV(aSel[i], 0) + ".ini";

      if (IsFileExists(sIniFile) && IsFileExists(sTextFile) && (sText = AkelPad.ReadFile(sTextFile)))
      {
        oRE      = new RegExp(escapeRegExp(GetItemTextLV(aSel[i], 1)) + "=[\\dA-F]*");
        sIniText = AkelPad.ReadFile(sIniFile);
        nSize    = (sText.length + 1) * 2;
        lpData   = AkelPad.MemAlloc(nSize);

          AkelPad.MemCopy(lpData, sText, DT_UNICODE);
        sText = "";
        for (n = 0; n < nSize; ++n)
          sText += PadL0(AkelPad.MemRead(lpData + n, DT_BYTE).toString(16).toUpperCase());
        AkelPad.MemFree(lpData);

        if (sText && oRE.test(sIniText))
        {
          //create backup .ini file
          if (GetItemTextLV(aSel[i], 0) != sPrevPlug)
          {
            CopyFile(sIniFile, null, sIniBack);
            sPrevPlug = GetItemTextLV(aSel[i], 0);
          }

          if (WriteFile(sIniFile, null, sIniText.replace(oRE, GetItemTextLV(aSel[i], 1) + "=" + sText), 1))
          {
            aSaved.push(aSel[i]);
            bWasSaved = true;
          }
        }
      }

      if (! bWasSaved)
        aNoSaved.push(aSel[i]);
    }
  }

  if (aSaved.length)
  {
    sMessage += sTxtSaved + "\n";

    for (i = 0; i < aSaved.length; ++i)
    {
      sMessage += GetItemTextLV(aSaved[i], 0) + ": " + GetItemTextLV(aSaved[i], 1) + "\n";
      RestartPlugin(GetItemTextLV(aSaved[i], 0));
    }
  }

  if (aNoSaved.length)
  {
    sMessage += "\n" + sTxtNoSaved + "\n";

    for (i = 0; i < aNoSaved.length; ++i)
      sMessage += GetItemTextLV(aNoSaved[i], 0) + ": " + GetItemTextLV(aNoSaved[i], 1) + "\n";
  }

  AkelPad.MessageBox(hWndDlg, sMessage, sScriptName, 0x00000040 /*MB_ICONINFORMATION*/);
}

function PadL0(sString)
{
  if (sString.length == 1)
    return "0" + sString;

  return sString;
}

function RestartPlugin(sPlugName)
{
  var bCoderHL;
  var bCoderCF;
  var bCoderAC;

  if (sPlugName == "Coder")
  {
    if (AkelPad.IsPluginRunning(sPlugName + "::HighLight"))
    {
      bCoderHL = 1;
      AkelPad.Call(sPlugName + "::HighLight");
    }
    if (AkelPad.IsPluginRunning(sPlugName + "::CodeFold"))
    {
      bCoderCF = 1;
      AkelPad.Call(sPlugName + "::CodeFold");
    }
    if (AkelPad.IsPluginRunning(sPlugName + "::AutoComplete"))
    {
      bCoderAC = 1;
      AkelPad.Call(sPlugName + "::AutoComplete");
    }

    if (bCoderHL)
      AkelPad.Call(sPlugName + "::HighLight");
    if (bCoderCF)
      AkelPad.Call(sPlugName + "::CodeFold");
    if (bCoderAC)
      AkelPad.Call(sPlugName + "::AutoComplete");
  }
  else if ((sPlugName == "ContextMenu") || (sPlugName == "Hotkeys"))
  {
    if (AkelPad.IsPluginRunning(sPlugName + "::Main"))
    {
      AkelPad.Call(sPlugName + "::Main", 10);
      AkelPad.Call(sPlugName + "::Main", 10);
    }
  }
  //SpecialChar, ToolBar*
  else
  {
    if (AkelPad.IsPluginRunning(sPlugName + "::Main"))
    {
      AkelPad.Call(sPlugName + "::Main");
      AkelPad.Call(sPlugName + "::Main");
    }
  }
}

function RenameTextFile()
{
  var aSel = GetSelArrayLV();
  var sOldName;
  var sNewName;

  for (i = 0; i < aSel.length; ++i)
  {
    sOldName = GetItemTextLV(aSel[i], 2);
    sNewName = GetFileName(sTxtRenameFile, sOldName + "\n\n" + sTxtNewName, sOldName);

    if (sNewName)
    {
      if (sNewName != sOldName)
      {
        SetItemTextLV(aSel[i], 2, sNewName);
        RenameFile(ExpandDirName(sTextDirS) + sOldName, 0, sNewName);
      }
    }
    else
      break;
  }
}

function GetFileName(sCaption, sLabel, sName)
{
  while (true)
  {
    sName = AkelPad.InputBox(hWndDlg, sCaption, sLabel, sName);

    if (sName)
    {
      sName = sName.replace(/[ .]+$/, "");

      if (/^(CON|PRN|AUX|NUL|COM1|COM2|COM3|COM4|COM5|COM6|COM7|COM8|COM9|LPT1|LPT2|LPT3|LPT4|LPT5|LPT6|LPT7|LPT8|LPT9)$/i.test(sName))
        AkelPad.MessageBox(hWndDlg, sName + "\n\n" + sTxtBadName, sCaption, 0x00000030 /*MB_ICONWARNING*/);
      else if (/[<>:"/\\|?*]/.test(sName))
        AkelPad.MessageBox(hWndDlg, sName + "\n\n" + sTxtBadChar, sCaption, 0x00000030 /*MB_ICONWARNING*/);
      else
        break;
    }
    else
      break;
  }

  return sName;
}

function DeleteTextFile(bRecBin)
{
  var sTextDir   = ExpandDirName(sTextDirS);
  var aSel       = GetSelArrayLV();
  var aDeleted   = [];
  var aNoDeleted = [];
  var sMessage   = "";

  if (AkelPad.MessageBox(hWndDlg, sTxtWantDelete, sScriptName,
                         0x00000023 /*MB_DEFBUTTON1|MB_ICONQUESTION|MB_YESNOCANCEL*/) == 6 /*IDYES*/)
  {
    for (i = 0; i < aSel.length; ++i)
    {
      if (DeleteFile(sTextDir + GetItemTextLV(aSel[i], 2), null, bRecBin))
        aDeleted.push(aSel[i]);
      else
        aNoDeleted.push(aSel[i]);
    }

    if (aDeleted.length)
    {
      sMessage += sTxtDeleted + "\n";
      for (i = 0; i < aDeleted.length; ++i)
        sMessage += sTextDir + GetItemTextLV(aDeleted[i], 2) + "\n";
    }

    if (aNoDeleted.length)
    {
      sMessage += "\n" + sTxtNoDeleted + "\n";
      for (i = 0; i < aNoDeleted.length; ++i)
        sMessage += sTextDir + GetItemTextLV(aNoDeleted[i], 2) + "\n";
    }

    AkelPad.MessageBox(hWndDlg, sMessage, sScriptName, 0x00000040 /*MB_ICONINFORMATION*/);
  }
}

//function written by Infocatcher
function escapeRegExp(str)
{
  return str.replace(/[\\\/.^$+*?|()\[\]{}]/g, "\\$&");
}

function ChangeTextsDir()
{
  var sLabel  = "%a - " + sTxtAkelDir + "\n%p - " + sTxtPlugDir + "\n%variable% - " + sTxtEnvVar;
  var sDirS   = sTextDirS;
  var bChange = 0;
  var sDirE;

  while (true)
  {
    sDirS = AkelPad.InputBox(hWndDlg, sTxtChangeDir, sLabel, sDirS);

    if (sDirS)
    {
      if (sDirS.slice(-1) != "\\")
        sDirS += "\\";

      sDirE = ExpandDirName(sDirS);

      if (IsDirExists(sDirE))
      {
        bChange = 1;
        break;
      }
      else if (AkelPad.MessageBox(hWndDlg, sDirE + "\n\n" + sTxtDirNoExists, sScriptName,
                                  0x00000023 /*MB_DEFBUTTON1|MB_ICONQUESTION|MB_YESNOCANCEL*/) == 6 /*IDYES*/)
      {
        if (oSys.Call("Kernel32::CreateDirectory" + _TCHAR, sDirE, 0))
        {
          bChange = 1;
          break;
        }
        else
          AkelPad.MessageBox(hWndDlg, sDirE + "\n\n" + sTxtDirCreFail, sScriptName, 0x00000030 /*MB_ICONWARNING*/);
      }
    }
    else
      break;
  }

  if (bChange)
  {
    sTextDirS = sDirS;
    oSys.Call("User32::SetWindowText" + _TCHAR, aWnd[IDDIRS][HWND], sTxtDir + sDirE);
  }
}

function ExpandDirName(sDir)
{
  sDir = sDir.replace(/%a\\/g, AkelPad.GetAkelDir() + "\\");
  sDir = sDir.replace(/%p\\/g, AkelPad.GetAkelDir(4 /*ADTYPE_PLUGS*/) + "\\");
  sDir = sDir.replace(/%.+?%/g, ExpandEnvironmentString);

  if (oSys.Call("Kernel32::GetFullPathNameW", sDir, nBufSize / 2, lpBuffer, 0))
    sDir = AkelPad.MemRead(lpBuffer, _TSTR);

  return sDir;
}

function ExpandEnvironmentString(sEnvironmentStr)
{
  if (oSys.Call("Kernel32::ExpandEnvironmentStringsW", sEnvironmentStr, lpBuffer, nBufSize / 2))
    sEnvironmentStr = AkelPad.MemRead(lpBuffer, _TSTR);

  return sEnvironmentStr;
}

function ReadWriteIni(bWrite)
{
  var sIniFile = WScript.ScriptFullName.substring(0, WScript.ScriptFullName.lastIndexOf(".")) + ".ini";
  var oRect;
  var sPlug;
  var sText;
  var sIniText;
  var oError;
  var i, n;

  if (bWrite)
  {
    GetWindowPos(hWndDlg, oRect = {});

    oPlugText = {};
    for (i = 0; i < GetItemCountLV(); ++i)
    {
      sPlug = GetItemTextLV(i, 0);
      sText = GetItemTextLV(i, 1);

      if (! oPlugText[sPlug])
        oPlugText[sPlug] = {};

      if (! oPlugText[sPlug][sText])
        oPlugText[sPlug][sText] = {Sel: IsItemSel(i), File: GetItemTextLV(i, 2)};
    }

    sIniText = 'nWndPosX='  + oRect.X + ';\r\n' +
               'nWndPosY='  + oRect.Y + ';\r\n' +
               'nWndPosW='  + oRect.W + ';\r\n' +
               'nWndPosH='  + oRect.H + ';\r\n' +
               'sTextDirS=' + '"' + sTextDirS.replace(/[\\"]/g, "\\$&") + '";\r\noPlugText={';

    for (i in oPlugText)
    {
      sIniText += '"' + i + '":{';
      for (n in oPlugText[i])
      {
        sIniText += '"' + n + '":{Sel:' + oPlugText[i][n].Sel + ',File:"' + oPlugText[i][n].File + '"},';
      }
      if (sIniText.slice(-1) == ",")
        sIniText = sIniText.slice(0, -1);
      sIniText += '},';
    }
    if (sIniText.slice(-1) == ",")
      sIniText = sIniText.slice(0, -1);
    sIniText += '};';

    WriteFile(sIniFile, null, sIniText, 1);
  }

  else if (IsFileExists(sIniFile))
  {
    try
    {
      eval(AkelPad.ReadFile(sIniFile));
    }
    catch (oError)
    {
    }
  }
}


Last edited by KDJ on Tue Sep 17, 2013 6:18 pm; edited 9 times in total
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1334
Location: Poland

PostPosted: Tue Apr 10, 2012 7:46 pm    Post subject: Reply with quote

InputBox with multiple edit value and variable window width.
The script should be saved in directory: ...\AkelPad\AkelFiles\Plugs\Scripts\Include\

InputBox_function.js

Code:
// InputBox_function.js - ver. 2014-06-03 (x86/x64)
//
// InputBox with multiple edit value and variable window width.
// Window width adjusts to the length of caption and labels.
//
// Usage:
// if (! AkelPad.Include("InputBox_function.js")) WScript.Quit();
// vRetVal = InputBox(hWndOwn, sCaption, vLabelT, vEdit, nFocus, oFunction, vFuncArg, nMinEditW, vLabelB, vLabelL, vLabelR);
//
// Arguments (all are optional):
// hWndOwn (number)
//   Handle to the owner window of the input box. Default is 0 - desktop window.
// sCaption (string)
//   Dialog box title. Default is "".
// vLabelT (string or array of strings)
//   Top labels of edit boxes. In string can use "\n" to create multiline label.
// vEdit (string or array of strings)
//   Edit boxes texts. Maximum length of edit text is 32767 characters. Default is "".
//   Maximum number of elements in array is 100.
// nFocus (number)
//   Index of vEdit array item, on which will set keyboard focus. First and default is 0.
// oFunction (object Function or string as function name)
//   Name of the function used to validate entered data.
//   The function is called when pressed button "OK", but before closing dialog box.
//   To the function are passed three arguments:
//     - handle to dialog box,
//     - array containing all of input strings,
//     - vFuncArg (optional).
//   If input strings are valid, the function should return -1. Otherwise, index of incorrect string in array.
// vFuncArg (any type)
//   Additional argument passed to oFunction.
// nMinEditW (number)
//   Minimum width of edit controls in pixels. Default is 20. The actual field width is adjusted to the width of dialog box.
// vLabelB (string or array of strings)
//   Bottom labels of edit boxes. In string can use "\n" to create multiline label.
// vLabelL (string or array of strings)
//   Left labels of edit boxes.
// vLabelR (string or array of strings)
//   Right labels of edit boxes.
//
// Return value:
//   undefined - if pressed Cancel button or Esc key,
//   array of strings - edit boxes texts, if vEdit is array,
//   string -  edit box text, otherwise.

function InputBox(hWndOwn, sCaption, vLabelT, vEdit, nFocus, oFunc, vFuncArg, nMinEditW, vLabelB, vLabelL, vLabelR)
{
  var oSys = AkelPad.SystemFunction();
  var vRetVal;

  try
  {
    oSys.RegisterCallback(InputBoxCallback);
  }
  catch (oError)
  {
    WScript.Echo("Unable to register callback function.");
    return vRetVal;
  }

  var hInstDLL = AkelPad.GetInstanceDll();
  var hIcon    = oSys.Call("User32::LoadImageW", hInstDLL, 101 /*lpszName*/, 1 /*uType=IMAGE_ICON*/, 0, 0, 0x40 /*fuLoad=LR_DEFAULTSIZE*/);
  var nGroups  = 1;
  var sTxtOK;
  var sTxtCancel;
  var aLabelT;
  var aLabelB;
  var aLabelL;
  var aLabelR;
  var aEdit;
  var lpTemp;
  var lpItem;
  var i;

  switch (AkelPad.GetLangId(0 /*LANGID_FULL*/))
  {
    case 1045 : //Polish
      sTxtOK     = "OK";
      sTxtCancel = "Anuluj";
      break;
    case 1049 : //Russian
      sTxtOK     = "\u041E\u041A";
      sTxtCancel = "\u041E\u0442\u043C\u0435\u043D\u0430";
      break;
    case 2052 : //Chinese-Simplified (by cnnnc)
      sTxtOK     = "\u786E\u5B9A";
      sTxtCancel = "\u53D6\u6D88";
      break;
    default :
      sTxtOK     = "OK";
      sTxtCancel = "Cancel";
  }

  if ((typeof hWndOwn != "number") || (! oSys.Call("User32::IsWindow", hWndOwn)))
    hWndOwn = oSys.Call("User32::GetDesktopWindow");

  if (typeof sCaption != "string")
    sCaption = "";

  if (typeof vEdit == "string")
    aEdit = [vEdit];
  else if ((vEdit instanceof Array) && vEdit.length)
    aEdit = vEdit.slice(0);
  else
    aEdit = [""];

  if (aEdit.length > 100)
    aEdit.length = 100;

  if (typeof vLabelT == "string")
    aLabelT = [vLabelT];
  else if ((vLabelT instanceof Array) && vLabelT.length)
    aLabelT = vLabelT.slice(0);

  if (typeof vLabelB == "string")
    aLabelB = [vLabelB];
  else if ((vLabelB instanceof Array) && vLabelB.length)
    aLabelB = vLabelB.slice(0);

  if (typeof vLabelL == "string")
    aLabelL = [vLabelL];
  else if ((vLabelL instanceof Array) && vLabelL.length)
    aLabelL = vLabelL.slice(0);

  if (typeof vLabelR == "string")
    aLabelR = [vLabelR];
  else if ((vLabelR instanceof Array) && vLabelR.length)
    aLabelR = vLabelR.slice(0);

  for (i = 0; i < aEdit.length; ++i)
  {
    if (typeof aEdit[i] != "string")
      aEdit[i] = "";

    if (aLabelT)
    {
      if (typeof aLabelT[i] == "string")
        aLabelT[i] = aLabelT[i].split("\n");
      else
        aLabelT[i] = undefined;
    }

    if (aLabelB)
    {
      if (typeof aLabelB[i] == "string")
        aLabelB[i] = aLabelB[i].split("\n");
      else
        aLabelB[i] = undefined;
    }

    if (aLabelL && (typeof aLabelL[i] != "string"))
      aLabelL[i] = undefined;

    if (aLabelR && (typeof aLabelR[i] != "string"))
      aLabelR[i] = undefined;
  }

  if ((typeof nFocus != "number") || (nFocus < 0))
    nFocus = 0;
  else if (nFocus >= aEdit.length)
    nFocus = aEdit.length - 1;

  if (typeof oFunc != "function")
  {
    if (typeof oFunc == "string")
      oFunc = eval(oFunc);

    if (typeof oFunc != "function")
      oFunc = undefined;
  }

  if ((typeof nMinEditW != "number") || (nMinEditW < 20))
    nMinEditW = 20;

  if (aLabelT) ++nGroups;
  if (aLabelB) ++nGroups;
  if (aLabelL) ++nGroups;
  if (aLabelR) ++nGroups;

  lpTemp = AkelPad.MemAlloc(24 + (2 + aEdit.length * nGroups) * 28);

  //Dialog
  AkelPad.MemCopy(lpTemp,     0x90C80000,  3 /*DT_DWORD*/); //style (WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU)
  AkelPad.MemCopy(lpTemp + 8, 2 + aEdit.length * nGroups, 4 /*DT_WORD*/); //cdit

  //Buttons
  lpItem = lpTemp + 24;
  CopyToTemplate(0x50010001 /*WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON*/, 0, 2000, 0x80 /*Button*/);
  lpItem += 28;
  CopyToTemplate(0x50010000 /*WS_CHILD|WS_VISIBLE|WS_TABSTOP*/, 0, 2001, 0x80);

  //Edits and Labels
  for (i = 0; i < aEdit.length; ++i)
  {
    lpItem += 28;
    CopyToTemplate(0x50010080 /*WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL*/, 0x200 /*WS_EX_CLIENTEDGE*/, 3000 + i, 0x0081 /*Edit*/);

    if (aLabelT)
    {
      lpItem += 28;
      CopyToTemplate(0x5000008C /*WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP*/, 0, 3100 + i, 0x0082 /*Static*/);
    }

    if (aLabelB)
    {
      lpItem += 28;
      CopyToTemplate(0x5000008C /*WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP*/, 0, 3200 + i, 0x0082 /*Static*/);
    }

    if (aLabelL)
    {
      lpItem += 28;
      CopyToTemplate(0x5000008C /*WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP*/, 0, 3300 + i, 0x0082 /*Static*/);
    }

    if (aLabelR)
    {
      lpItem += 28;
      CopyToTemplate(0x5000008C /*WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP*/, 0, 3400 + i, 0x0082 /*Static*/);
    }
  }

  if (oSys.Call("User32::DialogBoxIndirectParamW", hInstDLL, lpTemp, hWndOwn, InputBoxCallback, 0) > 0)
  {
    if (vEdit instanceof Array)
      vRetVal = aEdit;
    else
      vRetVal = aEdit[0];
  }

  oSys.Call("User32::DestroyIcon", hIcon);
  oSys.UnregisterCallback(InputBoxCallback);
  AkelPad.MemFree(lpTemp);

  return vRetVal;

  function CopyToTemplate(nStyle, nExStyle, nID, nClass)
  {
    AkelPad.MemCopy(lpItem,      nStyle,   3 /*DT_DWORD*/); //style
    AkelPad.MemCopy(lpItem +  4, nExStyle, 3 /*DT_DWORD*/); //dwExtendedStyle
    AkelPad.MemCopy(lpItem + 16, nID,      4 /*DT_WORD*/);  //id
    AkelPad.MemCopy(lpItem + 18, 0xFFFF,   4 /*DT_WORD*/);  //next item is a predefined system class
    AkelPad.MemCopy(lpItem + 20, nClass,   4 /*DT_WORD*/);  //class
  }

  function InputBoxCallback(hWnd, uMsg, wParam, lParam)
  {
    switch (uMsg)
    {
      case 272 : //WM_INITDIALOG
        var Scale =
        {
          Init: function()
          {
            var hMainWnd = AkelPad.GetMainWnd();
            var hDC = oSys.Call("User32::GetDC", hMainWnd);
            this.ScaleX = oSys.Call("Gdi32::GetDeviceCaps", hDC, 88 /*LOGPIXELSX*/);
            this.ScaleY = oSys.Call("Gdi32::GetDeviceCaps", hDC, 90 /*LOGPIXELSY*/);
            oSys.Call("User32::ReleaseDC", hMainWnd, hDC);
            //Align to 16 pixel
            this.ScaleX += (16 - this.ScaleX % 16) % 16;
            this.ScaleY += (16 - this.ScaleY % 16) % 16;
          },
          X: function(n) {return oSys.Call("Kernel32::MulDiv", n, this.ScaleX, 96);},
          Y: function(n) {return oSys.Call("Kernel32::MulDiv", n, this.ScaleY, 96);}
        }
        Scale.Init();

        var lpRect   = AkelPad.MemAlloc(16); //sizeof(RECT)
        var hGuiFont = oSys.Call("Gdi32::GetStockObject", 17 /*DEFAULT_GUI_FONT*/);
        var nFX      = oSys.Call("User32::GetSystemMetrics",  7 /*SM_CXFIXEDFRAME*/);
        var nFY      = oSys.Call("User32::GetSystemMetrics",  8 /*SM_CYFIXEDFRAME*/);
        var nIX      = oSys.Call("User32::GetSystemMetrics", 49 /*SM_CXSMICON*/);
        var nSX      = oSys.Call("User32::GetSystemMetrics", 30 /*SM_CXSIZE*/);
        var nCY      = oSys.Call("User32::GetSystemMetrics",  4 /*SM_CYCAPTION*/);
        var nLabelH  = Scale.Y(13);
        var nEditH   = Scale.Y(20);
        var nButtonW = Scale.X(80);
        var nButtonH = Scale.Y(23);
        var nGapW    = Scale.X(10);
        var nGapH    = Scale.Y(10);
        var nLabelLW = GetTextMaxWidth(aLabelL, 0, hGuiFont);
        var nLabelRW = GetTextMaxWidth(aLabelR, 0, hGuiFont);
        var nClientW = Math.max(GetTextMaxWidth([sCaption]) + nIX + nSX + nGapW, Math.max(GetTextMaxWidth(aLabelT, aLabelB, hGuiFont), Scale.X(nMinEditW)) + nLabelLW + (nLabelLW ? 3 : 0) + nLabelRW + (nLabelRW ? 3 : 0) + nGapW * 2, Scale.X(80) * 2 + nGapW * 3);
        var nEditW   = nClientW - nLabelLW - (nLabelLW ? 3 : 0) - nLabelRW - (nLabelRW ? 3 : 0) - nGapW * 2;
        var nEditX   = nGapW + nLabelLW + (nLabelLW ? 3 : 0);
        var nLabelRX = nEditX + nEditW + 3;
        var nItemY;
        var nOwnX, nOwnY, nOwnW, nOwnH;
        var nDeskX1, nDeskY1, nDeskX2, nDeskY2;
        var nWndX, nWndY, nWndW, nWndH;
        var i;

        //Edits and Labels
        nItemY = nGapH;
        for (i = 0; i < aEdit.length; ++i)
        {
          if (aLabelT && aLabelT[i])
          {
            WindowMoveAndSetText(3100 + i, nEditX, nItemY, nEditW, nLabelH * aLabelT[i].length, aLabelT[i].join("\n"));
            nItemY += nLabelH * aLabelT[i].length + 3;
          }

          if (aLabelL && aLabelL[i])
            WindowMoveAndSetText(3300 + i, nGapW, nItemY + 3, nLabelLW, nLabelH, aLabelL[i]);

          if (aLabelR && aLabelR[i])
            WindowMoveAndSetText(3400 + i, nLabelRX, nItemY + 3, nLabelRW, nLabelH, aLabelR[i]);

          //Edit
          WindowMoveAndSetText(3000 + i, nEditX, nItemY, nEditW, nEditH, aEdit[i]);
          nItemY += nEditH;

          if (aLabelB && aLabelB[i])
          {
            nItemY += 3;
            WindowMoveAndSetText(3200 + i, nEditX, nItemY, nEditW, nLabelH * aLabelB[i].length, aLabelB[i].join("\n"));
            nItemY += nLabelH * aLabelB[i].length;
          }
          nItemY += nGapH;
        }

        //Buttons
        WindowMoveAndSetText(2000, (nClientW - nGapW) / 2 - nButtonW, nItemY, nButtonW, nButtonH, sTxtOK);
        WindowMoveAndSetText(2001, (nClientW + nGapW) / 2, nItemY, nButtonW, nButtonH, sTxtCancel);

        oSys.Call("User32::GetWindowRect", hWndOwn, lpRect);
        nOwnX = AkelPad.MemRead(lpRect,      3 /*DT_DWORD*/);
        nOwnY = AkelPad.MemRead(lpRect  + 4, 3 /*DT_DWORD*/);
        nOwnW = AkelPad.MemRead(lpRect +  8, 3 /*DT_DWORD*/) - nOwnX;
        nOwnH = AkelPad.MemRead(lpRect + 12, 3 /*DT_DWORD*/) - nOwnY;

        oSys.Call("User32::SystemParametersInfoW", 0x30 /*SPI_GETWORKAREA*/, 0, lpRect, 0);
        nDeskX1 = AkelPad.MemRead(lpRect     , 3 /*DT_DWORD*/);
        nDeskY1 = AkelPad.MemRead(lpRect +  4, 3 /*DT_DWORD*/);
        nDeskX2 = AkelPad.MemRead(lpRect +  8, 3 /*DT_DWORD*/);
        nDeskY2 = AkelPad.MemRead(lpRect + 12, 3 /*DT_DWORD*/);
        AkelPad.MemFree(lpRect);

        nWndW = nClientW + nFX * 2;
        nWndH = nItemY + nButtonH + nGapH + nFY * 2 + nCY;
        nWndX = nOwnX + (nOwnW - nWndW) / 2;
        nWndY = nOwnY + (nOwnH - nWndH) / 2;

        if ((nWndX + nWndW) > nDeskX2)
          nWndX = nDeskX2 - nWndW;
        if (nWndX < nDeskX1)
          nWndX = nDeskX1;
        if ((nWndY + nWndH) > nDeskY2)
          nWndY = nDeskY2 - nWndH;
        if (nWndY < nDeskY1)
          nWndY = nDeskY1;

        //Dialog
        oSys.Call("User32::SendMessageW", hWnd, 0x0080 /*WM_SETICON*/, 0 /*ICON_SMALL*/, hIcon);
        oSys.Call("User32::MoveWindow", hWnd, nWndX, nWndY, nWndW, nWndH, 0);
        oSys.Call("User32::SetWindowTextW", hWnd, sCaption);
        oSys.Call("User32::SetFocus", oSys.Call("User32::GetDlgItem", hWnd, 3000 + nFocus));
        oSys.Call("User32::SendDlgItemMessageW", hWnd, 3000 + nFocus, 177 /*EM_SETSEL*/, 0, -1);
        break;

      case 273 : //WM_COMMAND
        if (wParam == 2000)
        {
          var nEditLen = 32767;
          var lpEdit   = AkelPad.MemAlloc((nEditLen + 1) * 2);
          var nBadInd;
          var i;

          for (i = 0; i < aEdit.length; ++i)
          {
            oSys.Call("User32::GetDlgItemTextW", hWnd, 3000 + i, lpEdit, nEditLen);
            aEdit[i] = AkelPad.MemRead(lpEdit, 1 /*DT_UNICODE*/);
          }

          AkelPad.MemFree(lpEdit);

          if (oFunc)
            nBadInd = oFunc(hWnd, aEdit, vFuncArg);

          if ((typeof nBadInd == "number") && (nBadInd >= 0) && (nBadInd < aEdit.length))
          {
            oSys.Call("User32::SetFocus", oSys.Call("User32::GetDlgItem", hWnd, 3000 + nBadInd));
            oSys.Call("User32::SendDlgItemMessageW", hWnd, 3000 + nBadInd, 177 /*EM_SETSEL*/, 0, -1);
          }
          else
            oSys.Call("User32::PostMessageW", hWnd, 16 /*WM_CLOSE*/, 1, 0);
        }

        else if ((wParam == 2001) || (wParam == 2 /*IDCANCEL*/))
          oSys.Call("User32::PostMessageW", hWnd, 16 /*WM_CLOSE*/, 0, 0);
        break;

      case 16 : //WM_CLOSE
        oSys.Call("User32::DestroyIcon", oSys.Call("User32::SendMessageW", hWnd, 0x007F /*WM_GETICON*/, 0 /*ICON_SMALL*/, 0));
        oSys.Call("User32::EndDialog", hWnd, wParam);
    }

    return 0;

    function GetTextMaxWidth(aText1, aText2, hFont)
    {
      var nWidth = 0;
      var aText;
      var hDC;
      var lpSize;
      var i, n;

      if (aText1)
      {
        if (aText2)
          aText = aText1.concat(aText2);
        else
          aText = aText1;
      }
      else
        aText = aText2;

      if (aText)
      {
        hDC    = oSys.Call("User32::GetDC", hWnd);
        lpSize = AkelPad.MemAlloc(8);

        if (hFont)
          oSys.Call("Gdi32::SelectObject", hDC, hFont);

        oSys.Call("Gdi32::SetMapMode", hDC, 1 /*MM_TEXT*/);

        for (i = 0; i < aText.length; ++i)
        {
          if (aText[i])
          {
            if (aText[i] instanceof Array)
            {
              for (n = 0; n < aText[i].length; ++n)
              {
                oSys.Call("Gdi32::GetTextExtentPoint32W", hDC, aText[i][n], aText[i][n].length, lpSize);

                if (nWidth < AkelPad.MemRead(lpSize, 3 /*DT_DWORD*/))
                  nWidth = AkelPad.MemRead(lpSize, 3 /*DT_DWORD*/);
              }
            }
            else
            {
              oSys.Call("Gdi32::GetTextExtentPoint32W", hDC, aText[i], aText[i].length, lpSize);

              if (nWidth < AkelPad.MemRead(lpSize, 3 /*DT_DWORD*/))
                nWidth = AkelPad.MemRead(lpSize, 3 /*DT_DWORD*/);
            }
          }
        }

        oSys.Call("User32::ReleaseDC", hWnd, hDC);
        AkelPad.MemFree(lpSize);
      }

      return nWidth;
    }

    function WindowMoveAndSetText(nID, nX, nY, nW, nH, sText)
    {
      oSys.Call("User32::MoveWindow", oSys.Call("User32::GetDlgItem", hWnd, nID), nX, nY, nW, nH, 0);
      oSys.Call("User32::SendDlgItemMessageW", hWnd, nID, 48 /*WM_SETFONT*/, hGuiFont, 0);
      oSys.Call("User32::SetDlgItemTextW", hWnd, nID, sText);
    }
  }
}


Example of use:
InputBox.js

Code:
//Example of use InputBox function - ver. 2013-04-14

if (! AkelPad.Include("InputBox_function.js")) WScript.Quit();

var hMainWnd = AkelPad.GetMainWnd();
var vRetVal;

vRetVal = InputBox();
MessageBox(vRetVal);

vRetVal = InputBox(
  hMainWnd,
  "InputBox - medium version",
  ["Input value a:", "Input value b:", "Input value c:"],
  ["Edit value a", "Edit value b", "Edit value c"]);
MessageBox(vRetVal);

vRetVal = InputBox(
  hMainWnd,
  "InputBox - full version",
  ["Top label 1\nInput value a:", "Input value b:", "Top label 3\nInput value c:"],
  ["Edit value a", "Edit value x", "Edit value c"],
  2,
  ErrorBox,
  ["Edit value a", "Edit value b", "Edit value c"],
  300,
  ["Bottom label 1\nin two rows", "Bottom label 2", "Bottom label 3\n\nIf you want to save the values press OK button."],
  ["Left label 1:", "Left label 2:", "Left label 3:"],
  ["Right label 1", "Right label 2", "Right label 3"]);
MessageBox(vRetVal);

function MessageBox(vRetVal)
{
  AkelPad.MessageBox(hMainWnd, "Returned value:\n" + (vRetVal == undefined ? ""  : vRetVal) + "\n\nType:\n" + typeof vRetVal + (vRetVal instanceof Array ? " Array" : ""), "Message", 0x40);
}

function ErrorBox(hWnd, aEdit, aLimit)
{
  for (var i = 0; i < aEdit.length; i++)
  {
    if (aEdit[i] != aLimit[i])
    {
      AkelPad.MessageBox(hWnd, 'In the field #' + (i + 1) + ' must be: "' + aLimit[i] + '"', "Error", 0x30);
      return i;
    }
  }
  return -1;
}


Last edited by KDJ on Sat Jun 14, 2014 9:54 pm; edited 10 times in total
Back to top
View user's profile Send private message
FeyFre



Joined: 07 Aug 2007
Posts: 2038
Location: Vinnitsa, Ukraine

PostPosted: Tue May 08, 2012 9:22 pm    Post subject: Reply with quote

Extends(or creates) selection bounding on quotes or parenthesis

QuoteExtend.js
Code:
// === [QuoteExtend.js] ===
// Panych Y.W. aka FeyFre(c) 2012-2014
//
// Version 1.0.1
//
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=17980#17980
//
// Extends selection into delimiting quotes(parenthesis)
//
// Argument:
//   string, specifies left & right bound characters. If string consists of single character - side delimiters are equal. If opted treated as double-quote delimiter
//
// Example:
//   Call( "Scripts::Main", 1, "QuoteExtend.js" ) - default, extend to bounding double-quotes
//   Call( "Scripts::Main", 1, "QuoteExtend.js", `'"'` ) - the same
//   Call( "Scripts::Main", 1, "QuoteExtend.js", `"'"` ) - extend to bounding single-quotes
//   Call( "Scripts::Main", 1, "QuoteExtend.js", '"`"' ) - extend to bounding single-quotes
//   Call( "Scripts::Main", 1, "QuoteExtend.js", "()" )  - extend to bounding round parenthesis
//
//   v1.0 (2012.05.08) Initial release
//   v1.0.1 (2014.04.27) Usage examples fix
//
var FR_DOWN   = 0x00000001;
var FR_UP   = 0x00100000;
var edit = AkelPad.GetEditWnd();
var doit = function(edit, quote)
{
   var qt = quote || '"';
   var ql = qt.charAt(0) || '"';
   var qr = qt.charAt(1) || ql;
   var wnd = edit || AkelPad.GetEditWnd();
   var l = AkelPad.GetSelStart();
   var r = AkelPad.GetSelEnd();
   AkelPad.SetSel(r,r);
   var fr = AkelPad.TextFind(wnd, qr, FR_DOWN);
   AkelPad.SetSel(l,l);
   var fl = AkelPad.TextFind(wnd, ql, FR_UP);
   AkelPad.SetSel(fl==-1?l:(fl+1), fr==-1?r:fr);
}

var quotes = (WScript.Arguments.length >0)? WScript.Arguments(0):'"';
if(edit)
{
   doit(edit,quotes);
}


Last edited by FeyFre on Sun Apr 27, 2014 3:12 pm; edited 1 time in total
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
VladSh



Joined: 29 Nov 2006
Posts: 2610
Location: Киев, Русь

PostPosted: Thu May 17, 2012 8:53 am    Post subject: Reply with quote

FullScreenEx.js

Code:
///Go to FullScreen-mode with additional options for display panels; a return to normal-mode
///Переход в полноэкранный режим с возможностью отображения определённого тулбара; возвращение в нормальный режим
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=18081#18081
// Version: 2.6 (2012.12.26)
//
// Parameters:
//    • ToolBar - ["имя dll-файла_1 плагина без расширения","номера рядов через запятую"],["имя dll-файла_2 плагина без расширения","номера рядов через запятую"];
//            если в одном из плагинов нужно отобразить все ряды, то параметр с номерами рядов можно не записывать
//    • Explorer, CodeFold, Clipboard, Log, StatusBar, Menu: [0] - не отображать / 1 - отображать
//      • TabBar: [0] - не отображать / 1 - отображать с автоопределением положения / 4301 - сверху / 4302 - снизу
//
// Examples:
// -"Обычный" Call("Scripts::Main", 1, "FullScreenEx.js")
// -"С тулбаром по умолчанию" Call("Scripts::Main", 1, "FullScreenEx.js", `-ToolBar='["ToolBar"]'`)
// -"С дополнительной панелью для работы с XML" Call("Scripts::Main", 1, "FullScreenEx.js", `-ToolBar='["ToolBar","1,3"],["ToolBar-XML"]' -CodeFold=1`)
// -"Псевдо-SDI" Call("Scripts::Main", 1, "FullScreenEx.js", `-ToolBar='["ToolBar"]' -Menu=1 -StatusBar=1`)

var pFullScreen = "FullScreen::Main";
var Toolbars = AkelPad.GetArgValue("ToolBar", "");
if (Toolbars) {
   Toolbars = eval('[' + eval(Toolbars) + ']');
   for (i = 0; i < Toolbars.length; i++) {
      Toolbars[i] = getToolbar(Toolbars[i]);
   }
}

//ПЕРЕХОД ИЗ ОБЫЧНОГО РЕЖИМА В ПОЛНОЭКРАННЫЙ
if (!AkelPad.IsPluginRunning(pFullScreen)) {
   var pExplorer = "Explorer::Main";
   var pCodeFold = "Coder::CodeFold";
   var pClipboard = "Clipboard::Capture";
   var pLog = "Log::Output";
   var hWndMain = AkelPad.GetMainWnd();
   
   var bExplorer = AkelPad.GetArgValue("Explorer", 0);
   var bCodeFold = AkelPad.GetArgValue("CodeFold", 0);
   var bClipboard = AkelPad.GetArgValue("Clipboard", 0);
   var bLog = AkelPad.GetArgValue("Log", 0);
   var IDM_VIEW_SHOW_STATUSBAR = 4211;
   var bStatusBar = AkelPad.GetArgValue("StatusBar", 0);
   var bMenu = AkelPad.GetArgValue("Menu", 0);
   var nTabBar = AkelPad.GetArgValue("TabBar", 0);
   
   //если панели перед запуском включены, - отключаем, т.к. без этого потом не запустятся
   
   if (Toolbars) {
      for (i = Toolbars.length - 1; i >= 0; i--) {
         if (AkelPad.IsPluginRunning(Toolbars[i].file)) {
            AkelPad.Call(Toolbars[i].file);
         }
      }
   }
   
   if (bExplorer && AkelPad.IsPluginRunning(pExplorer))
      AkelPad.Call(pExplorer);
   
   if (bCodeFold && AkelPad.IsPluginRunning(pCodeFold))
      AkelPad.Call(pCodeFold);
   
   if (bClipboard && AkelPad.IsPluginRunning(pClipboard))
      AkelPad.Call(pClipboard);
   
   if (bLog && AkelPad.IsPluginRunning(pLog))
      AkelPad.Call(pLog);
   
   if (bStatusBar && AkelPad.SendMessage(hWndMain, 1222 /*AKD_GETMAININFO*/, 142 /*MI_STATUSBAR*/, 0))
      AkelPad.Command(IDM_VIEW_SHOW_STATUSBAR);
   
   if (bMenu) {
      var oSys = AkelPad.SystemFunction();
      var hMenu = oSys.Call("user32::GetMenu", hWndMain);
   }
   
   //ЗАПУСК ПОЛНОЭКРАННОГО РЕЖИМА
   AkelPad.Call(pFullScreen);
   
   if (Toolbars) {
      for (i = Toolbars.length - 1; i >= 0; i--) {
         AkelPad.Call(Toolbars[i].file, 1, Toolbars[i].rows);
      }
   }
   
   if (bExplorer)
      AkelPad.Call(pExplorer);
   
   if (bCodeFold)
      AkelPad.Call(pCodeFold);
   
   if (bClipboard)
      AkelPad.Call(pClipboard);
   
   if (bLog)
      AkelPad.Call(pLog);
   
   if (bStatusBar)
      AkelPad.Command(IDM_VIEW_SHOW_STATUSBAR);
   
   if (bMenu)
      oSys.Call("user32::SetMenu", hWndMain, hMenu);
   
   if (nTabBar) {
      var nCommand;
      if (nTabBar > 1)
         nCommand = nTabBar;
      else {
         var nState = AkelPad.SendMessage(hWndMain, 1222 /*AKD_GETMAININFO*/, 157 /*MI_TABOPTIONSMDI*/, 0);
         if (nState & 2 /*TAB_VIEW_TOP*/)
            nCommand = 4301;      /*IDM_WINDOW_TABVIEW_TOP*/
         else
            nCommand = 4302;      /*IDM_WINDOW_TABVIEW_BOTTOM*/
      }
      AkelPad.Command(4303 /*IDM_WINDOW_TABVIEW_NONE*/);
      AkelPad.Command(nCommand);
   }
}

//ПЕРЕХОД ИЗ ПОЛНОЭКРАННОГО РЕЖИМА В ОБЫЧНЫЙ
else
{
   AkelPad.Call(pFullScreen);
   
   //если тулбар отключён - включаем для нормального восстановления вида проги
   if (Toolbars) {
      for (i = Toolbars.length - 1; i >= 0; i--) {
         if (!AkelPad.IsPluginRunning(Toolbars[i].file)) {
            AkelPad.Call(Toolbars[i].file);
         }
      }
   }
}

// преобразование отдельного тулбара из соотв. аргумента в определённую структуру
function getToolbar(pToolbar) {
   return {
      file: pToolbar[0] + "::Main",
      rows: (pToolbar.length > 1 && pToolbar[pToolbar.length-1]) ? pToolbar[1] : ""
   }
}

Поддерживаются параметры (соответствуют панелям):
• ToolBar (STRING) - имя dll-файла без расширения
все остальные как BOOLEAN-INTEGER (0/1):
• Log
• Clipboard
• Explorer
• CodeFold
• StatusBar
• Menu
• TabBar (0/1/4301/4302)

Благодарности: Lenchik, Instructor, San_dr, KDJ.


Last edited by VladSh on Wed Dec 26, 2012 9:43 am; edited 6 times in total
Back to top
View user's profile Send private message Visit poster's website
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5311

PostPosted: Sun Jun 03, 2012 11:33 am    Post subject: Reply with quote

FontSwitch.js
Code:
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=18278#18278
// Version v1.2
//
//
//// Cycle switch between fonts.

//Options
var lpFontList=[["Courier New", 10],
                ["MS Sans Serif", 8],
                ["Arial", 10]];

//Variables
var hMainWnd=AkelPad.GetMainWnd();
var hWndEdit=AkelPad.GetEditWnd();
var lpLogFont;
var pFontName="";
var nFontSize=0;
var i;

if (lpLogFont=AkelPad.MemAlloc(92 /*sizeof(LOGFONTW)*/))
{
  AkelPad.SendMessage(hMainWnd, 1233 /*AKD_GETFONTW*/, hWndEdit, lpLogFont);
  pFontName=AkelPad.MemRead(lpLogFont + 28 /*offsetof(LOGFONTW, lfFaceName)*/, 1 /*DT_UNICODE*/);
  nFontSize=AkelPad.SendMessage(hWndEdit, 3188 /*AEM_GETCHARSIZE*/, 3 /*AECS_POINTSIZE*/, 0);
  AkelPad.MemFree(lpLogFont);
}

if (pFontName && nFontSize)
{
  for (i=0; i < lpFontList.length; ++i)
  {
    if (lpFontList[i][0] == pFontName && lpFontList[i][1] == nFontSize)
      break;
  }
  if (++i >= lpFontList.length) i=0;
  AkelPad.Font(lpFontList[i][0], 0, lpFontList[i][1]);
}


Cycle switch between fonts.
Back to top
View user's profile Send private message Send e-mail
KDJ



Joined: 06 Mar 2010
Posts: 1334
Location: Poland

PostPosted: Sun Jun 03, 2012 2:16 pm    Post subject: Reply with quote

Cycle switch between fonts. Alternative version of FontSwitch.js by Instructor.
The script saves settings in .ini file. To change the font list, you can edit this file.

FontCycleSwitch.js

Code:
/***************************************************************************************
FontCycleSwitch.js - ver. 2012-06-17

Cycle switch between fonts. Extended version of FontSwitch.js by Instructor.

Call("Scripts::Main", 1, "FontCycleSwitch.js")
Call("Scripts::Main", 1, "FontCycleSwitch.js", '-AddCurFont=1 -Reverse=1 -Local=1')
Arguments:
  AddCurFont
    1 - add font from current edit window to the list (if not exists)
    0 - not add (default)
  Reverse
    1 - switch in reverse direction
    0 - switch with increasing index (default)
  Local
    1 - change font locally
    0 - change font globally (default)

The script saves settings in .ini file. To change the font list, you can edit this file.
Example of contents the configuration file:
nFont=0;
aFonts=[
["Courier New",3,11],
["MS Sans Serif",1,17],
["Tahoma",2,9],
["Lucida Console",3,12],
["Arial",4,15]
];
***************************************************************************************/

var bAddFont = AkelPad.GetArgValue("AddCurFont", 0);
var bReverse = AkelPad.GetArgValue("Reverse", 0);
var bLocal   = AkelPad.GetArgValue("Local", 0);
var oSys     = AkelPad.SystemFunction();
var sIniFile = WScript.ScriptFullName.substring(0, WScript.ScriptFullName.lastIndexOf(".")) + ".ini";
var oFSO     = new ActiveXObject("Scripting.FileSystemObject");
var hEditWnd = AkelPad.GetEditWnd();
var nFont    = 0;
var aFonts   = [];
var hFont;
var aCurFont;
var oError;
var sIniTxt;
var oFile;
var i;

if (hEditWnd)
{
  //read settings
  if (oFSO.FileExists(sIniFile))
  {
    try
    {
      eval(AkelPad.ReadFile(sIniFile));
    }
    catch (oError)
    {
    }
  }

  //check index
  if ((nFont < 0) || (! aFonts.length))
    nFont = 0;
  else if (nFont >= aFonts.length)
    nFont = aFonts.length - 1;

  //add current font
  if (bAddFont || (! aFonts.length))
  {
    hFont    = AkelPad.SendMessage(hEditWnd, 0x0031 /*WM_GETFONT*/, 0, 0);
    aCurFont = ConvertFontFormat(hFont, 2, 3);

    for (i = 0; i < aFonts.length; ++i)
    {
      if ((aFonts[i][0] == aCurFont[0]) && (aFonts[i][1] == aCurFont[1]) && (aFonts[i][2] == aCurFont[2]))
        break;
    }
    if (i == aFonts.length)
    {
      aFonts.splice(nFont, 0, aCurFont);
      if (! bReverse)
        ++nFont;
    }
  }

  //next index
  if (bReverse)
  {
    if (--nFont < 0)
      nFont = aFonts.length - 1;
  }
  else
  {
    if (++nFont >= aFonts.length)
      nFont = 0;
  }

  //set font
  if (bLocal)
  {
    hFont = ConvertFontFormat(aFonts[nFont], 3, 2);
    AkelPad.SendMessage(hEditWnd, 0x0030 /*WM_SETFONT*/, hFont, 1);
    oSys.Call("Gdi32::DeleteObjectW", hFont);
  }
  else
    AkelPad.Font(aFonts[nFont][0], aFonts[nFont][1], aFonts[nFont][2]);

  //save settings
  sIniTxt = 'nFont='+ nFont + ';\r\naFonts=[\r\n';

  for (i = 0; i < aFonts.length; ++i)
    sIniTxt += '["' + aFonts[i][0] + '",' + aFonts[i][1] + ',' + aFonts[i][2] + '],\r\n';
 
  if (sIniTxt.slice(-3, -2) == ",")
    sIniTxt = sIniTxt.slice(0, -3);
 
  sIniTxt += '\r\n];';

  oFile = oFSO.OpenTextFile(sIniFile, 2, true, 0);
  oFile.Write(sIniTxt);
  oFile.Close();
}

function ConvertFontFormat(vFont, nInType, nRetType)
{
  //nInType, nRetType:
  //1 - pointer to LOGFONT structure
  //2 - handle to font
  //3 - array [sFontName, nFontStyle, nFontSize]

  if (nInType == nRetType)
    return vFont;

  var nLFSize  = 28 + 32 * 2; //sizeof(LOGFONTW)
  var lpLF     = AkelPad.MemAlloc(nLFSize);
  var hFont;
  var hDC;
  var nHeight;
  var nWeight;
  var bItalic;
  var vRetVal;
  var i;

  if (nInType == 1)
  {
    for (i = 0; i < nLFSize; ++i)
      AkelPad.MemCopy(lpLF + i, AkelPad.MemRead(vFont + i,  5 /*DT_BYTE*/, 5 /*DT_BYTE*/));
  }
  else if (nInType == 2)
  {
    if (! vFont)
      vFont = oSys.Call("Gdi32::GetStockObject", 13 /*SYSTEM_FONT*/);

    oSys.Call("Gdi32::GetObjectW", vFont, nLFSize, lpLF);
  }
  else if (nInType == 3)
  {
    hDC     = oSys.Call("User32::GetDC", hEditWnd);
    nHeight = -oSys.Call("Kernel32::MulDiv", vFont[2], oSys.Call("Gdi32::GetDeviceCaps", hDC, 90 /*LOGPIXELSY*/), 72);
    oSys.Call("User32::ReleaseDC", hEditWnd, hDC);

    nWeight = 400;
    bItalic = 0;
    if ((vFont[1] == 2) || (vFont[1] == 4))
      nWeight = 700;
    if (vFont[1] > 2)
      bItalic = 1;

    AkelPad.MemCopy(lpLF     , nHeight, 3 /*DT_DWORD*/); //lfHeight
    AkelPad.MemCopy(lpLF + 16, nWeight, 3 /*DT_DWORD*/); //lfWeight
    AkelPad.MemCopy(lpLF + 20, bItalic, 5 /*DT_BYTE*/);  //lfItalic
    AkelPad.MemCopy(lpLF + 28, vFont[0], 1 /*DT_UNICODE*/); //lfFaceName
  }

  if (nRetType == 1)
    vRetVal = lpLF;
  else if (nRetType == 2)
  {
    vRetVal = oSys.Call("Gdi32::CreateFontIndirectW", lpLF);
    AkelPad.MemFree(lpLF);
  }
  else if (nRetType == 3)
  {
    vRetVal    = [];
    vRetVal[0] = AkelPad.MemRead(lpLF + 28, 1 /*DT_UNICODE*/); //lfFaceName

    nWeight = AkelPad.MemRead(lpLF + 16, 3 /*DT_DWORD*/); //lfWeight
    bItalic = AkelPad.MemRead(lpLF + 20, 5 /*DT_BYTE*/);  //lfItalic

    if (nWeight < 600)
      vRetVal[1] = 1;
    else
      vRetVal[1] = 2;

    if (bItalic)
      vRetVal[1] += 2;

    hDC        = oSys.Call("User32::GetDC", hEditWnd);
    nHeight    = AkelPad.MemRead(lpLF, 3 /*DT_DWORD*/); //lfHeight
    vRetVal[2] = -oSys.Call("Kernel32::MulDiv", nHeight, 72, oSys.Call("Gdi32::GetDeviceCaps", hDC, 90 /*LOGPIXELSY*/));
    oSys.Call("User32::ReleaseDC", hEditWnd, hDC);
    AkelPad.MemFree(lpLF);
  }

  return vRetVal;
}


------------------------------------
Another version of the script.
Note:
- this script modifies itself (saves nFont value),
- the script must be saved in ANSI format.
Second part of the script name comes from VladSh: http://akelpad.sourceforge.net/forum/viewtopic.php?p=18308&highlight=#18308

FontCycleSwitch_PerverseCode.js

Code:
// FontCycleSwitch_PerverseCode.js - ver. 2012-06-04
//
// Cycle switch between fonts. Alternative version of FontSwitch.js by Instructor.
//
// Call("Scripts::Main", 1, "FontCycleSwitch_PerverseCode.js")
//
// Note: This script modifies itself (saves nFont value).
//       The script must be saved in ANSI format.

//here you can insert the desired fonts:
var aFonts = [
               ["Courier New",    0, 11],
               ["MS Sans Serif",  1, 17],
               ["Tahoma",         2,  9],
               ["Lucida Console", 3, 12],
               ["Arial",          4, 15]
             ];

//////////////
var nFont = 0;
//////////////

if (nFont >= aFonts.length)
  nFont = 0;

AkelPad.Font(aFonts[nFont][0], aFonts[nFont][1], aFonts[nFont][2]);

var sScrFile = WScript.ScriptFullName;
var sScrText = AkelPad.ReadFile(sScrFile).replace(/(var\s+nFont\s*=\s*)(\d+)(\s*;)/, "$1" + ++nFont + "$3");
var oFSO     = new ActiveXObject("Scripting.FileSystemObject");
var oFile    = oFSO.OpenTextFile(sScrFile, 2, true, 0);

oFile.Write(sScrText);
oFile.Close();


Last edited by KDJ on Sun Jun 17, 2012 7:50 pm; edited 4 times in total
Back to top
View user's profile Send private message
Infocatcher



Joined: 06 Aug 2007
Posts: 1612

PostPosted: Mon Jun 04, 2012 10:09 am    Post subject: Reply with quote

adblockPlusChecksum.js
Code:
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=18306#18306
// http://infocatcher.ucoz.net/js/akelpad_scripts/adblockPlusChecksum.js

// (c) Infocatcher 2012
// version 0.1.1 - 2012-06-09

// Adds checksum to Adblock Plus subscription
// http://adblockplus.org/en/faq_internal#checksum

// Dependencies:
//   getHash.js   - http://akelpad.sourceforge.net/forum/viewtopic.php?p=11096#11096
//   converter.js - http://akelpad.sourceforge.net/forum/viewtopic.php?p=11095#11095


var hMainWnd = AkelPad.GetMainWnd();
var hWndEdit = AkelPad.GetEditWnd();
var oSys = AkelPad.SystemFunction();

var hashesArgs = {
   codePage: 65001 // UTF-8 for MD5
};
var convertersArgs = {
   codePageBase64: 28591 // ISO-8859-1 for base64
};

if(
   hMainWnd
   && hWndEdit
   && AkelPad.Include("..\\getHash.js")
   && AkelPad.Include("..\\converter.js")
) {
   if(typeof hashes == "undefined")
      AkelPad.MessageBox(hMainWnd, "Required getHash.js v.0.2.3 and higher", WScript.ScriptName, 16 /*MB_ICONERROR*/);
   else if(typeof converters == "undefined")
      AkelPad.MessageBox(hMainWnd, "Required converter.js v.0.2.3 and higher", WScript.ScriptName, 16 /*MB_ICONERROR*/);
   else
      addChecksum();
}

function _localize(s) {
   var strings = {
      "This is not a Adblock Plus subscription!": {
         ru: "Это не подписка для Adblock Plus!"
      },
      "Checksum already added!": {
         ru: "Контрольная сумма уже добавлена!"
      }
   };
   var lng;
   switch(AkelPad.GetLangId(1 /*LANGID_PRIMARY*/)) {
      case 0x19: lng = "ru"; break;
      default:   lng = "en";
   }
   _localize = function(s) {
      return strings[s] && strings[s][lng] || s;
   };
   return _localize(s);
}

function addChecksum() {
   // adblock_plus-2.0.3-sm+tb+fn+fx.xpi\modules\Synchronizer.jsm
   // function readFilters(subscription, text, errorCallback)

   // adblock_plus-2.0.3-sm+tb+fn+fx.xpi\modules\Utils.jsm
   // Checksum is an MD5 checksum (base64-encoded without the trailing "=") of
   // all lines in UTF-8 without the checksum line, joined with "\n".

   var text = AkelPad.GetTextRange(0, -1, 2 /*\n*/);
   if(!/^\[Adblock(\s*Plus\s*([\d\.]+)?)?\]\n/i.test(text)) {
      AkelPad.MessageBox(
         hMainWnd,
         _localize("This is not a Adblock Plus subscription!"),
         WScript.ScriptName,
         48 /*MB_ICONEXCLAMATION*/
      );
      return;
   }
   if(/\n[ \t]*![ \t]*checksum[ \t:-]+([\w+\/=]+)\n/i.test(text)) {
      var oldChecksum = RegExp.$1;
      text = RegExp.leftContext + "\n" + RegExp.rightContext;
      var insPosStart = RegExp.leftContext.length + 1;
      var insPosEnd = RegExp.leftContext.length + RegExp.lastMatch.length - 1;
      var insNoNewLine = true;
   }
   var newChecksum = generateChecksum(text);
   if(oldChecksum && newChecksum == oldChecksum) {
      AkelPad.MessageBox(
         hMainWnd,
         _localize("Checksum already added!"),
         WScript.ScriptName,
         64 /*MB_ICONINFORMATION*/
      );
      return;
   }

   if(!insPosStart && /^[^\n\r]*\n/.test(text))
      insPosStart = insPosEnd = RegExp.lastMatch.length - 1;

   setRedraw(hWndEdit, false);
   AkelPad.SetSel(insPosStart, insPosEnd);
   AkelPad.ReplaceSel((insNoNewLine ? "" : "\n") + "! Checksum: " + newChecksum);
   setRedraw(hWndEdit, true);
}
function generateChecksum(str) {
   str = str.replace(/[\r\n]+/g, "\n");

   // Perl: md5_base64($data)
   // PHP: preg_replace('/=+$/', '', base64_encode(pack('H*',md5($data))));
   var hash = hashes.md5(str);
   var pached = pack(hash);
   var base64 = converters.base64.encode(pached);
   return base64.replace(/=+$/, "");
}

function pack(str) {
   // Based on code from http://phpjs.org/functions/pack:880 (only for pack("H*", str))
   // + String[N] => String.charAt(N)
   var result = "";
   var quantifier = str.length;
   for (var i = 0; i < quantifier; i += 2) {
       // Always get per 2 bytes...
       var word = str.charAt(i);
       if (((i + 1) >= quantifier) || typeof(str.charAt(i + 1)) === 'undefined') {
           word += '0';
       } else {
           word += str.charAt(i + 1);
       }
       result += String.fromCharCode(parseInt(word, 16));
   }
   return result;
}

function setRedraw(hWnd, bRedraw) {
   AkelPad.SendMessage(hWnd, 11 /*WM_SETREDRAW*/, bRedraw, 0);
   bRedraw && oSys.Call("user32::InvalidateRect", hWnd, 0, true);
}
<download | mirror | development version>
Adds checksum to Adblock Plus subscription.
Dependencies:


Last edited by Infocatcher on Sun Feb 10, 2013 6:29 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1334
Location: Poland

PostPosted: Sun Jun 10, 2012 3:55 pm    Post subject: Reply with quote

Switch between different views of AkelPad screen.

This script has been moved to another location: ScreenView.js


Last edited by KDJ on Mon Dec 17, 2012 8:34 pm; edited 6 times in total
Back to top
View user's profile Send private message
Infocatcher



Joined: 06 Aug 2007
Posts: 1612

PostPosted: Wed Jun 13, 2012 7:35 am    Post subject: Reply with quote

restart.js
Code:
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=18433#18433
// http://infocatcher.ucoz.net/js/akelpad_scripts/restart.js
// https://github.com/Infocatcher/AkelPad_scripts/blob/master/restart.js

// (c) Infocatcher 2012-2014
// version 0.1.1+ - 2014-03-29

// Restart AkelPad

// Dependencies:
//   Sessions plugin
//   NirCmd utility - http://www.nirsoft.net/utils/nircmd.html

// Arguments:
//   -nirCmd="path\to\nircmd.exe" - you can use environment variables like %ProgramFiles%
//   -session="OnExit"            - name of autosaved session in Sessions plugin
//   -sessionAutoSave=false       - checked state of "save on exit" in Sessions plugin settings
//   -sessionAutoLoad=false       - checked state of "open on start" in Sessions plugin settings

// Usage:
//   Call("Scripts::Main", 1, "restart.js")
//   Call("Scripts::Main", 1, "restart.js", '-nirCmd="%a\..\NirCmd\nircmd.exe" -session="OnExit"')

var oSys = AkelPad.SystemFunction();
var akelDir = AkelPad.GetAkelDir();
var nirCmdPath = AkelPad.GetArgValue("nirCmd", "%a\\AkelFiles\\Utils\\nircmd.exe");
var nirCmd = expandEnvironmentVariables(nirCmdPath);
if(!new ActiveXObject("Scripting.FileSystemObject").FileExists(nirCmd)) {
   error(
      "NirCmd utility not found!\nYou can download it here: http://www.nirsoft.net/utils/nircmd.html\n\n"
      + (nirCmd == nirCmdPath ? nirCmd : nirCmdPath + "\n=> " + nirCmd)
   );
   WScript.Quit();
}
var session = AkelPad.GetArgValue("session", "OnExit");
var sessionAutoSave = AkelPad.GetArgValue("sessionAutoSave", false);
var sessionAutoLoad = AkelPad.GetArgValue("sessionAutoLoad", false);
var pid = oSys.Call("kernel32::GetCurrentProcessId");

// Get real AkelPad executable
var MAX_PATH = 0x104;
var lpBuffer = AkelPad.MemAlloc(MAX_PATH*_TSIZE);
if(lpBuffer) {
   if(oSys.Call("kernel32::GetModuleFileName" + _TCHAR, null, lpBuffer, MAX_PATH))
      var akelExe = AkelPad.MemRead(lpBuffer, _TSTR);
   else
      failed("GetModuleFileName");
   AkelPad.MemFree(lpBuffer);
}
if(!akelExe)
   akelExe = akelDir + "\\AkelPad.exe";

// Get current directory
var nBufferLength = oSys.Call("kernel32::GetCurrentDirectory" + _TCHAR, 0, 0);
if(nBufferLength) {
   var lpBuffer = AkelPad.MemAlloc(nBufferLength*_TSIZE);
   if(lpBuffer) {
      if(oSys.Call("kernel32::GetCurrentDirectory" + _TCHAR, nBufferLength, lpBuffer))
         var curDir = AkelPad.MemRead(lpBuffer, _TSTR);
      else
         failed("GetCurrentDirectory");
      AkelPad.MemFree(lpBuffer);
   }
}
if(!curDir)
   curDir = akelDir;

if(!sessionAutoSave || !AkelPad.IsPluginRunning("Sessions::Main"))
   AkelPad.Call("Sessions::Main", 2, session);

AkelPad.Exec('"%nirCmd%" killprocess "%nirCmd%"'.replace(/%nirCmd%/g, nirCmd)); //~ todo: check process command line

var cmd = '"%nirCmd%" waitprocess /%pid% exec2 show "%workDir%" "%akelExe%"';
if(!sessionAutoLoad)
   cmd += ' /Call("Sessions::Main", 1, "%session%")';
cmd = cmd
   .replace(/%nirCmd%/g, nirCmd)
   .replace(/%pid%/g, pid)
   .replace(/%workDir%/g, curDir)
   .replace(/%akelExe%/g, akelExe)
   .replace(/%session%/g, session);
AkelPad.Exec(cmd, akelDir);
AkelPad.Command(4109); // Exit

function expandEnvironmentVariables(s) {
   if(/^%a[\\\/]/.test(s))
      s = akelDir + s.substr(2);
   return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings(s);
}
function error(s) {
   AkelPad.MessageBox(
      AkelPad.GetMainWnd(),
      s,
      WScript.ScriptName,
      16 /*MB_ICONERROR*/
   );
}
function failed(func) {
   error(func + "() failed!\nError: " + oSys.Call("kernel32::GetLastError"));
}
<download | mirror | development version>
Restart AkelPad.
Dependencies:


Last edited by Infocatcher on Sat Mar 29, 2014 11:10 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Visitor7



Joined: 03 Jun 2012
Posts: 88

PostPosted: Thu Jun 14, 2012 11:19 pm    Post subject: Reply with quote

Cycling between specified menubar, toolbar, statusbar and tabbar states.

cpBarSwitch.js
Code:
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=18460#18460
// cpBarSwitch.js    ver.1.6    2012-06-23
// Cycling between specified menubar, toolbar, statusbar and tabbar states.
// Usage: Call("Scripts::Main", 1, "cpBarSwitch.js", "m s1 [s2 s3 s4 ...]")
//    m - bar`s mask, integer 1...15:
//      0x0001 (1)  -  process menubar
//      0x0010 (2)  -  process toolbar      (toolbar.dll plugin required)
//      0x0100 (4)  -  process tabbar
//      0x1000 (8)  -  process statusbar
//    s1 [s2 s3 s4 ...] - states, integer 0...31, should not be repeated:
//      0x00001 (1)  -  menubar state       (0 - off, 1 - on)
//      0x00010 (2)  -  toolbar state         (0 - off, 1 - on)
//      0x00100 (4)  -  tabbar state         (0 - off, 1 - on)
//      0x01000 (8)  -  statusbar state      (0 - off, 1 - on)
//      0x10000 (16)  - tabbar position       (0 - top, 1 - bottom)
// Examples:
//    Call("Scripts::Main", 1, "cpBarSwitch.js", "4 4 0")
//       On/Off tabbar(top).
//    Call("Scripts::Main", 1, "cpBarSwitch.js", "1 1 0")
//       On/Off menubar.
//    Call("Scripts::Main", 1, "cpBarSwitch.js", "14 14 0")
//       On/Off tabbar(top), toolbar and statusbar.
//    Call("Scripts::Main", 1, "cpBarSwitch.js", "4 4 20 0")
//       1. Turn on tabbar(top); 2. switches tabbar to bottom; 3. turn off tabbar... then starts from the beginning.
//    Call("Scripts::Main", 1, "cpBarSwitch.js", "11 1 9 10")
//       1. Turn off toolbar and statusbar, turn on menubar; 2. turn on statusbar; 3. turn on toolbar and turn off menubar... then starts from the beginning.

/////// Variables                  ///////////////////////////////
var hMainWnd = AkelPad.GetMainWnd();
var aMod = !AkelPad.IsMDI();
var bMask;
var xState = 0;
var nState;
var i;

if (hMainWnd && IsArgIntRng(0, 1, 15) && IsArgIntRng(1, 0, 31))
{
   bMask = WScript.Arguments(0);
   if (aMod)
      bMask &= ~4;   //ignore tabbar
   /////// Calculation of the current state      ///////////////////////////////
   if (bMask & 4)                           ///tabbar
   {
      var tState = AkelPad.SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 157 /*MI_TABOPTIONSMDI*/, 0);
      if (!(tState & 1))
      {                          //  if (tState & 1) TAB_VIEW_NONE
         xState |= 4;           //  if (tState & 2) TAB_VIEW_TOP
         if (tState & 4)         //  if (tState & 4) TAB_VIEW_BOTTOM
            xState |= 16;
      }
   }
   if (bMask & 8)                            ///statusbar
   {
      var sState = AkelPad.SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 142 /*MI_STATUSBAR*/, 0);
      if (sState)
         xState |= 8;
   }
   if (bMask & 2)                            ///toolbar
   {
      var ptState = AkelPad.IsPluginRunning("ToolBar::Main");
      if (ptState)
         xState |= 2;
   }
   if (bMask & 1)                           ///menubar
   {
      var pmState = AkelPad.IsPluginRunning("ContextMenu::Main");
      var hMainMenu = AkelPad.SendMessage(hMainWnd, 1222 /*AKD_GETMAININFO*/, 21 /*MI_MENUMAIN*/, 0);
      var oSys = AkelPad.SystemFunction();
      var mState = oSys.Call("User32::GetMenu", hMainWnd);
      if (mState)
         xState |= 1;
   }

   ///////Search for the next state in list         ///////////////////////////////
   for (i=1; i < WScript.Arguments.Length; ++i)
   {
      if ((WScript.Arguments(i) & (~(aMod?20:0))) == xState)
         break;
   }
   if (++i >= WScript.Arguments.Length) i=1;
   if (IsArgIntRng(i, 0, 31))
   {
      nState = (WScript.Arguments(i) & (((bMask&4) << 2) | bMask));

      ///////Set the next state               ///////////////////////////////
      if (((nState & 4) != (xState & 4)) || ((nState & 16) != (xState & 16)))     ///tabbar
      {
         if (!(nState & 4))
            AkelPad.Command(4303 /*IDM_WINDOW_TABVIEW_NONE*/);
         else if (nState & 16)
            AkelPad.Command(4302 /*IDM_WINDOW_TABVIEW_BOTTOM*/);
         else
            AkelPad.Command(4301 /*IDM_WINDOW_TABVIEW_TOP*/);
      }
      if ((nState & 8) != (xState & 8))                         ///statusbar
         AkelPad.Command(4211 /*IDM_VIEW_SHOW_STATUSBAR*/);
      if ((nState & 2) != (xState & 2))                         ///toolbar
         AkelPad.Call("ToolBar::Main");
      if ((nState & 1) != (xState & 1))                         ///menubar
      {
         if (!mState)
         {
            oSys.Call("User32::SetMenu", hMainWnd, hMainMenu);
            if (pmState)   // Menu items of contextMenu.dll does not appear when turn on the menu, restart required.
            {
               AkelPad.Call("ContextMenu::Main", 10);
               // WScript.Sleep(50); // If not restarted, try to uncomment the pause.
               AkelPad.Call("ContextMenu::Main", 10);
            }
         }
         else
            oSys.Call("User32::SetMenu", hMainWnd, 0);
      }
   }
}

function IsArgIntRng(aNum, aFrom, aTo)
{
   if (WScript.Arguments.length > aNum)
   {
      var aValue = +WScript.Arguments(aNum);
      if ((Math.floor(aValue) == aValue) && (aValue >= aFrom) && (aValue <= aTo))
         return true;
   }
   return false;
}


Last edited by Visitor7 on Mon Jul 23, 2012 5:55 am; edited 8 times in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2, 3 ... 14, 15, 16, 17, 18  Next
Page 15 of 18

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group