Script bound to Ctrl-only keycombo can't be opened for edit by holding Ctrl and clicking it in menu
Create simple script and give it a simple name (e.g. t.py):
from Npp import *
notepad.prompt('hello:', 'there', 'dude')
Run the script from the menu to see it works:
Close the t.py file.
Navigate to the script in the menu again, but this time hold Ctrl down while clicking t here:
Observe that t.py opens (correctly) into a Notepad++ tab. Close this N++ tab.
Assign a shortcut that only involves the Ctrl key (e.g. Ctrl + e) to the running of this script, and it will appear like this in the menu:
With that menu showing, point to the t script, hold Ctrl down, and click.
Expected result: t.py opens into a new Notepad++ tab.
Actual result: the script runs.
Using Notepad++ 8.6 64-bit with PS 3.0.16.0.
See https://github.com/bruderstein/PythonScript/blob/50fd4982307041efa963788d6d352c398039f406/PythonScript/src/PythonScript.cpp#L482-L487
From plugin perspective Ctrl+Shortcutkey, Mouseclick menuitem with script and Mouseclick menuitem with script+Ctrl all are connected just the call of the script function from N++ and is not easily possible to find out where it is coming from.
As Workaround a shortcut with Ctrl+Shift or Ctrl+Alt could be used instead.
OK, makes sense. Thanks for investigating.
As Workaround a shortcut with Ctrl+Shift or Ctrl+Alt could be used instead.
Well, users want keycombos as they want them.
Nobody would want to add an extra modifier in just for this capability.
Interesting. I never realized this could be considered a bug as if you use the "Scripts" submenu, t should be there also and you should be able to CTRL+Right Mouse or CTRL+Enter to open in Notepad++. That's what I always have done assuming that the CTRL+<somthing> shortcut in PythonScript only worked on the "Scripts" submenu.
Cheers.
if you use the "Scripts" submenu,
tshould be there also
Yes, this works. The problem comes in when you have hundreds(?!) of scripts in many subfolders, and finding just one can be a lengthy scrolling/digging-down process, and especially annoying if you can plainly see the script you want to edit in the "first-level" PS menu.
[ I probably need a script that prompts me for a partial name, and then finds and opens (for edit) it for me. :-) ]
should be able to CTRL+Right Mouse or CTRL+Enter to open
CTRL+Enter works, but I'm unsure about how CTRL+Right Mouse does anything?
CTRL+Right Mousedoes anything?
I obviously meant using the mouse with your RIGHT HAND to click the LEFT mouse button ... he says after holding both hands in front of his face with the thumbs out to see which one spells the letter L.
Cheers.
Super-confused now. :-) Think I will just ignore prior references to CTRL+Right Mouse...
Somewhat maddeningly:
- put a script (with no bound keycombo, for the sake of simplicity) on Notepad++'s editor right-click menu (i.e.
contextMenu.xml) - have some logic in the script so that it acts differently when Ctrl key is down vs not-down (see sample code below)
- try to run the script with the alternate logic asserted (i.e., hold Ctrl while choosing the script entry in N++ editor right-click menu)
- be befuddled when the script opens in a new tab rather than executing
- (change your script to use Shift, not Ctrl)
sample code:
from ctypes import (WinDLL)
def ctrl_held(self):
VK_CONTROL = 0x11
user32 = WinDLL('user32')
return (user32.GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0
usage of defined function:
...
if self.ctrl_held():
...logic path 1...
else:
...logic path 2...