//// Methods list AkelPad.GetMainWnd AkelPad.GetAkelDir AkelPad.GetInstanceDll AkelPad.IsOldWindows AkelPad.IsOldRichEdit AkelPad.IsOldComctl32 AkelPad.IsAkelEdit AkelPad.IsMDI AkelPad.GetEditWnd AkelPad.GetEditFile AkelPad.GetEditCodePage AkelPad.GetEditBOM AkelPad.GetEditNewLine AkelPad.GetEditModified AkelPad.GetEditReadOnly AkelPad.SendMessage AkelPad.MessageBox AkelPad.InputBox AkelPad.GetSelStart AkelPad.GetSelEnd AkelPad.SetSel AkelPad.GetSelText AkelPad.ReplaceSel AkelPad.TextFind AkelPad.TextReplace AkelPad.GetClipboardText AkelPad.SetClipboardText AkelPad.Call AkelPad.IsPluginRunning AkelPad.OpenFile AkelPad.ReadFile AkelPad.SaveFile AkelPad.SystemFunction AkelPad.SystemFunction.AddParameter AkelPad.SystemFunction.Call AkelPad.SystemFunction.GetLastError AkelPad.MemAlloc AkelPad.MemCopy AkelPad.MemRead AkelPad.MemFree AkelPad.WindowRegisterClass AkelPad.WindowUnregisterClass AkelPad.WindowGetMessage //// Methods description AkelPad.GetMainWnd __________________ Get main window handle. GetMainWnd(); Return Value Number. Main window handle. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hMainWnd=AkelPad.GetMainWnd(); AkelPad.GetAkelDir __________________ Get AkelPad directory. GetAkelDir(); Return Value String. AkelPad directory. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var pAkelDir=AkelPad.GetAkelDir(); AkelPad.GetInstanceDll ______________________ Get DLL instance handle. GetInstanceDll(); Return Value Number. DLL instance handle. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hInstance=AkelPad.GetInstanceDll(); AkelPad.IsOldWindows ____________________ Is non-Unicode Windows. IsOldWindows(); Return Value true non-Unicode (Windows 95/98/Me) false Unicode (Windows NT/2000/XP) Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bOldWindows=AkelPad.IsOldWindows(); AkelPad.IsOldRichEdit _____________________ Is riched20.dll lower then 5.30 (v3.0). IsOldRichEdit(); Return Value true riched20.dll lower then 5.30 (v2.0) false riched20.dll not lower then 5.30 (v3.0, v4.0) Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bOldRichEdit=AkelPad.IsOldRichEdit(); AkelPad.IsOldComctl32 _____________________ Is comctl32.dll lower then 4.71. IsOldComctl32(); Return Value true comctl32.dll lower then 4.71. false comctl32.dll not lower then 4.71. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bOldComctl32=AkelPad.IsOldComctl32(); AkelPad.IsAkelEdit __________________ Is AkelEdit control used. IsAkelEdit(); Return Value true AkelEdit control used (AkelPad v4.x.x or higher). false RichEdit control used (AkelPad v3.x.x). Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bAkelEdit=AkelPad.IsAkelEdit(); AkelPad.IsMDI _____________ Is AkelPad in MDI mode. IsMDI(); Return Value true MDI mode is used. false SDI mode is used. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bMDI=AkelPad.IsMDI(); AkelPad.GetEditWnd __________________ Get active edit window handle. GetEditWnd(); Return Value Number. Active edit window handle. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hEditWnd=AkelPad.GetEditWnd(); AkelPad.GetEditFile ___________________ Get file name. GetEditFile(hHandle); Arguments hHandle Edit window handle. If zero then active edit window handle is used. Return Value String. File name. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var pEditFile=AkelPad.GetEditFile(0); AkelPad.GetEditCodePage _______________________ Get file code page. GetEditCodePage(hHandle); Arguments hHandle Edit window handle. If zero then active edit window handle is used. Return Value Number. Code page. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var nCodePage=AkelPad.GetEditCodePage(0); AkelPad.GetEditBOM __________________ Get file BOM. GetEditBOM(hHandle); Arguments hHandle Edit window handle. If zero then active edit window handle is used. Return Value true file has BOM. false file hasn't BOM. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bBOM=AkelPad.GetEditBOM(0); AkelPad.GetEditNewLine ______________________ Get file new line format. GetEditNewLine(hHandle); Arguments hHandle Edit window handle. If zero then active edit window handle is used. Return Value 1 DOS/Windows (0Dh, 0Ah) 2 Unix (0Ah) 3 Mac (0Dh) Example: var AkelPad=new ActiveXObject("AkelPad.document"); var nNewLine=AkelPad.GetEditNewLine(0); AkelPad.GetEditModified _______________________ Get file modified flag. GetEditModified(hHandle); Arguments hHandle Edit window handle. If zero then active edit window handle is used. Return Value true contents of edit control have been modified false contents of edit control haven't been modified Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bModified=AkelPad.GetEditModified(0); AkelPad.GetEditReadOnly _______________________ Get edit control's read only mode. GetEditReadOnly(hHandle); Arguments hHandle Edit window handle. If zero then active edit window handle is used. Return Value true read only mode false edit mode Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bReadOnly=AkelPad.GetEditReadOnly(0); AkelPad.SendMessage ___________________ Send message. SendMessage(hHandle, nMessage, wParam, lParam); Arguments hHandle Handle to the window whose window procedure will receive the message. nMessage Specifies the message to be sent. wParam Specifies additional message-specific information. lParam Specifies additional message-specific information. Return Value Number. Result of the message processing; it depends on the message sent. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hMainWnd=AkelPad.GetMainWnd(); AkelPad.SendMessage(hMainWnd, 273 /*WM_COMMAND*/, 4101 /*IDM_FILE_NEW*/, 0); AkelPad.MessageBox __________________ Show message. MessageBox(hHandle, pText, pCaption, nType); Arguments hHandle Handle to the owner window of the message box to be created. If this parameter is zero, the message box has no owner window. pText Message to be displayed. pCaption Dialog box title. nType Specifies the contents and behavior of the dialog box. See MSDN. Return Value Number. Return value is the button's ID pressed. See MSDN. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hMainWnd=AkelPad.GetMainWnd(); AkelPad.MessageBox(hMainWnd, "MyText", "MyCaption", 64 /*MB_ICONINFORMATION*/); AkelPad.InputBox ________________ Input dialog box. InputBox(hHandle, pCaption, pLabel, pEdit); Arguments hHandle Handle to the owner window of the message box to be created. pCaption Dialog box title. pLabel Edit box label. pEdit Edit box text. Return Value String. Edit box text. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hMainWnd=AkelPad.GetMainWnd(); var pText=AkelPad.InputBox(hMainWnd, "MyCaption", "MyLabel", "MyText"); AkelPad.GetSelStart ___________________ Get selection first char index. GetSelStart(); Return Value Number. Selection first char index. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var nSelStart=AkelPad.GetSelStart(); AkelPad.GetSelEnd _________________ Get selection last char index. GetSelEnd(); Return Value Number. Selection last char index. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var nSelEnd=AkelPad.GetSelEnd(); AkelPad.SetSel ______________ Set selection. SetSel(nSelStart, nSelEnd); Arguments nSelStart Selection first char index. nSelEnd Selection last char index. Return Value Zero. Example: var AkelPad=new ActiveXObject("AkelPad.document"); AkelPad.SetSel(0, 10); AkelPad.GetSelText __________________ Get selected text. GetSelText(); Return Value String. Selected text. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var pSelText=AkelPad.GetSelText(); AkelPad.ReplaceSel __________________ Replace selection. ReplaceSel(pText); Arguments pText Text to replace with. Return Value Zero. Example: var AkelPad=new ActiveXObject("AkelPad.document"); AkelPad.ReplaceSel("MyText"); AkelPad.TextFind ________________ Find text. TextFind(hHandle, pFindIt, nFlags); Arguments hHandle Edit window handle. pFindIt Text to find. nFlags 0x00000001 //FR_DOWN Find down 0x00000004 //FR_MATCHCASE Search is case-sensitive 0x00100000 //FR_UP Find up 0x00200000 //FR_BEGINNING Search from beginning (usage: FR_DOWN|FR_BEGINNING) 0x00400000 //FR_SELECTION Search in selection (usage: FR_DOWN|FR_SELECTION) 0x00800000 //FR_ESCAPESEQ Search with escape sequences 0x01000000 //FR_ALLFILES Search in all openned MDI documents (not implemented) Return Value Number. Character position of the next match. If there are no more matches, the return value is –1. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hEditWnd=AkelPad.GetEditWnd(); AkelPad.TextFind(hEditWnd, "MySearchString", 0x00000001|0x00200000); AkelPad.TextReplace ___________________ Find and replace text. TextReplace(hHandle, pFindIt, pReplaceWith, nFlags, bAll); Arguments hHandle Edit window handle. pFindIt Text to find. pReplaceWith Text to replace with. nFlags 0x00000001 //FR_DOWN Find down 0x00000004 //FR_MATCHCASE Search is case-sensitive 0x00100000 //FR_UP Find up 0x00200000 //FR_BEGINNING Search from beginning (usage: FR_DOWN|FR_BEGINNING) 0x00400000 //FR_SELECTION Search in selection (usage: FR_DOWN|FR_SELECTION) 0x00800000 //FR_ESCAPESEQ Search with escape sequences 0x01000000 //FR_ALLFILES Search in all openned MDI documents (not implemented) bAll true replace all. false replace single. Return Value Number. Character position of the next match. If there are no more matches, the return value is –1. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hEditWnd=AkelPad.GetEditWnd(); AkelPad.TextReplace(hEditWnd, "MySearchString", "MyReplaceText", 0x00000001|0x00200000, true); AkelPad.GetClipboardText ________________________ Get clipboard text. GetClipboardText([bAnsi]); Arguments bAnsi true retrieve ansi text. false retrieve unicode text (default). Return Value String. Clipboard text. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var pClipboardText=AkelPad.GetClipboardText(); AkelPad.SetClipboardText ________________________ Set clipboard text. SetClipboardText(pText); Arguments pText Text to set. Return Value Zero. Example: var AkelPad=new ActiveXObject("AkelPad.document"); AkelPad.SetClipboardText("MyText"); AkelPad.Call ____________ Call AkelPad plugin. Call(pFunction[, ...]); Arguments pFunction Function to call. ... Function parameters. Return Value 0 //EDL_FAILED Operation failed 1 //EDL_UNLOADED Plugin unloaded 2 //EDL_NONUNLOADED_ACTIVE Plugin in memory and active 3 //EDL_NONUNLOADED_NONACTIVE Plugin in memory and non-active 4 //EDL_NONUNLOADED Plugin in memory Example: var AkelPad=new ActiveXObject("AkelPad.document"); var nResult=AkelPad.Call("Scripts::Main", 1, "InsertDate.js", "", 0); AkelPad.IsPluginRunning _______________________ Is AkelPad plugin running. IsPluginRunning(pFunction); Arguments pFunction Function to check. Return Value true plugin is running. false plugin isn't running. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bRunning=AkelPad.IsPluginRunning("HighLight::Main"); AkelPad.OpenFile ________________ Open file. OpenFile(pFile[, nFlags][, nCodePage][, bBOM]); Arguments pFile File to open. nFlags 0x1 //OD_ADT_BINARY_ERROR Check if file is binary 0x2 //OD_ADT_REG_CODEPAGE If last open code page found in registry, then it will be // used with OD_ADT_DETECT_BOM flag, if not found, then next flags // will be used OD_ADT_DETECT_CODEPAGE|OD_ADT_DETECT_BOM 0x4 //OD_ADT_DETECT_CODEPAGE Detect code page 0x8 //OD_ADT_DETECT_BOM Detect BOM mark //Default is 0xD (OD_ADT_BINARY_ERROR|OD_ADT_DETECT_CODEPAGE|OD_ADT_DETECT_BOM) nCodePage File code page, ignored if (nFlags & OD_ADT_DETECT_CODEPAGE) bBOM File BOM, ignored if (nFlags & OD_ADT_DETECT_BOM) Return Value 0 //EOD_SUCCESS Success -1 //EOD_ADT_OPEN Autodetect codepage, can't open file -2 //EOD_ADT_ALLOC Autodetect codepage, can't allocate buffer -3 //EOD_ADT_READ Autodetect codepage, read file error -4 //EOD_ADT_BINARY Autodetect codepage, file is binary -5 //EOD_OPEN Can't open file -6 //EOD_CANCEL User press cancel -7 //EOD_WINDOW_EXIST File already opened -8 //EOD_CODEPAGE_ERROR Code page isn't implemented -9 //EOD_STOP Stopped from AKDN_OPENDOCUMENT_START -10 //EOD_STREAMIN Error in EM_STREAMIN Example: var AkelPad=new ActiveXObject("AkelPad.document"); var bResult=AkelPad.OpenFile("C:\\MyFile.txt"); AkelPad.ReadFile ________________ Read contents of a file. ReadFile(pFile[, nFlags][, nCodePage][, bBOM]); Arguments pFile File to read. nFlags 0x1 //OD_ADT_BINARY_ERROR Check if file is binary 0x2 //OD_ADT_REG_CODEPAGE If last open code page found in registry, then it will be // used with OD_ADT_DETECT_BOM flag, if not found, then next flags // will be used OD_ADT_DETECT_CODEPAGE|OD_ADT_DETECT_BOM 0x4 //OD_ADT_DETECT_CODEPAGE Detect code page 0x8 //OD_ADT_DETECT_BOM Detect BOM mark //Default is 0xD (OD_ADT_BINARY_ERROR|OD_ADT_DETECT_CODEPAGE|OD_ADT_DETECT_BOM) nCodePage File code page, ignored if (nFlags & OD_ADT_DETECT_CODEPAGE) bBOM File BOM, ignored if (nFlags & OD_ADT_DETECT_BOM) Return Value String. Contents of a file. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var pText=AkelPad.ReadFile("C:\\MyFile.txt"); AkelPad.SaveFile ________________ Save document. SaveFile(hHandle, pFile, nCodePage, bBOM[, nFlags]); Arguments hHandle Edit window handle. pFile File name to save to. nCodePage File code page. bBOM File BOM. nFlags 0x1 //SD_UPDATE Update file info 0x2 //SD_SELECTION Save only selection //Default is 0x1 (SD_UPDATE) Return Value 0 //ESD_SUCCESS Success -1 //ESD_OPEN Can't open file -2 //ESD_WRITE Can't write to file -3 //ESD_READONLY File has read-only attribute -4 //ESD_CODEPAGE_ERROR Code page isn't implemented -5 //ESD_STOP Stopped from AKDN_SAVEDOCUMENT_START -6 //ESD_STREAMOUT Error in EM_STREAMOUT Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hEditWnd=AkelPad.GetEditWnd(); var nCodePage=AkelPad.GetEditCodePage(hEditWnd); var bBOM=AkelPad.GetEditBOM(hEditWnd); var nResult=AkelPad.SaveFile(hEditWnd, "C:\\MyFile.txt", nCodePage, bBOM); AkelPad.SystemFunction ______________________ Create system function object. SystemFunction(); Return Value Object. System function object. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var oFunction=AkelPad.SystemFunction(); AkelPad.SystemFunction.AddParameter ___________________________________ Add function parameter. AddParameter(vParameter); Arguments vParameter Function parameter. Return Value Zero. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var oFunction=AkelPad.SystemFunction(); oFunction.AddParameter(1000); oFunction.Call("kernel32::Sleep"); AkelPad.SystemFunction.Call ___________________________ Call system function. Call(pDllFunction); Arguments pDllFunction Function name in format "Dll::Function". Return Value Number. Call result. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var oFunction=AkelPad.SystemFunction(); var nAnsiCodepage=oFunction.Call("kernel32::GetACP"); AkelPad.SystemFunction.GetLastError ___________________________________ Get call function last error. GetLastError(); Return Value Number. Call function last error. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var oFunction=AkelPad.SystemFunction(); var hMainWnd=AkelPad.GetMainWnd(); var nError; oFunction.AddParameter(hMainWnd); oFunction.AddParameter(6 /*SW_MINIMIZE*/); oFunction.Call("user32::ShowWindow"); nError=oFunction.GetLastError(); AkelPad.MemAlloc ________________ Allocate memory. MemAlloc(nSize[, bExeMemory]); Arguments nSize Size in bytes to allocate. bExeMemory true //Exe memory false //Dll memory (default) Return Value Number. Pointer to a buffer. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hMainWnd=AkelPad.GetMainWnd(); var oFunction=AkelPad.SystemFunction(); var pMessage="MyMessage"; var pCaption="MyCaption"; var lpMessageBuffer; var lpCaptionBuffer; if (lpMessageBuffer=AkelPad.MemAlloc(256)) { AkelPad.MemCopy(lpMessageBuffer, pMessage.substr(0, 255), 0 /*DT_ANSI*/); if (lpCaptionBuffer=AkelPad.MemAlloc(256)) { AkelPad.MemCopy(lpCaptionBuffer, pCaption.substr(0, 255), 0 /*DT_ANSI*/); oFunction.AddParameter(hMainWnd); oFunction.AddParameter(lpMessageBuffer); oFunction.AddParameter(lpCaptionBuffer); oFunction.AddParameter(64 /*MB_ICONINFORMATION*/); oFunction.Call("user32::MessageBoxA"); AkelPad.MemFree(lpCaptionBuffer); } AkelPad.MemFree(lpMessageBuffer); } AkelPad.MemCopy _______________ Copy memory. MemCopy(nPointer, vData, nType[, bExeMemory]); Arguments nPointer Pointer to a buffer. vData Data to copy. nType Type of the vData parameter: 0 //DT_ANSI Copy Ansi string to memory 1 //DT_UNICODE Copy Unicode string to memory 2 //DT_WORD Copy WORD number to memory 3 //DT_DWORD Copy DWORD number to memory bExeMemory true //Exe memory false //Dll memory (default) Return Value Number. Bytes copied. Example: See MemAlloc example. AkelPad.MemRead _______________ Read memory. MemRead(nPointer, vData, nType[, bExeMemory]); Arguments nPointer Pointer to a buffer. nType 0 //DT_ANSI Read Ansi string from memory 1 //DT_UNICODE Read Unicode string from memory 2 //DT_WORD Read WORD number from memory 3 //DT_DWORD Read DWORD number from memory bExeMemory true //Exe memory false //Dll memory (default) Return Value Number. Data string ot number. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var oFunction=AkelPad.SystemFunction(); var lpDirBuffer; var pWinDir; if (lpDirBuffer=AkelPad.MemAlloc(256)) { oFunction.AddParameter(lpDirBuffer); oFunction.AddParameter(256); oFunction.Call("kernel32::GetWindowsDirectoryA"); pWinDir=AkelPad.MemRead(lpDirBuffer, 0 /*DT_ANSI*/); AkelPad.MemFree(lpDirBuffer); } AkelPad.MemFree _______________ Free memory. MemFree(nPointer[, bExeMemory]); Arguments nPointer Pointer to a buffer. bExeMemory true //Exe memory false //Dll memory (default) Return Value Zero. Example: See MemAlloc example. AkelPad.WindowRegisterClass ___________________________ Register window class. WindowRegisterClass(pClassName); Arguments pClassName Class name to register. Return Value Number. Class atom that uniquely identifies the class being registered. Example: var AkelPad=new ActiveXObject("AkelPad.document"); var hMainWnd=AkelPad.GetMainWnd(); var oFunction=AkelPad.SystemFunction(); var hInstanceDLL=AkelPad.GetInstanceDll(); var hWndDialog; var lpBuffer; if (hMainWnd) { if (AkelPad.WindowRegisterClass("NewClass")) { if (lpBuffer=AkelPad.MemAlloc(256)) { //Create dialog AkelPad.MemCopy(lpBuffer, "NewClass", 0 /*DT_ANSI*/); oFunction.AddParameter(0); oFunction.AddParameter(lpBuffer); oFunction.AddParameter(0); oFunction.AddParameter(0x90CA0000 /*WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX*/); oFunction.AddParameter(0); oFunction.AddParameter(0); oFunction.AddParameter(351); oFunction.AddParameter(179); oFunction.AddParameter(hMainWnd); oFunction.AddParameter(0); oFunction.AddParameter(hInstanceDLL); oFunction.AddParameter(DialogCallbackA); //Script function callback. To use it class must be registered by WindowRegisterClass. hWndDialog=oFunction.Call("user32::CreateWindowExA"); if (hWndDialog) { //Disable main window, to make dialog modal oFunction.AddParameter(hMainWnd); oFunction.AddParameter(false); oFunction.Call("user32::EnableWindow"); //Message loop AkelPad.WindowGetMessage(); } AkelPad.MemFree(lpBuffer); } AkelPad.WindowUnregisterClass("NewClass"); } } function DialogCallbackA(hWnd, uMsg, wParam, lParam) { if (uMsg == 1 /*WM_CREATE*/) { } else if (uMsg == 256 /*WM_KEYDOWN*/) { if (wParam == 27 /*VK_ESCAPE*/) { //Escape key pushes Cancel button oFunction.AddParameter(hWndDialog); oFunction.AddParameter(273 /*WM_COMMAND*/); oFunction.AddParameter(2 /*IDCANCEL*/); oFunction.AddParameter(0); oFunction.Call("user32::PostMessageA"); } } else if (uMsg == 273 /*WM_COMMAND*/) { if ((wParam & 0xffff) == 2 /*IDCANCEL*/) { oFunction.AddParameter(hWndDialog); oFunction.AddParameter(16 /*WM_CLOSE*/); oFunction.AddParameter(0); oFunction.AddParameter(0); oFunction.Call("user32::PostMessageA"); } } else if (uMsg == 16 /*WM_CLOSE*/) { //Enable main window oFunction.AddParameter(hMainWnd); oFunction.AddParameter(true); oFunction.Call("user32::EnableWindow"); //Destroy dialog oFunction.AddParameter(hWnd); oFunction.Call("user32::DestroyWindow"); } else if (uMsg == 2 /*WM_DESTROY*/) { //Exit message loop oFunction.AddParameter(0); oFunction.Call("user32::PostQuitMessage"); } return 0; } AkelPad.WindowUnregisterClass _____________________________ Unregister window class. WindowUnregisterClass(pClassName); Arguments pClassName Class name to unregister. Return Value true success false failed Example: See WindowRegisterClass example. AkelPad.WindowGetMessage ________________________ Process thread messages (message loop). WindowGetMessage(); Return Value Zero. Example: See WindowRegisterClass example.