Scripts discussion (2)

Discuss and announce AkelPad plugins
Locked
  • Author
  • Message
KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

SendData.js
Fixed minor bugs.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

File&Stream_functions.js
Rename script:
FileStreams_functions.js -> File&Stream_functions.js

Add: NTFS streams for directories

Rename functions:
IsSupportFileStreams() -> IsSupportStreams()
IsFileStreamExists() -> IsStreamExists()
CreateFileStream() -> CreateFile()
DeleteFileStream() -> DeleteFile()
WriteFileStream() -> WriteStream()
EnumFileStreams() -> EnumStreams()

Add functions:
GetFileAttr()
IsDriveExists()
IsDirExists()
IsFileExists()
CopyFile()
RenameFile()

Offline
Posts: 2248
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

KDJ
FileStreams_functions.js -> File&Stream_functions.js
This is really bad idea. In most case shell(as much as user) threat & as special symbol(yes, in most cases they handle it as part of filename correctly too), but there can be unpredicted consequences in some software.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

FeyFre
What would be the negative consequences of using an ampersand in the filename?

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

OK
I renamed again:
File&Stream_functions.js -> FileAndStream_functions.js

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »



KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

FileAndStream.js
Added:
Shift+F5 - copy in one panel,
Left - go to parent dir,
Right - go to sub dir,
Ctrl+\ - go to main dir,
buttons: "\", "..", "<-", "->",
change drive after pressing char key on drives list.

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

Post by Instructor »

KDJ
RE: FileAndStream.js

Speed optimizations:
1.

Code: Select all

AkelPad.WindowSubClass(aWnd[i][HWND], ListCallback);
->

Code: Select all

AkelPad.WindowSubClass(aWnd[i][HWND], ListCallback, 0x87 /*WM_GETDLGCODE*/, 257 /*WM_KEYUP*/);
2. Use SetWndFontAndText with filled second parameter only in WM_CREATE.

Code: Select all

function SetWndFontAndText(hWnd, hFont, sText)
{
  AkelPad.SendMessage(hWnd, 48 /*WM_SETFONT*/, hFont, true);
  oSys.Call("user32::SetWindowText" + _TCHAR, hWnd, sText);
}
->

Code: Select all

function SetWndFontAndText(hWnd, hFont, sText)
{
  if (hFont) AkelPad.SendMessage(hWnd, 48 /*WM_SETFONT*/, hFont, 1);
  oSys.Call("user32::SetWindowText" + _TCHAR, hWnd, sText);
}
Call SetWndFontAndText outside of WM_CREATE with zero in second parameter or simply use

Code: Select all

oSys.Call("user32::SetWindowText" + _TCHAR, hWnd, sText);
After this - "File and Stream" dialog almost not flickers when became to foreground on my system.

Offline
Posts: 3243
Joined: Wed Nov 29, 2006 1:19 pm
Location: Киев, Русь
Contact:

Post by VladSh »

Изменены:
TranslateWithGoogleAPI.js - если перевод не выполнен (слово было неверно написано, поэтому возвращается тот же текст), то выдаётся сообщение, что перевод отсутствует.

