Run python script (pythonscript plugin) with a shortcut?



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



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



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



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



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



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



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



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


Log in to reply