Scripts plugin

Discuss and announce AkelPad plugins
  • Author
  • Message
Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

Добавлено: константы vbTCHAR, vbTSTR, vbTSIZE, vbX64 для использования в VBScript.

Added: constants vbTCHAR, vbTSTR, vbTSIZE, vbX64 for using in VBScript.


Scripts plugin v12.5

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

Post by KDJ »

Instructor
I have a script that uses AkelEdit control.
When I run this script from command line (as ActiveX), the following metods are available:
AkelPad.SetEditWnd(),
AkelPad.GetSelStart(),
AkelPad.GetSelEnd(),
AkelPad.SetSel(),
AkelPad.ReplaceSel().
However, these methods do not work:
AkelPad.GetSelText(),
AkelPad.GetTextRange().

I looked at the source - IDocument.c.
These methods use GetTextRange() function that retrieves the text through main window (AKD_EXGETTEXTRANGEW message).
Can you do so that the text was taken directly from edit window (AEM_GETTEXTRANGEW)?

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

Post by Instructor »

Изменено: методы GetSelText и GetTextRange получают текст напрямую из AkelEdit контрола.

Changed: methods GetSelText and GetTextRange retrieves text directly from AkelEdit control.


Scripts plugin v12.6

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

Post by KDJ »

Instructor
Excellently, thank you very much.

You can still mark in documentation as +ActiveX:
AkelPad.GetEditWnd,
AkelPad.SetEditWnd,
AkelPad.GetSelStart,
AkelPad.GetSelEnd,
AkelPad.SetSel,
AkelPad.ReplaceSel,
AkelPad.GetSelText,
AkelPad.GetTextRange.

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

Post by Instructor »

Добавлено: методы WindowRegisterDialog, WindowUnregisterDialog - зарегистрировать диалог для обработки в цикле сообщений. Используется в случае, если диалог создан без WindowRegisterClass.

Added: methods WindowRegisterDialog, WindowUnregisterDialog - register dialog for message loop. Used if dialog created without WindowRegisterClass.


Scripts plugin v12.8

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

Post by KDJ »

Instructor wrote:Только DT_BYTE unsigned, остальные signed.
viewtopic.php?p=9203#p9203

I think it has been changed.
It seems that DT_WORD is also unsigned.
You could add it in the documentation of AkelPad.MemRead().

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

Post by KDJ »

A sample script run on x64:

Code: Select all

var hMainWnd = AkelPad.GetMainWnd();
var hEditWnd = AkelPad.GetEditWnd();
var hFont = AkelPad.SendMessage(hMainWnd, 1233 /*AKD_GETFONTW*/, 0, 0);
WScript.Echo(hFont);
AkelPad.SendMessage(hEditWnd, 48 /*WM_SETFONT*/, hFont, true);
Sometimes the value of hFont is negative.
In this case, there is a run-time error:
Error: Overflow
Code: 800A0006
Line: 5

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

Post by Instructor »

KDJ wrote:Error: Overflow
Code: 800A0006
Line: 5
Were unable to reproduce, but the problems with the large number is possible, because:
Scripts.idl wrote:...
//- JScript and VBScript doesn't understand __int64 in return value
//- VBScript doesn't support UINT in return value
...

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

Post by KDJ »

Instructor wrote:Were unable to reproduce, ...
I repeated following actions 10 times:
1. Run AkelPad.
2. Run sample script.
3. Close AkelPad.
On the ten trials, in three cases, I received a negative value (eg. hFont = -485881582).
//- JScript and VBScript doesn't understand __int64 in return value
This means that many scripts can not be converted into 64-bit version. :cry:

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

Post by KDJ »

Instructor
I think I found the problem solution. :D
Instead AkelPad.SendMessage method, should use User32::SendMessage function.

Code: Select all

var oSys = AkelPad.SystemFunction();
var hMainWnd = AkelPad.GetMainWnd();
var hEditWnd = AkelPad.GetEditWnd();
var hFont = AkelPad.SendMessage(hMainWnd, 1233 /*AKD_GETFONTW*/, 0, 0);
var nObjType = oSys.Call("Gdi32::GetObjectType", hFont);
WScript.Echo("hFont: " + hFont + "\nnObjType: " + nObjType + "\n\n(6=OBJ_FONT)");
//AkelPad.SendMessage(hEditWnd, 48 /*WM_SETFONT*/, hFont, true);
oSys.Call("User32::SendMessageW", hEditWnd, 48 /*WM_SETFONT*/, hFont, true);
It seems to me that AkelPad.SendMessage method not tolerate negative value as a parameter (on x64).

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

Post by Instructor »

Исправлено: передача отрицательных значений методу SendMessage на Windows x64.

Fixed: passing negative values to SendMessage method on Windows x64.


Scripts plugin v12.9

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

Post by KDJ »

It seems, that now can pass a text parameter directly eg.:
AkelPad.SendMessage(hWnd, 0x143 /*CB_ADDSTRING*/, 0, "Text");

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

Post by KDJ »

On Win7 does not work:
AkelPad.Exec("regedit.exe");

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

Post by Instructor »

KDJ
Probably UAC blocks. You can check it by running AkelPad.exe as admin.

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

Post by KDJ »

Instructor
Oh yeah, as admin it works. Thanks.

This can be done also in this way (without admin privileges):
AkelPad.Exec("rundll32.exe shell32, ShellExec_RunDLL regedit.exe");
Post Reply