Community
    • Login

    Notepad++, windows 11 and pythonscript

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 4 Posters 572 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.
    • ThosRTannerT
      ThosRTanner
      last edited by

      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)

      Mark OlsonM 1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @ThosRTanner
        last edited by

        @ThosRTanner
        Have you posted an issue in the repo?

        ThosRTannerT 1 Reply Last reply Reply Quote 0
        • ThosRTannerT
          ThosRTanner @Mark Olson
          last edited by

          @Mark-Olson Which repo?

          EkopalypseE 1 Reply Last reply Reply Quote 0
          • EkopalypseE
            Ekopalypse @ThosRTanner
            last edited by

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

            Alan KilbornA 1 Reply Last reply Reply Quote 2
            • Alan KilbornA
              Alan Kilborn @Ekopalypse
              last edited by Alan Kilborn

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

              EkopalypseE 1 Reply Last reply Reply Quote 1
              • EkopalypseE
                Ekopalypse @Alan Kilborn
                last edited by

                @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
                • ThosRTannerT
                  ThosRTanner
                  last edited by

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

                  EkopalypseE 1 Reply Last reply Reply Quote 0
                  • EkopalypseE
                    Ekopalypse @ThosRTanner
                    last edited by

                    @ThosRTanner

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

                    ThosRTannerT 1 Reply Last reply Reply Quote 3
                    • ThosRTannerT
                      ThosRTanner @Ekopalypse
                      last edited by

                      @Ekopalypse working great now. thank you!

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