Page 26 of 96

Posted: Tue Apr 03, 2012 8:47 am
by VladSh
KDJ
And again, thank you! :)
Now it works.

Posted: Fri Apr 06, 2012 3:20 pm
by Infocatcher
highlighter.js
Added detection of files masks from *.coder files in new format.

Posted: Fri Apr 06, 2012 8:57 pm
by KDJ
FeyFre wrote:Попробовал немного поиграться с DialogBoxIndirectParam, но к сожалению ничего не получается(хорошо что хоть не падает) Без доработки со стороны плага не получится этот вызов не заработает(как и другие вызова которые требуют CALLBACK функции)
Can I use DialogBoxIndirect function in the script?

Posted: Sat Apr 07, 2012 8:43 am
by FeyFre
KDJ, with some limitations you can.
First of all, callback function (DLGPROC) should be global function(i.e. defined somewhere globally in script in form "function name(hwnd,msg,wparam,lparam)" ) not dynamic.
The it must be registered with RegisterCallback. Since RegisterCallback has limitation of 4 simultaneously registered functions, a number of different dialogs will be limited too.
As for me, I'm not happy with this limitation. In most cases I shall use dynamic functions and/or closures and/or Function variables but for now I cannot.
You can try yourself. But this is not main concern. Main concern is routine to format DLGTEMPLATE structure in memory which is required as parameter of *Indirect API calls.

Posted: Sat Apr 07, 2012 9:39 am
by Andrey_A_A
Подскажите как записать на vbs:

Code: Select all

  AkelPad.TextFind(0, sSel, 0x00000001|0x00200000);

Posted: Sat Apr 07, 2012 9:47 am
by FeyFre
Andrey_A_A

Code: Select all

AkelPad.TextFind(0, sSel, &H00000001 or &H00200000);

Posted: Sat Apr 07, 2012 11:02 am
by Andrey_A_A
FeyFre, спасибо!

Posted: Sat Apr 07, 2012 3:09 pm
by KDJ
FeyFre
I tried to do it, but it does not work.
Callback function is not called at all.
And I don't know how to format DLGTEMPLATE structure.
Help me.

Code: Select all

var oSys = AkelPad.SystemFunction();
WScript.Echo(DialogBoxIndirect(AkelPad.GetMainWnd(), "Dialog box", "OK"));

function DialogBoxIndirect(hWndParent, sCaption, sButton)
{
  var DT_UNICODE   = 1;
  var DT_DWORD     = 3;
  var DT_WORD      = 4;
  var hInstanceDLL = AkelPad.GetInstanceDll();
  var lpCallback   = oSys.RegisterCallback("DialogBoxIndirectCallback");
  var lpTemp       = AkelPad.MemAlloc(1024);
  var lpItem;
  var nRetVal;

  AkelPad.MemCopy(lpTemp,      0x90C80000, DT_DWORD);   //style (WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU)
  AkelPad.MemCopy(lpTemp +  4, 0x00000000, DT_DWORD);   //dwExtendedStyle
  AkelPad.MemCopy(lpTemp +  8, 1,          DT_WORD);    //cdit
  AkelPad.MemCopy(lpTemp + 10, 200,        DT_WORD);    //x
  AkelPad.MemCopy(lpTemp + 12, 100,        DT_WORD);    //y
  AkelPad.MemCopy(lpTemp + 14, 300,        DT_WORD);    //cx
  AkelPad.MemCopy(lpTemp + 16, 150,        DT_WORD);    //cy
  AkelPad.MemCopy(lpTemp + 18, 0,          DT_WORD);    //menu (no menu)
  AkelPad.MemCopy(lpTemp + 20, 0,          DT_WORD);    //class (default)
  AkelPad.MemCopy(lpTemp + 22, sCaption,   DT_UNICODE); //title

  lpItem = lpTemp + 22 + (sCaption.length + 1) * 2;
  AkelPad.MemCopy(lpItem,      0x50010000, DT_DWORD);   //style (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
  AkelPad.MemCopy(lpItem +  4, 0x00000000, DT_DWORD);   //dwExtendedStyle
  AkelPad.MemCopy(lpItem +  8, 30,         DT_WORD);    //x
  AkelPad.MemCopy(lpItem + 10, 30,         DT_WORD);    //y
  AkelPad.MemCopy(lpItem + 12, 80,         DT_WORD);    //cx
  AkelPad.MemCopy(lpItem + 14, 20,         DT_WORD);    //cy
  AkelPad.MemCopy(lpItem + 16, 3001,       DT_WORD);    //id
  AkelPad.MemCopy(lpItem + 18, 0xFFFF,     DT_WORD);    //class
  AkelPad.MemCopy(lpItem + 20, 0x0080,     DT_WORD);    //class ("Button")
  AkelPad.MemCopy(lpItem + 22, sButton,    DT_UNICODE); //title

  nRetVal = oSys.Call("user32::DialogBoxIndirect" + _TCHAR, hInstanceDLL, lpTemp, hWndParent, lpCallback);

  oSys.UnregisterCallback(lpCallback);
  AkelPad.MemFree(lpTemp);

  return nRetVal;
}

