Community
    • Login

    PythonScript

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    30 Posts 5 Posters 2.8k 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.
    • EkopalypseE
      Ekopalypse @Heinz Berecz 0
      last edited by

      @heinz-berecz-0

      To assign a shortcut, the script must be available in this yellow highlighted area.

      3ffe168b-c270-4421-8f99-6da3abf5f51e-image.png

      You can use the normal Shortcut Mapper to assign the key mapping as you wish

      bd10e2e0-89f7-45ae-ab52-0993e49b0f75-image.png

      Heinz Berecz 0H 1 Reply Last reply Reply Quote 2
      • cmeriauxC
        cmeriaux @Heinz Berecz 0
        last edited by

        @heinz-berecz-0 you have to select a script (in user scripts or machine scripts), then the add button become available

        the user script path is kind of obsolete with latest Npp workflow, but if you need it, it’s:

        C:\Users\XXXXXXXXX\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\
        

        9cb29c78-a712-4990-9803-382315e70733-image.png

        PeterJonesP Heinz Berecz 0H 2 Replies Last reply Reply Quote 3
        • Alan KilbornA
          Alan Kilborn @Heinz Berecz 0
          last edited by

          @heinz-berecz-0 said in PythonScript:

          How do I run a specific script with a keyboard shortcut?

          Shortcut mapping for running PythonScripts uses the normal N++ method for assigning keyboard shortcuts, with a twist because PythonScript is involved.

          If you go to Shortcut Mapper (via Settings menu) and switch to the Plugin commands tab and scroll down, you’ll see some entries for PythonScript:

          1480512d-e8f8-4c75-8cb2-a3be25d0f1d4-image.png

          Notice here that I’ve got one called BackgroundColorEveryOtherLine that is non-standard. It is non-standard because it is one of my custom scripts. So…how did I get it to appear in the Shortcut Mapper so that a keycombo can be assigned to it?

          Normally your scripts appear as a submenu off of Scripts > (ref. screenshot in prior posting). Well, Shortcut Mapper doesn’t see that far “down” into a plugin’s menu hierarchy–it only sees one level down (if you notice, commands 25 to 32–with exception of 29–in the screenshot just above are “first-submenu” commands of PythonScript).

          We need to get a script moved “up” one level, how to do that…hmmm…

          Go into PythonScript Configuration and use the Add button right above the Menu items text to get your desired script added to the box below Menu items, example:

          6139806b-1656-4728-8f8d-308705def823-image.png

          After a restart of Notepad++, the script now appears in PythonScript’s first-level submenu, example:

          17c68f30-1073-4b66-985a-1adc63f1a6c1-image.png

          More importantly, your script will now appear in Notepad++'s Shortcut Mapper and you may assign a keycombo, example:

          43b47b5e-5c01-44fd-a3c7-366e6b82f358-image.png

          1 Reply Last reply Reply Quote 4
          • PeterJonesP
            PeterJones @cmeriaux
            last edited by

            Three overlapping replies. That might be a record. ;-)

            —

            Since the primary question has been sufficiently answered, I don’t feel bad hijacking the thread:

            @cmeriaux said in PythonScript:

            the user script path is kind of obsolete with latest Npp workflow,

            Why do you say that?

            From the way I understood it, “system” vs “user” was originally intended to allow some scripts on a given PC that were available to all users (like if my wife and I wanted to use scripts X and Y when logged in as our separate accounts), but some scripts that are unique to a given user (like I also want Z available, but she wants W available, and neither of us want to see the unique-to-spouse’s scripts). I don’t see what about the current workflow would obsolete that.

            Or, for a less spousal example, maybe a workplace IT department wants to install Notepad++ with scripts that every user should use, but no user should have permission to modify (in the system-scripts area, it’s in the UAC-protected Program Files hierarchy; this could be used for protected business processes where auditors would complain if it wasn’t done the same way for every worker), but allow the individual workers to create their own scripts to automate tasks specific to their job functions.

            IMO, both of those are good reasons for still maintaining two separate script locations.

            cmeriauxC 1 Reply Last reply Reply Quote 2
            • cmeriauxC
              cmeriaux @PeterJones
              last edited by

              @peterjones said in PythonScript:

              Why do you say that?

              I think (but I may be wrong) notepad++ doesn’t install any plugins in AppData\Roaming\Notepad++\plugins anymore. So those folder must be created manually.

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @cmeriaux
                last edited by

                @cmeriaux said in PythonScript:

                I think (but I may be wrong) notepad++ doesn’t install any plugins in AppData\Roaming\Notepad++\plugins anymore. So those folder must be created manually.

                It doesn’t install any plugins in that folder. But %AppData%\Notepad++\plugins\Config\ is still where plugins configuration files go… And for PythonScript, %AppData%\Notepad++\plugins\Config\PythonScript\scripts\ is still the location for user scripts, and even if %AppData%\Notepad++\plugins\Config\PythonScript\ doesn’t exist yet.

                On my machine where I normally don’t use the AppData (so I don’t have a Notepad++ in the %AppData% hierarchy), I just unzipped a fresh portable, then removed doLocalConf.xml, so that the portable will use %AppData%. I installed PythonScript, and ran Plugins > Python Script > New Script: it defaulted to %AppData%\Notepad++\plugins\Config\PythonScript\scripts\ … and it did create that folder for me when I saved the new script. (And portable without doLocalConf.xml is the same as a normal installation, as far as using the AppData folder is concerned.)

                1 Reply Last reply Reply Quote 2
                • Heinz Berecz 0H
                  Heinz Berecz 0 @cmeriaux
                  last edited by

                  @cmeriaux said in PythonScript:

                  you have to select a script (in user scripts or machine scripts), then the add button become available

                  I cannot select a script (in user scripts or machine scripts), because both fields are empty

                  1 Reply Last reply Reply Quote 0
                  • Heinz Berecz 0H
                    Heinz Berecz 0 @Ekopalypse
                    last edited by

                    @ekopalypse said in PythonScript:

                    To assign a shortcut, the script must be available in this yellow highlighted area.

                    On my PC no scripts are available in this yellow highlighted area nor in the user scripts or machine scripts area.

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @Heinz Berecz 0
                      last edited by

                      @heinz-berecz-0 said in PythonScript:

                      On my PC no scripts are available in this yellow highlighted area nor in the user scripts or machine scripts area.

                      The user-scripts area will be empty if you haven’t created any user scripts, so that’s natural. But the machine scripts will only be empty if you had a bad installation of PythonScript, or if you intentionally deleted all the example scripts. But if you can see the sample scripts in the Plugins > Python Script > Scripts > Samples submenu, then they weren’t deleted.

                      Since sometimes animation helps users see something that simple screenshots do not:

                      Heinz Berecz 0H 1 Reply Last reply Reply Quote 3
                      • Heinz Berecz 0H
                        Heinz Berecz 0 @PeterJones
                        last edited by

                        @peterjones said in PythonScript:

                        The user-scripts area will be empty if you haven’t created any user scripts, so that’s natural. But the machine scripts will only be empty if you had a bad installation of PythonScript, or if you intentionally deleted all the example scripts. But if you can see the sample scripts in the Plugins > Python Script > Scripts > Samples submenu, then they weren’t deleted.

                        How can I uninstall a bad installation of PythonScript?

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

                          @heinz-berecz-0

                          How did you install it in the first place?
                          If you used the msi package, remove it via the Windows function for removing programmes. Otherwise, do it via the plugin admin of Npp.

                          a9824664-58eb-4043-a3ad-4015180b1932-image.png

                          Heinz Berecz 0H 2 Replies Last reply Reply Quote 0
                          • Heinz Berecz 0H
                            Heinz Berecz 0 @Ekopalypse
                            last edited by

                            @ekopalypse Thank you, now it works. But a new Script (\plugins\PythonScript\scripts\aa.py) appears in the machine scripts area, not in the user scripts area.

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

                              @heinz-berecz-0

                              How did you create this new script?
                              Via the plugin menu new script?
                              If so, an save dialog should have opened asking you to save the file. Where did it point to?

                              Heinz Berecz 0H 1 Reply Last reply Reply Quote 0
                              • Heinz Berecz 0H
                                Heinz Berecz 0 @Ekopalypse
                                last edited by

                                @ekopalypse Via the plugin menu new script. The save dialog pointed to D:\N++\plugins\PythonScript\scripts\

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

                                  @heinz-berecz-0

                                  hmmm … strange, it should point to D:\N++\plugins\config\PythonScript\scripts instead.
                                  Could be related to Explorer caching, but not quite sure.

                                  Heinz Berecz 0H Alan KilbornA 3 Replies Last reply Reply Quote 0
                                  • Heinz Berecz 0H
                                    Heinz Berecz 0 @Ekopalypse
                                    last edited by

                                    @ekopalypse Thank you. I copied my script to D:\N++\plugins\config\PythonScript\scripts, now it works.

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

                                      @ekopalypse said in PythonScript:

                                      hmmm … strange, it should point to D:\N++\plugins\config\PythonScript\scripts instead.
                                      Could be related to Explorer caching, but not quite sure.

                                      I often prove out scripts I’m about to post by using a “clean” portable N++/PS setup. It makes me crazy that this new setup somehow knows my daily-use directory structure and defaults to this when I am trying to create/save a script. I often make the mistake of saving in my daily-use hierarchy, something I definitely don’t want to be doing.

                                      1 Reply Last reply Reply Quote 0
                                      • Heinz Berecz 0H
                                        Heinz Berecz 0 @Ekopalypse
                                        last edited by

                                        @ekopalypse You have PythonScript Version 3.0.7, my Version is after newly installing the PythonScript plugin 1.5.4

                                        Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                                        • Alan KilbornA
                                          Alan Kilborn @Heinz Berecz 0
                                          last edited by

                                          @heinz-berecz-0 said in PythonScript:

                                          You have PythonScript Version 3.0.7, my Version is after newly installing the PythonScript plugin 1.5.4

                                          3.x is a pre-release version, if you want it you have to do special things to install it (go to the PS website and manually get it and manually install it).

                                          Installing via Plugins Admin will get you 1.5.4.

                                          1 Reply Last reply Reply Quote 1
                                          • PeterJonesP
                                            PeterJones @Heinz Berecz 0
                                            last edited by

                                            @heinz-berecz-0 said in PythonScript:

                                            @ekopalypse You have PythonScript Version 3.0.7, my Version is after newly installing the PythonScript plugin 1.5.4

                                            Eko’s example may be that way. But the animation I showed was using PythonScript version 1.5.4, and it worked the way I intended.

                                            I think why you (and Alan) have problems with Windows remembering the “wrong” scripts directory is because (if I understand correctly), some of Windows’ “memory” in the registry for last-opened-folder in the FileOpen or similar windows is based on the name of the application (so in this case notepad++.exe), rather than on the full path to the application (c:\program files\notepad++\notepad++.exe vs x:\some\portable\path\notepad++.exe for a portable), so Windows may only keep one recently-opened-folder setting for both notepad++.exe. (But that’s a piecemeal memory, nothing with hard data to support that conclusion.) Any time you bring Windows OS into the mix, a new level of confusion arises. ;-)

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