sieukrem / jn-npp-plugin

Plugin for Notepad++ allowing you to automate some tasks using JavaScript
https://github.com/sieukrem/jn-npp-plugin/wiki
110 stars 24 forks source link

Call to win32 functions not working #79

Closed David-Mawer closed 5 years ago

David-Mawer commented 5 years ago

Hi There,

So I love being able to write my own scripts that execute in np++ as normal menu options.

I'm trying to use the win32 libraries now (using the example in this page: https://github.com/sieukrem/jn-npp-plugin/wiki/Calling-of-Win32-API-functions )

I can't get that example to work at all - below is the code I'm using: -

testMenu.addItem({
    text:"Testing MessageBox",
    cmd:function(){
        var lib = System.loadLibrary("user32.dll");

        var paramBuf = lib.alloc( 4 * 4);
        var myText = 'Functionality not yet implemented';
        var myCaption = 'Custom Caption :-)';

        lib.writeDWord(paramBuf, 0,  0);
        lib.writeDWord(paramBuf, 4,  myText);
        lib.writeDWord(paramBuf, 8,  myCaption);
        lib.writeDWord(paramBuf, 12, 0);

        lib.call('MessageBoxW', paramBuf);
    }
});

Please could you let me know what I'm doing wrong?

Thanks :-)

sieukrem commented 5 years ago

Hi David,

Which OS and Platform (x64, x86) are you using.

Which Npp version (x64 x86).

Which error message do you get.

Can you provide entire code you try to run.

With regards Eugen

David Mawer notifications@github.com schrieb am Do., 29. Aug. 2019, 17:41:

Hi There,

So I love being able to write my own scripts that execute in np++ as normal menu options.

I'm trying to use the win32 libraries now (using the example in this page: https://github.com/sieukrem/jn-npp-plugin/wiki/Calling-of-Win32-API-functions )

I can't get that example to work at all - below is the code I'm using: - `testMenu.addItem({ text:"Testing MessageBox", cmd:function(){ var lib = System.loadLibrary("user32.dll");

var paramBuf = lib.alloc( 4 * 4); var myText = 'Functionality not yet implemented'; var myCaption = 'Custom Caption :-)';

lib.writeDWord(paramBuf, 0, 0); lib.writeDWord(paramBuf, 4, myText); lib.writeDWord(paramBuf, 8, myCaption); lib.writeDWord(paramBuf, 12, 0);

lib.call('MessageBoxW', paramBuf); }

});`

Please could you let me know what I'm doing wrong?

Thanks :-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sieukrem/jn-npp-plugin/issues/79?email_source=notifications&email_token=ABCRUR7RZ5TOFQ5AQ6EQFK3QG7U27A5CNFSM4ISD3O42YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HIHTFWA, or mute the thread https://github.com/notifications/unsubscribe-auth/ABCRURZ7KM36AJMP2L4XQA3QG7U27ANCNFSM4ISD3O4Q .

David-Mawer commented 5 years ago

Hi Eugen,

OK - so I'm running windows 10 Pro (x64)

and Npp v7.7.1 (x64)

I don't get any error message when the code runs.

DavidMenu.txt

I've attached the file from my "plugins\jN\jN\includes" folder ( had to rename it to a .txt file for GitHub to accept it).

Thanks, David :-)

sieukrem commented 5 years ago

Hi David,

Win32 calls are working only in Nppx86.

I did not have time to adapt asm code working for parameter passing in x64. It could be also breaking change in the JN api necessary.

So my advice is to use x86 version of npp if you need win 32 calls.

With regards Eugen

David Mawer notifications@github.com schrieb am Fr., 30. Aug. 2019, 08:29:

Hi Eugen,

OK - so I'm running windows 10 Pro (x64)

and Npp v7.7.1 (x64)

I don't get any error message when the code runs.

DavidMenu.txt https://github.com/sieukrem/jn-npp-plugin/files/3558530/DavidMenu.txt

I've attached the file from my "plugins\jN\jN\includes" folder ( had to rename it to a .txt file for GitHub to accept it).

Thanks, David :-)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sieukrem/jn-npp-plugin/issues/79?email_source=notifications&email_token=ABCRUR5JU4N76PHUQZCL5GDQHC43FA5CNFSM4ISD3O42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5QWGFQ#issuecomment-526476054, or mute the thread https://github.com/notifications/unsubscribe-auth/ABCRURZTYFWWMMX4AKYHGR3QHC43FANCNFSM4ISD3O4Q .

David-Mawer commented 5 years ago

OK, thanks :-)