• Login
Community
  • Login

Notepad++, windows 11 and pythonscript

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 4 Posters 574 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    ThosRTanner
    last edited by Jul 8, 2023, 6:56 AM

    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)

    M 1 Reply Last reply Jul 8, 2023, 7:32 AM Reply Quote 0
    • M
      Mark Olson @ThosRTanner
      last edited by Jul 8, 2023, 7:32 AM

      @ThosRTanner
      Have you posted an issue in the repo?

      T 1 Reply Last reply Jul 8, 2023, 8:34 AM Reply Quote 0
      • T
        ThosRTanner @Mark Olson
        last edited by Jul 8, 2023, 8:34 AM

        @Mark-Olson Which repo?

        E 1 Reply Last reply Jul 8, 2023, 9:37 AM Reply Quote 0
        • E
          Ekopalypse @ThosRTanner
          last edited by Jul 8, 2023, 9:37 AM

          @ThosRTanner

          The problem with the code is that it is not clear how SendMessage needs to be called.
          Make sure you define a prototype, such as

          import 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.

          A 1 Reply Last reply Jul 8, 2023, 10:58 AM Reply Quote 2
          • A
            Alan Kilborn @Ekopalypse
            last edited by Alan Kilborn Jul 8, 2023, 10:58 AM Jul 8, 2023, 10:58 AM

            @Ekopalypse said in Notepad++, windows 11 and pythonscript:

            LRESULT = ctypes.c_ssize_t

            This is interesting. Previously I believe you recommended:

            LRESULT = LPARAM

            and indeed that is what I have in my scripts that use this.
            Is ctypes.c_ssize_t a better thing to use?

            E 1 Reply Last reply Jul 8, 2023, 11:29 AM Reply Quote 1
            • E
              Ekopalypse @Alan Kilborn
              last edited by Jul 8, 2023, 11:29 AM

              @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.

              8859cab6-5665-4747-a190-2b0011a8de0b-image.png

              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.

              1 Reply Last reply Reply Quote 3
              • T
                ThosRTanner
                last edited by Jul 8, 2023, 11:49 AM

                it’s now objecting because what create_string_buffer returns isn’t an integer.

                E 1 Reply Last reply Jul 8, 2023, 11:54 AM Reply Quote 0
                • E
                  Ekopalypse @ThosRTanner
                  last edited by Jul 8, 2023, 11:54 AM

                  @ThosRTanner

                  use ctypes.addressof to get the int representation of the pointer

                  T 1 Reply Last reply Jul 8, 2023, 3:46 PM Reply Quote 3
                  • T
                    ThosRTanner @Ekopalypse
                    last edited by Jul 8, 2023, 3:46 PM

                    @Ekopalypse working great now. thank you!

                    1 Reply Last reply Reply Quote 2
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors