Anyone used the new v8.3.3 API calls yet?
-
and to prove that otherwise, Notepad++/PythonScript can do message communication:
>>> winv = ctypes.windll.user32.SendMessageW(notepad.hwnd, 1024+1000+42,0,0) >>> console.write("Win v{}\n".format(winv)) Win v14 >>> nppv = ctypes.windll.user32.SendMessageW(notepad.hwnd, 1024+1000+50,0,0) >>> console.write("NPP v{}.{}\n".format(nppv>>16, nppv&0xFFFF)) NPP v8.33
I would be surprised if it’s Python 2.7.18 vs Python 3.8.5 (especially since I get the same 0s when I run from an external C++ program as well). But I’ll try that:
Weird… I would have expected the same results from PythonScript 2.0.0 as I got in PythonScript 3.0.12 alpha, since SendMessageW shouldn’t be significantly different between the two.
At least I have a known working setup, and can start comparing what C++ and/or Perl are sending, as compared to Python.
(Do you have
notepad.hwnd
set during your startup.py? Because I don’t have that attribute to the notepad object…)–
Anyway, now time to go enjoy a few days at the coast with the family. I probably won’t be posting again in the forum until Sunday -
Under Python 2, wouldn’t you want to pass
u'GEDCOM'
to SendMessageW, not'GEDCOM'
? -
It’s like Alan said.
With Python2 you have to use a Unicode stringu'GEDCOM'
if you want to use theW
version of SendMessage.
Another way would be to useSendMessageA
and'GEDCOM'
.
With Python3 it is the other way round:'GEDCOM'
is the Unicode version and you would have to useb'GEDCOM'
if you want to useSendMessageA
.This is the main difference between python2 and python3.
-
Sorry, I forgot to answer your question.
Yes, notepad.hwnd is set by my startup.py.notepad.hwnd = user32.FindWindowW('Notepad++', None) editor1.hwnd = user32.FindWindowExW(notepad.hwnd, None, "Scintilla", None) editor2.hwnd = user32.FindWindowExW(notepad.hwnd, editor1.hwnd, "Scintilla", None) notepad.splitter_hwnd = user32.FindWindowExW(notepad.hwnd, None, 'splitterContainer', None)
where user32 is
user32 = ctypes.WinDLL('user32')
Enjoy your holidays/vacation/days off …
-
@ekopalypse said in Anyone used the new v8.3.3 API calls yet?:
Yes, notepad.hwnd is set by my startup.py.
More PS3 code, unless
from __future__ import unicode_literals
is at the top.I don’t know, has everyone made the jump from PS2 to PS3, except me?
-
I assume that most users use Python 2, as it is the default PythonScript version installed via the plugin admin.
-
@alan-kilborn said in Anyone used the new v8.3.3 API calls yet?:
I don’t know, has everyone made the jump from PS2 to PS3, except me?
We dumped Python2 back in December 2019 right before it was sunsetted. A few months of migration prior and then all new scripts were Python3. Since Python3 is the only Python installed on my Windows system, I first started with PythonScript 3.0.7-alpha (since it matched my Python 3.8 version) and I haven’t changed since.
Cheers.
-
Note that I said:
has everyone made the jump from PS2 to PS3, except me?
which is NOT equivalent to:
“has everyone made the jump from Python2 to Python3, except me?”
The jump to Python3 for all purposes other than N++ scripting was made long ago.
:-)
-
@alan-kilborn said in Anyone used the new v8.3.3 API calls yet?:
“has everyone made the jump from Python2 to Python3, except me?”
The jump to Python3 for all purposes other than N++ scripting was made long ago.Agreed. I didn’t explain in detail enough, sorry.
Since I’m coding in Python3 and my goal to install PythonScript was to get some Language Server / IDE-like features when coding Python, I needed to run PythonScript 3 so my parsing libraries (Jedi, Rope, PyFlakes) are installed in my system Python3 and will parse Python3 code and PythonScript 3 will find them and execute them.
Cheers.
-
@peterjones said in Anyone used the new v8.3.3 API calls yet?:
Anyway, now time to go enjoy a few days at the coast with the family. I probably won’t be posting again in the forum until Sunday
If you put the same effort into your day job as you do here in the Community and also on the N++ user manual, a resounding “WELL DESERVED!” :-)
-
After getting back from the coast, I confirmed that
import ctypes notepad.hwnd = ctypes.windll.user32.FindWindowW(u'Notepad++', None) nppv = ctypes.windll.user32.SendMessageW(notepad.hwnd, 1024+1000+50,0,0) console.write("NPP v{}.{}\n".format(nppv>>16, nppv&0xFFFF)) ctypes.windll.user32.SendMessageW(notepad.hwnd, 1024+1000+104, u'GEDCOM', 2) mode = ctypes.c_ssize_t(0) ctypes.windll.user32.SendMessageW(notepad.hwnd, 1024+1000+103, u'GEDCOM', ctypes.pointer(mode)) mode.value
did what I wanted in old PythonScript, so it was a matter of the missing unicode marker. Which probably means that the reason my compiled version failed was probably that it wasn’t in UTF-16-LE like it should have been. But it gives me a lead, and I know in my PerlScript source code what I need to do to make sure that I send the string as UTF-16-LE.
–
(A few minutes before the moon set behind the clouds this morning. Twas a nice few days… but now, back to reality.)