function DialogBoxIndirectCallback(hWnd, uMsg, wParam, lParam)
{
  switch (uMsg)
  {
    case 256 : //WM_KEYDOWN
      if (wParam == 13 /*VK_RETURN*/)
      {
        oSys.Call("user32::EndDialog", hWnd, 1);
        return 1;
      }
      else if (wParam == 27 /*VK_ESCAPE*/)
      {
        oSys.Call("user32::EndDialog", hWnd, 0);
        return 1;
      }

    case 273 : //WM_COMMAND
      if ((wParam & 0xFFFF) == 3001)
      {
        oSys.Call("user32::EndDialog", hWnd, 1);
        return 1;
      }
  }

  return 0;
}

Posted: Sat Apr 07, 2012 4:51 pm
by FeyFre
KDJ
1. There is no such WINUSERAPI call DialogBoxIndirectA/W. DialogBoxIndirectA/W is handy C macro

Code: Select all

#define DialogBoxIndirectA(hInstance, lpTemplate, hWndParent, lpDialogFunc)  DialogBoxIndirectParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
#define DialogBoxIndirectW(hInstance, lpTemplate, hWndParent, lpDialogFunc)  DialogBoxIndirectParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
Real functions are DialogBoxIndirectParamA/W with 4 arguments. The last argument is user-defined value of type LPARAM which will be passed to into DIALOGPROC with WM_INITDIALOG message. So DialogBoxIndirectA/W just set this argument to zero.
So in your case there is wasn't any call because Scritps plugin did not found any DialogBoxIndirectA/W function in user32.dll and just returned zero.
(DialogBoxA/W is also macro for DialogBoxParamA/W).
2. About DLGTEMPLATE structure - here. And I shall advice you to use Unicode variant in all cases(not only because it is deprecated and ugly). And one - just try to load DialogBox withou any controls first, and only then tru with other controls, in order to avoid overlapped errors.

By the way, rename DialogBoxIndirectCallback into DlgProc or something similar - it is more readable and matches references in MSDN and manuals.

Posted: Sat Apr 07, 2012 7:10 pm
by KDJ
FeyFre
Well, I didn't notice that it is a macro.
Thank you very much.

Posted: Sat Apr 07, 2012 10:00 pm
by Andrey_A_A
KDJ
можно попросить...
в скрипте Translator.js сделать ещё параметр, который позволял бы открывать переводчик сразу с содержимым буфера обмена
к примеру:
Call("Scripts::Main", 1, "Translator.js", "en ru" "1")

Posted: Sat Apr 07, 2012 11:17 pm
by KDJ
Andrey_A_A
In the near future, I'll try to do it.

Posted: Sun Apr 08, 2012 2:18 pm
by KDJ
Translator.js

Added:
Third, optional argument.
If equal to "1", the source text is taken from the Clipboard:
Call("Scripts::Main", 1, "Translator.js", "ru pl 1")

Posted: Sun Apr 08, 2012 6:23 pm
by Andrey_A_A
KDJ , Огромное спасибо! Image

Обнаружил маленький недочёт в строке 203
надо наверно так:

Code: Select all

  if ((WScript.Arguments.length > 2) && (WScript.Arguments(2) == "1"))

Posted: Sun Apr 08, 2012 7:40 pm
by KDJ
Andrey_A_A
Yes, of course. Fixed.