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 discussion (2)
Goto page Previous  1, 2, 3 ... 44, 45, 46 ... 94, 95, 96  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    AkelPad Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Andrey_A_A



Joined: 03 Jun 2010
Posts: 579
Location: Сочи, Хоста

PostPosted: Mon Aug 06, 2012 5:11 pm    Post subject: Reply with quote

Я изменяю скриптом AkelPad.ini
Подскажите можно тут же подгрузить настройки
Back to top
View user's profile Send private message Send e-mail Visit poster's website
FeyFre



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

PostPosted: Mon Aug 06, 2012 5:53 pm    Post subject: Reply with quote

Andrey_A_A, низя.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Andrey_A_A



Joined: 03 Jun 2010
Posts: 579
Location: Сочи, Хоста

PostPosted: Mon Aug 06, 2012 8:01 pm    Post subject: Reply with quote

FeyFre wrote:
Andrey_A_A, низя.


А локально, к примеру есть задача быстро подгружать несколько наборов левых и правых символов для правильности отображения Url - секции UrlLeftDelimiters и UrlRightDelimiters

или совсем низя)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
FeyFre



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

PostPosted: Mon Aug 06, 2012 8:21 pm    Post subject: Reply with quote

Andrey_A_A, AkelPad.SendMessage + AKD_SETFRAMEINFO + FIS_URLLEFTDELIMITERS/FIS_URLRIGHTDELIMITERS. См. AkelDll.h
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Mon Aug 06, 2012 8:56 pm    Post subject: Reply with quote

Andrey_A_A
See also:
  in AkelEdit.h:
    AEM_GETURLLEFTDELIMITERS
    AEM_SETURLLEFTDELIMITERS
  in AkelDLL.h:
    AKD_GETFRAMEINFO
    FI_URLLEFTDELIMITERS
Script example: ResetUrlDelimiters.js
Back to top
View user's profile Send private message
DV



Joined: 16 Nov 2006
Posts: 851
Location: Kyiv, Ukraine

PostPosted: Tue Aug 07, 2012 1:41 pm    Post subject: Reply with quote

Упаковка текущего файла в zip-архив средствами JScript...
ToDo: использование классов?
ZipCurrentFile.js
Code:
var isFileSaved;
var sCurrentFilePath;
var sZipFilePath;

isFileSaved = false;
sCurrentFilePath = AkelPad.GetEditFile(0);
if (sCurrentFilePath)
{
  if (!AkelPad.GetEditModified(0))
    isFileSaved = true;
}
if (!isFileSaved)
{
  WScript.Echo("File is not saved. Please save the file first!");
  WScript.Quit();
}

sZipFilePath = getZipFilePath();
if (!zip_create(sZipFilePath))
{
  WScript.Echo("Failed to create the archive :(");
  WScript.Quit();
}
if (!zip_add_file(sZipFilePath, sCurrentFilePath))
{
  WScript.Echo("Failed to add the file to the archive :(");
  WScript.Quit();
}
WScript.Echo("Archive created!\n" + sZipFilePath);

function getZipFilePath()
{
  var sZipFileDir = getFileDir(sCurrentFilePath);
  var sZipFileName = getFileName(sCurrentFilePath);
  var s = sZipFileDir + "\\" + sZipFileName + ".zip";
  return s;
}

