Community
    • Login

    Anyone used the new v8.3.3 API calls yet?

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    16 Posts 4 Posters 870 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.
    • Alan KilbornA
      Alan Kilborn @PeterJones
      last edited by

      @peterjones

      Under Python 2, wouldn’t you want to pass u'GEDCOM' to SendMessageW, not 'GEDCOM' ?

      1 Reply Last reply Reply Quote 1
      • EkopalypseE
        Ekopalypse
        last edited by

        It’s like Alan said.
        With Python2 you have to use a Unicode string u'GEDCOM' if you want to use the W version of SendMessage.
        Another way would be to use SendMessageA and 'GEDCOM'.
        With Python3 it is the other way round: 'GEDCOM' is the Unicode version and you would have to use b'GEDCOM' if you want to use SendMessageA.

        This is the main difference between python2 and python3.

        1 Reply Last reply Reply Quote 2
        • EkopalypseE
          Ekopalypse
          last edited by Ekopalypse

          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 …

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

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

            EkopalypseE Michael VincentM 2 Replies Last reply Reply Quote 1
            • EkopalypseE
              Ekopalypse @Alan Kilborn
              last edited by

              @alan-kilborn

              I assume that most users use Python 2, as it is the default PythonScript version installed via the plugin admin.

              1 Reply Last reply Reply Quote 1
              • Michael VincentM
                Michael Vincent @Alan Kilborn
                last edited by

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

                Alan KilbornA 1 Reply Last reply Reply Quote 1
                • Alan KilbornA
                  Alan Kilborn @Michael Vincent
                  last edited by

                  @michael-vincent

                  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.

                  :-)

                  Michael VincentM 1 Reply Last reply Reply Quote 1
                  • Michael VincentM
                    Michael Vincent @Alan Kilborn
                    last edited by

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

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

                      @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!” :-)

                      PeterJonesP 1 Reply Last reply Reply Quote 2
                      • PeterJonesP
                        PeterJones @Alan Kilborn
                        last edited by PeterJones

                        @alan-kilborn & @Ekopalypse ,

                        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.

                        –
                        c4847b06-4ba8-4e99-a958-78dcbcbfe77f-image.png
                        (A few minutes before the moon set behind the clouds this morning. Twas a nice few days… but now, back to reality.)

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