Notepad++, windows 11 and pythonscript
-
I’ve recently had to replace my windows 10 computer with a windows 11 one. After reinstalling notepad++, pythonscript and python2.7 and the windows api python extension, I’m having problems with this script:
https://github.com/ThosRTanner/python-notepad-scripts/blob/master/statusbar_for_linter.py
The read_statusbar_section function is always returning an empty string as the SendMessage function always returns 0.
I’m at a loss to work out what is happening here, and if anyone has any suggestions I’d be grateful.
(PS I may have posted this twice. the forum is being a bit strange today)
-
@ThosRTanner
Have you posted an issue in the repo? -
@Mark-Olson Which repo?
-
The problem with the code is that it is not clear how SendMessage needs to be called.
Make sure you define a prototype, such asimport ctypes from ctypes.wintypes import ( HWND, UINT, WPARAM, LPARAM ) LRESULT = ctypes.c_ssize_t SendMessage = user32.SendMessageW SendMessage.restype = LRESULT SendMessage.argtypes = [HWND, UINT, WPARAM, LPARAM]and then use that always.
Python now knows how to handle the parameters and will throw exceptions if they are not specified properly.
HWND is a pointer, while the rest are integer types. -
@Ekopalypse said in Notepad++, windows 11 and pythonscript:
LRESULT = ctypes.c_ssize_t
This is interesting. Previously I believe you recommended:
LRESULT = LPARAMand indeed that is what I have in my scripts that use this.
Isctypes.c_ssize_ta better thing to use? -
@Alan-Kilborn said in Notepad++, windows 11 and pythonscript:
Is ctypes.c_ssize_t a better thing to use?
No, they are exactly the same.

I have finally started to migrate my scripts with a single winapi module
and I kept the c_ssize_t variant because it is more descriptive for me.
There is no doubt that it is a signed size_t, while LPARAM cannot tell.
If wintypes had contained LRESULT, I would have taken it. -
it’s now objecting because what create_string_buffer returns isn’t an integer.
-
use ctypes.addressof to get the int representation of the pointer
-
@Ekopalypse working great now. thank you!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login