function zip_create(sZipFilePath)
{
  var isOK = false;

  // Creating an empty .zip archive
  try
  {
    var oFileSystem = new ActiveXObject("Scripting.FileSystemObject");
    var oZipFile = oFileSystem.OpenTextFile(sZipFilePath, 2, true);
    var data = String.fromCharCode(80,75,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
    oZipFile.Write(data);
    oZipFile.Close();
    isOK = true;
  }
  catch (err)
  {
    // ...
  }

  return isOK;
}

function zip_add_file(sZipFilePath, sFilePath)
{
  var isOK = false;

  // Packing the data
  try
  {
    var oShell = new ActiveXObject("Shell.Application");
    var oDstFolder = oShell.NameSpace(sZipFilePath);
    oDstFolder.CopyHere(sFilePath, 16);
    //WScript.Sleep(1000);
    isOK = true;
  }
  catch (err)
  {
    // ...
  }

  return isOK;
}

function zip_add_folder(sZipFilePath, sFolderPath)
{
  var isOK = false;

  // Packing the data
  try
  {
    var oShell = new ActiveXObject("Shell.Application");
    var oDstFolder = oShell.NameSpace(sZipFilePath);
    var oSrcFolder = oShell.NameSpace(sFolderPath);
    var oFolderItems = oSrcFolder.Items();
    oDstFolder.CopyHere(oFolderItems.Item(), 16);
    //WScript.Sleep(1000);
    isOK = true;
  }
  catch (err)
  {
    // ...
  }

  return isOK;
}

function getFileExt(filePathName) // file extension w/o leading '.'
{
  var n = filePathName.lastIndexOf(".");
  return (n >= 0) ? filePathName.substr(n + 1) : "";
}

function getFileName(filePathName) // file name w/o extension
{
  var n2 = filePathName.lastIndexOf(".");
  var n1 = filePathName.lastIndexOf("\\");
  var nn = filePathName.lastIndexOf("/");
  if (nn > n1)  n1 = nn;
  var s = "";
  if (n1 < 0 && n2 < 0)
    s = filePathName;
  else if (n1 < 0)
    s = filePathName.substr(0, n2);
  else if (n2 < 0)
    s = filePathName.substr(n1 + 1);
  else if (n2 > n1)
    s = filePathName.substr(n1 + 1, n2 - n1 - 1);
  return s;
}

function getFileDir(filePathName) // file directory w/o trailing '\'
{
  var n = filePathName.lastIndexOf("\\");
  var nn = filePathName.lastIndexOf("/");
  if (nn > n)  n = nn;
  return (n >= 0) ? filePathName.substr(0, n) : filePathName;
}
Back to top
View user's profile Send private message
VladSh



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

PostPosted: Wed Aug 08, 2012 8:53 am    Post subject: Reply with quote

DV
Не знал, что такое возможно. Здорово!
Если бы вывести список всех открытых файлов, поставить галки и запаковать выбранные, то вообще был бы яд! Very Happy
А ещё лучше в аргументах передавать скрипту: текущий или выбор.
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Thu Aug 09, 2012 8:24 pm    Post subject: Reply with quote

How to create Richedit control in ActiveX?
In the following script is not working:
RicheditInActiveX.js
Code:
GetAkelPadObject();

var oSys         = AkelPad.SystemFunction();
var hMainWnd     = AkelPad.GetMainWnd();
var hInstanceDLL = AkelPad.GetInstanceDll();
var sClassName   = "AkelPad::Scripts::" + WScript.ScriptName + "::" + hInstanceDLL;
var hRichEdit;
var hEdit;
var hButton;

AkelPad.WindowRegisterClass(sClassName);

oSys.Call("user32::CreateWindowExW",
          0,               //dwExStyle
          sClassName,      //lpClassName
          "Richedit test", //lpWindowName
          0x90CA0000,      //dwStyle=WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX
          300,             //x
          200,             //y
          300,             //nWidth
          300,             //nHeight
          hMainWnd,        //hWndParent
          0,               //ID
          hInstanceDLL,    //hInstance
          DialogCallback); //Script function callback. To use it class must be registered by WindowRegisterClass.

AkelPad.WindowGetMessage();
AkelPad.WindowUnregisterClass(sClassName);

function DialogCallback(hWnd, uMsg, wParam, lParam)
{
  if (uMsg == 1) //WM_CREATE
  {
    hRichEdit =
      oSys.Call("user32::CreateWindowExW",
                0,             //dwExStyle
                "RichEdit20W", //lpClassName
                0,             //lpWindowName
                0x50311104,    //dwStyle=WS_VISIBLE|WS_CHILD|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP|ES_WANTRETURN|ES_NOHIDESEL|ES_MULTILINE
                10,            //x
                10,            //y
                130,           //nWidth
                200,           //nHeight
                hWnd,          //hWndParent
                0,             //ID
                hInstanceDLL,  //hInstance
                0);            //lpParam
    oSys.Call("user32::SetWindowTextW", hRichEdit, "Rich Edit");

    if (hRichEdit)
      WScript.Echo("Richedit was created");
    else
      WScript.Echo("Richedit was not created");

    hEdit =
      oSys.Call("user32::CreateWindowExW",
                0,             //dwExStyle
                "EDIT",        //lpClassName
                0,             //lpWindowName
                0x50311104,    //dwStyle=WS_VISIBLE|WS_CHILD|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP|ES_WANTRETURN|ES_NOHIDESEL|ES_MULTILINE
                160,           //x
                10,            //y
                130,           //nWidth
                200,           //nHeight
                hWnd,          //hWndParent
                0,             //ID
                hInstanceDLL,  //hInstance
                0);            //lpParam
    oSys.Call("user32::SetWindowTextW", hEdit, "Edit");

    hButton =
      oSys.Call("user32::CreateWindowExW",
                0,            //dwExStyle
                "BUTTON",     //lpClassName
                "Close",      //lpWindowName
                0x50010000,   //dwStyle
                100,          //x
                230,          //y
                100,          //nWidth
                25,           //nHeight
                hWnd,         //hWndParent
                0,            //ID
                hInstanceDLL, //hInstance
                0);           //lpParam
  }
  else if (uMsg == 7) //WM_SETFOCUS
    oSys.Call("user32::SetFocus", hButton);
  else if (uMsg == 256) //WM_KEYDOWN
  {
    if (wParam == 27) //VK_ESCAPE
      oSys.Call("user32::PostMessageW", hWnd, 16 /*WM_CLOSE*/, 0, 0);
  }
  else if (uMsg == 273) //WM_COMMAND
  {
    if (lParam == hButton)
      oSys.Call("user32::PostMessageW", hWnd, 16 /*WM_CLOSE*/, 0, 0);
  }
  else if (uMsg == 16) //WM_CLOSE
    oSys.Call("user32::DestroyWindow", hWnd);
  else if (uMsg == 2) //WM_DESTROY
    oSys.Call("user32::PostQuitMessage", 0);

  return 0;
}

function GetAkelPadObject()
{
  if (typeof AkelPad == "undefined")
  {
    var oError;

    try
    {
      AkelPad = new ActiveXObject("AkelPad.Document");
      _TCHAR  = AkelPad.Constants._TCHAR;
      _TSTR   = AkelPad.Constants._TSTR;
      _TSIZE  = AkelPad.Constants._TSIZE;
    }
    catch (oError)
    {
      WScript.Echo("You need register Scripts.dll");
      WScript.Quit();
    }
  }
}
Back to top
View user's profile Send private message
FeyFre



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

PostPosted: Thu Aug 09, 2012 11:48 pm    Post subject: Reply with quote

KDJ
From About Rich Edit Controls on MSDN
Quote:
Versions of Rich Edit

The original specification for rich edit controls is Microsoft Rich Edit 1.0; the current specification is Microsoft Rich Edit 4.1. Each version of rich edit is a superset of the preceding one, except that only Asian builds of Microsoft Rich Edit 1.0 have a vertical text option. Before creating a rich edit control, you should call the LoadLibrary function to verify which version of Microsoft Rich Edit is installed.
And there is an table of versions of RichEdit functionality.
Code:
Rich Edit version  DLL               Window Class
1.0                Riched32.dll      RICHEDIT_CLASS
2.0                Riched20.dll      RICHEDIT_CLASS
3.0                Riched20.dll      RICHEDIT_CLASS
4.1                Msftedit.dll      MSFTEDIT_CLASS
Where:
RICHEDIT_CLASS for v1.0 is "RICHEDIT" (only ANSI version)
RICHEDIT_CLASS for v2.0 & v3.0 is "RichEdit20" +"A"/"W"
MSFTEDIT_CLASS for v4.1 is "RICHEDIT50W" (only UCS2 version)
(This constants are define in Richedit.h header file in Platform SDK)
So solution for you is probably:
Insert this snippet before first reference to RichEdit control(on the very beginning of script is not bad choice):
Code:
richdll = oSys.Call("kernel32::LoadLibrary"+_TCHAR,"Riched20.dll");
Insert this snippet when You will no need RichEdit any more(after destroying all RichEdit windows You have created)
Code:
oSys.Call("kernel32::FreeLibrary", richdll);

NB: It is essential You not to forget about this last snippet especially when script execution can be terminated, in order to prevent resource leak.(Since module was manually loaded it must be manually unloaded).

PS: By the way, You completely forgot about error checking facility which can explain most of "Why this does not works?":
Code:
if(!oSys.Call("user32::CreateWindowEx"+_TCHAR,...))
{
    WScript.Echo(oSys.GetLastError());
}
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Infocatcher



Joined: 06 Aug 2007
Posts: 1629

PostPosted: Sat Aug 11, 2012 3:01 pm    Post subject: Reply with quote

jsBeautifier.js
Released test version.
Updated: Remove some unneeded get_next_token args (#139)
Added Russian localization for some messages.
Back to top
View user's profile Send private message Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Sat Aug 11, 2012 5:00 pm    Post subject: Reply with quote

FeyFre
Thank you very much for your extensive explanation about RichEdit. Now I understand almost everything.
AkelPad does not use Riched20.dll library.
1. To create AkelEdit control in AkelPad, you can use the class name AkelEditA/W or RichEdit20A/W.
2. To create original RichEdit control in AkelPad, you must load Riched32.dll (Msftedit.dll) library and create a window with class name RICHEDIT (RICHEDIT50W).
3. To create RichEdit in ActiveX, you must load Riched32.dll (Riched20.dll, Msftedit.dll) and create a window with class name RICHEDIT (RichEdit20A/W, RICHEDIT50W).
4. Question, how to create AkelEdit control in ActiveX?
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Fri Aug 17, 2012 3:23 pm    Post subject: Reply with quote

Instructor
Is it possible to use AkelEdit control in ActiveX?
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5399

PostPosted: Fri Aug 17, 2012 4:11 pm    Post subject: Reply with quote

KDJ
Yes, if you compile AkelEdit.dll from sources and load library as you did with Riched20.dll.
Back to top
View user's profile Send private message Send e-mail
FeyFre



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

PostPosted: Fri Aug 17, 2012 7:05 pm    Post subject: Reply with quote

Oh. Now I understood what KDJ means by "In ActiveX". It does not equals to my(probably more canonical) definition of ActiveX.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Sat Aug 18, 2012 12:56 pm    Post subject: Reply with quote

Instructor wrote:
Yes, if you compile AkelEdit.dll from sources and load library as you did with Riched20.dll.

I have no means to compile AkelEdit source.
Can you compile AkelEdit and put AkelEdit.dll on download page (or put it in Scripts.zip)?.
It will then be available to everyone.
Thank you very much.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    AkelPad Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2, 3 ... 44, 45, 46 ... 94, 95, 96  Next
Page 45 of 96

 
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