CommonFunctions.js - добавлена функция получения расширения по применённой к файлу теме (по коду Instructor'а), это нужно было для усовершенстования нижеперечисленных скриптов.
OpenCoderParamsFile.js;
SaveAs.js.


Добавлено:
1. Ещё раз изменён CommonFunctions.js, - пофиксена ситуация, когда расширение определено, но отсутствует в списке-файле FileDialogExtentions.param, - выдаём его в имени файла, чтобы и в таком случае можно было сохранить его с правильным расширением.

2. Откорректирован FileDialogExtentions.param, - из HTML-файлов вынесены расширения для php-файлов в отдельную строку, т.к. они сохранялись как html.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

FileAndStream.js
Corrected according to the recommendations of Instructor.

Added:
Ctrl+Enter - run AkelPad script,
Shift+Enter - run AkelPad script with arguments.

Offline
Posts: 3243
Joined: Wed Nov 29, 2006 1:19 pm
Location: Киев, Русь
Contact:

Post by VladSh »

Изменён CommentsExt.js, - добавлена установка комментариев для coder- и spck-файлов.


Добавлено:
Instructor
Вы можете "разбить" функционал ChmKeyword.js на 2 части: "определение, есть ли в chm'нике вхождение" и "открытие вхождения"? Просто в этом же скрипте выделить в 2 функции?
Я хотел в своём скрипте сначала узнать, есть ли вхождение в chm, тогда открывать Вашим скриптом, а если нет, то открывать в документации по скрипту с помощью OpenScriptsHelp.js. И посадить на Ctrl+F1, как в IDE'хах.


Добавлено-2:
Откорректирован CodeFoldSwitcher.js, - исправлен баг "мигания" окошка фолдинга при запуске "Область навигации с окном" (оно скрывалось) после выгрузки проги с открытым окошком фолдинга, загрузке снова и выполнении вышеуказанного варианта запуска скрипта.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

I need to display file or directory properties dialog box.
I tried to do this by using ShellExecuteEx function.
But this function generates error ERROR_ACCESS_DENIED.
Can anyone help me solve the problem?

Code: Select all

FileProperties("C:\\WINDOWS", AkelPad.GetMainWnd());

function FileProperties(sFile, hWnd)
{
  var oSys      = AkelPad.SystemFunction();
  var sVerb     = "properties";
  var nInfoSize = 16 * 4;
  var lpInfo    = AkelPad.MemAlloc(nInfoSize); //SHELLEXECUTEINFO
  var lpVerb    = AkelPad.MemAlloc((sVerb.length + 1) * _TSIZE);
  var lpFile    = AkelPad.MemAlloc((sFile.length + 1) * _TSIZE);

  AkelPad.MemCopy(lpVerb, sVerb, _TSTR);
  AkelPad.MemCopy(lpFile, sFile, _TSTR);

  AkelPad.MemCopy(lpInfo, nInfoSize, 3 /*DT_DWORD*/); //cbSize
  AkelPad.MemCopy(lpInfo + 4, 0x0000000C /*SEE_MASK_INVOKEIDLIST*/, 3 /*DT_DWORD*/); //fMask
  if (hWnd)
    AkelPad.MemCopy(lpInfo + 8, hWnd, 3 /*DT_DWORD*/); //hwnd
  AkelPad.MemCopy(lpInfo + 12, lpVerb, 3 /*DT_DWORD*/); //lpVerb
  AkelPad.MemCopy(lpInfo + 16, lpFile, 3 /*DT_DWORD*/); //lpFile
  AkelPad.MemCopy(lpInfo + 28, 5 /*SW_SHOW*/, 3 /*DT_DWORD*/); //nShow

  if (! oSys.Call("Shell32::ShellExecuteEx" + _TCHAR, lpInfo))
    AkelPad.MessageBox(hWnd, "hInstApp: " + AkelPad.MemRead(lpInfo + 32, 3 /*DT_DWORD*/) + "\nLastError: " + oSys.GetLastError(), "Error", 0x00000030 /*MB_ICONWARNING*/);

  AkelPad.MemFree(lpInfo);
  AkelPad.MemFree(lpVerb);
  AkelPad.MemFree(lpFile);
}

//typedef struct _SHELLEXECUTEINFO {
//  DWORD     cbSize;
//  ULONG     fMask;
//  HWND      hwnd;
//  LPCTSTR   lpVerb;
//  LPCTSTR   lpFile;
//  LPCTSTR   lpParameters;
//  LPCTSTR   lpDirectory;
//  int       nShow;
//  HINSTANCE hInstApp;
//  LPVOID    lpIDList;
//  LPCTSTR   lpClass;
//  HKEY      hkeyClass;
//  DWORD     dwHotKey;
//  union {
//    HANDLE hIcon;
//    HANDLE hMonitor;
//  } DUMMYUNIONNAME;
//  HANDLE    hProcess;
//} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;

Offline
Posts: 2248
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

KDJ, your mistake is

Code: Select all

var nInfoSize = 16 * 4;
it should be

Code: Select all

var nInfoSize = 15 * 4;
Change it and it will work.
union keyword means enclosed into {} declarations will be located in the same memory location, and total size of whole union will be equal size of largest declaration(not sum).

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

FeyFre
Thank you very much. As always, you are reliable.
Locked