Page 34 of 97

Posted: Sun Oct 24, 2010 7:26 pm
by KDJ
Again, interesting. This time with VBS.

First function:

Code: Select all

Dim oSys, nFontSize
set oSys  = AkelPad.SystemFunction()
nFontSize = -oSys.Call("kernel32::MulDiv", -20, 72, 96)
WScript.Echo "nFontSize=" & nFontSize
Result nFontSize=15.

Second function:

Code: Select all

Dim oSys, lfHeight, nDevCap, nFontSize
set oSys  = AkelPad.SystemFunction()
lfHeight  = -20
nDevCap   = 96
nFontSize = -oSys.Call("kernel32::MulDiv", lfHeight, 72, nDevCap)
WScript.Echo "nFontSize=" & nFontSize
Result nFontSize=1.

What is the difference between these two functions?

Posted: Mon Oct 25, 2010 10:29 am
by Instructor
KDJ
I have made some modifications to Scripts plugin. In new version it should be OK, but in new version you need to avoid passing negative values to "kernel32::MulDiv".

Posted: Mon Oct 25, 2010 5:57 pm
by KDJ
Instructor
For now I solved the problem by adding zero to the variable:
nFontSize = -oSys.Call("kernel32::MulDiv", lfHeight + 0, 72, nDevCap + 0)
But the same error occurs in the function gdi32::GetDeviceCaps.

Code: Select all

nDevCap = oSys.Call("gdi32::GetDeviceCaps", hDC,     LOGPIXELSY)
nDevCap = oSys.Call("gdi32::GetDeviceCaps", hDC + 0, LOGPIXELSY)
These functions return two different values (in VBS).
FontIniSize.vbs

Posted: Mon Oct 25, 2010 6:22 pm
by KDJ
One more thing. I do not understand why the same function returns different values in JS and VBS:

Code: Select all

//JS
var lfHeight;
lfHeight = eval("0xFFFFFFF1");

Code: Select all

'VBS
Dim lfHeight
lfHeight = Eval("&HFFFFFFF1")
The result in JS is lfHeight=4294967281, in VBS lfHeight=-15.

Posted: Mon Oct 25, 2010 6:55 pm
by FeyFre
KDJ
signed and unsigned values. Do not forget, JScript, VBScript and other script languages bind to WSH internally work with own typecast styles. Some languages even do not have neither implicit nor explicit integer typecasts.(because integers are not portable)

Posted: Tue Oct 26, 2010 6:59 pm
by KDJ
Fixed CalculatorJS.js. The minus sign was incorrectly displayed in the hex and oct numbers.
In script FontIniSize.js add reading from the registry.

Posted: Thu Oct 28, 2010 5:28 am
by Instructor
В ChmKeyword.js добавлено закрытие CHM окна по Esc. А также залил на narod набор файлов помощи CHM для C/C++, CSS, HTML, VBS, JS, NSIS.

Cpp.chm это старый добрый "Microsoft® Win32® Programmer's Reference" (мини MSDN), который был доступен на скачивание в формате hlp. Чтобы его перевести в chm мне понадобилось 3 дня :) С частью конвертирования справился только "Help & Manual", остальные программы из опробованных не осилили такой объем hlp файла (24Mb), либо форматирование было далеко от оригинала. Для информации: если вы хотите воспользоваться взломанной версией программы, отключайтесь от интернета, а то результат конвертирования будет весьма забавный :)

Posted: Thu Oct 28, 2010 8:40 pm
by KDJ
In the script LinesFilter.js the following code checks to see if ESC key was pressed.

Code: Select all

else if (uMsg == 256)  //WM_KEYDOWN
{
  if (wParam == 27)  //VK_ESCAPE
  {
    //Escape key pushes Cancel button
    oSys.Call("user32::PostMessage" + _TCHAR, hWndDialog, 273 /*WM_COMMAND*/, IDC_CANCEL, 0);
  }
How to check, that you have pressed Ctrl+Alt+Left or Ctrl+Alt+End?

Posted: Thu Oct 28, 2010 9:00 pm
by FeyFre
KDJ
You should check modifier key state in VK_LEFT and VK_END handling routine:

Code: Select all

oSys.Call("user32::GetAsyncKeyState",0xA2/*VK_LCONTROL*/) & 0x80000000)
oSys.Call("user32::GetAsyncKeyState",0xA3/*VK_RCONTROL*/) & 0x80000000)
oSys.Call("user32::GetAsyncKeyState",0xA4/*VK_LMENU*/) & 0x80000000)
oSys.Call("user32::GetAsyncKeyState",0xA5/*VK_RMENU*/) & 0x80000000)
You must read more at MSDN about this syscall(there are may occur some problems with returned value(that why I added "& 0x80000000"))

Posted: Fri Oct 29, 2010 8:39 pm
by KDJ
Thanks FeyFre.
I used it in the script ColumnsSum.js, to move the dialog box using the keyboard.

Posted: Fri Oct 29, 2010 9:26 pm
by FeyFre
KDJ, you did good job. But in most cases, if user do not want to use mouse for window manipulation, he(she) will use Alt+Space hotkey to activate window's system menu and select Move(or even resize) item.

Posted: Sat Oct 30, 2010 6:19 pm
by KDJ
I'm not entirely happy, because it works with keys "Ctrl+Alt", but do not want to work with keys "Shif+Alt".
Using "Ctrl+Alt+Right", also the caret moves in the edit box.

Posted: Sun Oct 31, 2010 3:58 pm
by Instructor
KDJ

Code: Select all

else if (uMsg == 0x100 /*WM_KEYDOWN*/ ||
         uMsg == 0x104 /*WM_SYSKEYDOWN*/)

Posted: Sun Oct 31, 2010 5:33 pm
by KDJ
Instructor
This is what I needed - WM_SYSKEYDOWN!
A big thank for you.

Posted: Tue Nov 02, 2010 9:40 am
by VladSh
Instructor
Скажите, что должен делать скрипт NsisCall.js? Он всегда выдаёт сообщение:
NsisCall.js wrote:---------------------------
c:\_1.txt
---------------------------
ОК