Community
    • Login

    Run python script (pythonscript plugin) with a shortcut?

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    9 Posts 5 Posters 10.7k 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.
    • Mikhail VM
      Mikhail V
      last edited by

      I have installed Pythonscript plugin (it works though only on 32 bit version)

      I have a simple script, just print in console something and it’s working.
      I need to bind a key which runs this script, but can’t find anything in the shorcut mapper.
      Do I need probably to write it in some config manually?
      So I can run it only from the plugin menu.
      How do I run specific script with a keyboard shortcut?

      Claudia FrankC Scott SumnerS 2 Replies Last reply Reply Quote 1
      • Claudia FrankC
        Claudia Frank @Mikhail V
        last edited by

        @Mikhail-V

        copied from docu

        If you click Configuration, you can assign the script either to a toolbar icon, or to the Python Script menu itself. If you assign a script to the menu, then it will appear immediately, but you will not be able to assign a shortcut to it until next time Notepad++ starts.

        What I do have in addition is a proxy script which calls the current active python script,
        good for testing.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 3
        • Scott SumnerS
          Scott Sumner @Mikhail V
          last edited by

          @Mikhail-V said:

          How do I run specific script with a keyboard shortcut?

          To elaborate on @Claudia-Frank 's answer:

          Go to Plugins (menu) -> Python Script -> Configuration. The Python Script Shortcut Configuration window will appear.

          In the Scripts area at the top of the Python Script Shortcut Configuration window, locate and select the script you want to bind to a shortcut (and/or toolbar button).

          Between the Scripts box and the Menu items (or Toolbar icons) caption there is an Add button. To get your script added as a menu item (necessary to bind a keycombo to it via the “Shortcut Mapper”), press the Add button (the one above the Menu items caption). Very similar but hopefully obvious what to do for a toolbar button.

          Once you click OK to dismiss the Python Script Shortcut Configuration window, you should be able to go into Plugins (menu) -> Python Script (just point to that and let the menu cascade open) and then see your script at this level of the menu (between the Scripts-> and Configuration entries). Seeing your script appear here is key to being able to tie it to a shortcut keycombo.

          Restart Notepad++. This allows the “Shortcut Mapper” to see that you’ve changed the Plugins (menu) -> Python Script menu contents.

          Now go to Settings (menu) -> Shortcut Mapper… and select the Plugin commands tab. Scrolling down somewhat you should see your script in the Name column (along with “Pythonscript” in the Plugin column). Go ahead and select your script and assign a keycombo to it just like you would for any other command.

          Franklin DelgadoF 1 Reply Last reply Reply Quote 4
          • V S RawatV
            V S Rawat
            last edited by

            thanks to you all,

            I was also wondering how to assign a keyboard shortcut to my first pyscript.

            I came to this forum to post that query, but then I searched first, and found this post and guided by your posts, I could successfully do it.

            thanks a lot.

            1 Reply Last reply Reply Quote 1
            • V S RawatV
              V S Rawat
              last edited by

              Also, I have added my script to toolbar, but it is not appearing on the toolbar anywhere.

              I haven’t changed or assigned any icon to it. Is that required?

              when I click on “icon” in python script configuration, it takes to a folder on hd with doesn’t have any .ico file at all.

              where do I find ico files to assign to my script?

              thanks.

              Claudia FrankC 1 Reply Last reply Reply Quote 0
              • Claudia FrankC
                Claudia Frank @V S Rawat
                last edited by

                @V-S-Rawat said:

                Also, I have added my script to toolbar, but it is not appearing on the toolbar anywhere.

                I haven’t changed or assigned any icon to it. Is that required?

                No, if you don’t specify your own icons it should take the normal python icon like the last one here

                Did you restart afterwards?

                when I click on “icon” in python script configuration, it takes to a folder on hd with doesn’t have any .ico file at all.

                where do I find ico files to assign to my script?

                There are no icons, except the standard one, delivered, you need to create it yourself.
                Note, there are some restrictions like it must be bmp and either 16x16 or 32x32 in size.

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 2
                • V S RawatV
                  V S Rawat
                  last edited by

                  I have my pyscript macro name appearing in pyscript configuration under “add to toolbar”,

                  but no icon is appearing in toolbar.

                  yeah, that was several weeks ago and I have restarted npp and my pc several times.

                  Thanks.

                  Claudia FrankC 1 Reply Last reply Reply Quote 0
                  • Claudia FrankC
                    Claudia Frank @V S Rawat
                    last edited by

                    @V-S-Rawat

                    Do you use the standard icons for toolbox?
                    Settings->Preferences->General->Toolbox

                    Do you see an icon if you add the script to the toolbar section?
                    (within python script shortcut configuration window)

                    Cheers
                    Claudia

                    1 Reply Last reply Reply Quote 0
                    • Franklin DelgadoF
                      Franklin Delgado @Scott Sumner
                      last edited by

                      @Scott-Sumner said in Run python script (pythonscript plugin) with a shortcut?:

                      @Mikhail-V said:

                      How do I run specific script with a keyboard shortcut?

                      To elaborate on @Claudia-Frank 's answer:

                      Go to Plugins (menu) -> Python Script -> Configuration. The Python Script Shortcut Configuration window will appear.

                      In the Scripts area at the top of the Python Script Shortcut Configuration window, locate and select the script you want to bind to a shortcut (and/or toolbar button).

                      Between the Scripts box and the Menu items (or Toolbar icons) caption there is an Add button. To get your script added as a menu item (necessary to bind a keycombo to it via the “Shortcut Mapper”), press the Add button (the one above the Menu items caption). Very similar but hopefully obvious what to do for a toolbar button.

                      Once you click OK to dismiss the Python Script Shortcut Configuration window, you should be able to go into Plugins (menu) -> Python Script (just point to that and let the menu cascade open) and then see your script at this level of the menu (between the Scripts-> and Configuration entries). Seeing your script appear here is key to being able to tie it to a shortcut keycombo.

                      Restart Notepad++. This allows the “Shortcut Mapper” to see that you’ve changed the Plugins (menu) -> Python Script menu contents.

                      Now go to Settings (menu) -> Shortcut Mapper… and select the Plugin commands tab. Scrolling down somewhat you should see your script in the Name column (along with “Pythonscript” in the Plugin column). Go ahead and select your script and assign a keycombo to it just like you would for any other command.

                      excelente muchas gracias tu aporte

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