I have a basic python script that calls the plugin NppExport in order to 'Export to RTF'. Unfortunately this raises a dialog box that requests that the proposed file name be confirmed.
Is there any way to handle pop-up confirmation boxes? I would like to simply "press enter" on the default button.
Not directly. If there was an (programmable) interface to NppExport then maybe we could add a module for it, but as far as I know there isn't. You might be able to do something with SendKeys, to send the enter key to the dialog after a short delay.
I've not had chance to have a look yet - and it includes a module, which may or may not work. I'll have a look tomorrow and see if I can build it to be compatible with PythonScript.
Thanks Dave, that would be great.
Ok, seems to work:
timer = threading.Timer(0.5, sendEnter)
notepad.runPluginCommand('NppExport', 'Export to HTML')
The only trick is that as runPluginCommand doesn't return until the plugin has finished it's command, you need to start a thread to send the enter - but as you can see that's very easy.
You need to download the SendKeys.zip (in the ExtraPythonLibs directory under the download section) and add the contents (the SendKeys.py and _sendkeys.pyd) to your Notepad++\plugins\PythonScript\lib directory.
You may need to alter the 0.5 number in the script - that's half a second to wait while the window opens - for me that seems to work every time, but YMMV.
I've only just uploaded the file, so it may take a few minutes before you can see it.
Hope that works for you!
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.