<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Macro ignores Python script &amp; erratic Shortcut Mapper]]></title><description><![CDATA[<p dir="auto">Dear all!</p>
<p dir="auto">I have a python script, which works fine (1) if it is invoked by its keyboard shortcut (assigned by means of the Shortcut Mapper, in my case Ctrl.-E) or (2) if it is applied via the menu entry Plugins\Python Script\Scripts\MyScript. However, whatever I do, if I try do start MyScript from a recorded <em>Macro</em> (either using method (1) or (2) during recording), nothing happens. (Note: the script works as expected <em>while</em> recording the macro, but it does not if it is <em>re-called</em> again by the <em>saved</em> macro.) It appears, the macro simply ignores the call of the script when getting saved!</p>
<p dir="auto">With respect to Ctrl.-E, maybe, some strange observation applies. The Shortcut Mapper erratically announces a “CONFLICT FOUND!” (when re-opening the mapper) although it says “No conflict …” directly after assigning that shortcut.</p>
<p dir="auto">npp++ is 7.9.5 (64bit), python plugin and, generally, OS (Win10Pro) are up to date.</p>
<p dir="auto">Many thanks for any idea!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20967/macro-ignores-python-script-erratic-shortcut-mapper</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 10:09:15 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20967.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 31 Mar 2021 12:37:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 15:01:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> Thank you too … <em>now</em> it’s clear ;-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64536</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64536</guid><dc:creator><![CDATA[Peter Greistorfer]]></dc:creator><pubDate>Wed, 31 Mar 2021 15:01:55 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 15:00:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peter-greistorfer" aria-label="Profile: Peter-Greistorfer">@<bdi>Peter-Greistorfer</bdi></a> said in <a href="/post/64534">Macro ignores Python script &amp; erratic Shortcut Mapper</a>:</p>
<blockquote>
<p dir="auto">dont use <strong>N</strong>otepad.save()</p>
</blockquote>
<p dir="auto"><strong>N</strong>otepad is the “class name”.<br />
<strong>n</strong>otepad is the instantiated object name.<br />
You call functions on an instantiated object.<br />
So, yes, you want it in your code, just as I wrote it before: <code>notepad.save()</code></p>
<p dir="auto">Same for <strong>E</strong>ditor and <strong>e</strong>ditor.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64535</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64535</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 31 Mar 2021 15:00:18 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 14:54:46 GMT]]></title><description><![CDATA[<p dir="auto">Think I found it: no argument and dont use <em>N</em>otepad.save() :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64534</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64534</guid><dc:creator><![CDATA[Peter Greistorfer]]></dc:creator><pubDate>Wed, 31 Mar 2021 14:54:46 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 14:51:54 GMT]]></title><description><![CDATA[<p dir="auto">What should be the argument of notepad.save() if I want to save the current active edited file?</p>
<p dir="auto">Your second post …, well, thanks, but that will need some <em>more</em> time.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64533</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64533</guid><dc:creator><![CDATA[Peter Greistorfer]]></dc:creator><pubDate>Wed, 31 Mar 2021 14:51:54 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 14:41:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peter-greistorfer" aria-label="Profile: Peter-Greistorfer">@<bdi>Peter-Greistorfer</bdi></a> said in <a href="/post/64530">Macro ignores Python script &amp; erratic Shortcut Mapper</a>:</p>
<blockquote>
<p dir="auto">try to find some insight to extend my running python script</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> mentioned the right command if it really just is a save action.</p>
<p dir="auto">But in general, you can edit <code>shortcuts.xml</code>, and look for your macro name (in my instance, it was <code>blah</code>).  There will be a list of <code>&lt;actions&gt;</code> as described <a href="https://npp-user-manual.org/docs/config-files/#macros" rel="nofollow ugc">in my previous manual link</a>.  For <code>type=0</code> and <code>type=1</code>, the <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/scintilla/include/Scintilla.iface" rel="nofollow ugc">scintilla.iface</a> file will map <code>message=#</code> to the appropriate command – then you can search for that same text in the PythonScript docs to find the <code>editor</code>-object method name.  For <code>type=2</code>, the mapping of built-in menu commands can be found in <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/menuCmdID.h" rel="nofollow ugc">menuCmdID.h</a>, though you have to do a little math: for example, <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/menuCmdID.h#L29" rel="nofollow ugc">IDM_FILE_SAVE</a> maps to <code>(IDM_FILE + 6)</code>, where <code>IDM_FILE</code> and <code>IDM</code> are defined <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/menuCmdID.h#L20-L22" rel="nofollow ugc">near the top of the .h</a>; putting that together, ((40000 + 1000) + 6) = 41006, so set <code>type="2" wParam="41006"</code> in the macro definition will map to <code>IDM_FILE_SAVE</code> – you would then look through the <code>notepad</code> object methods in the PythonScript docs to get the equivalent command.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64532</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64532</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 31 Mar 2021 14:41:10 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 14:20:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peter-greistorfer" aria-label="Profile: Peter-Greistorfer">@<bdi>Peter-Greistorfer</bdi></a> said in <a href="/post/64530">Macro ignores Python script &amp; erratic Shortcut Mapper</a>:</p>
<blockquote>
<p dir="auto">find some insight to extend my running python script with the missing link (it’s just the saving of the active document …).</p>
</blockquote>
<p dir="auto"><code>notepad.save()</code> ?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64531</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64531</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 31 Mar 2021 14:20:33 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 14:17:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> I absolutely appreciate your fast and comprehensive answers, thanks a lot!</p>
<p dir="auto">So I will have to forget the macro-script-approach (since your workaround sketched actually is a little fragile) and try to find some insight to extend my running python script with the missing link (it’s just the saving of the active document …).</p>
<p dir="auto">And, yes, these conflicts and non-conflicts did arise when I filtered the Plugin commands to find my Python scripts written before!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64530</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64530</guid><dc:creator><![CDATA[Peter Greistorfer]]></dc:creator><pubDate>Wed, 31 Mar 2021 14:17:54 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 13:51:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/64528">Macro ignores Python script &amp; erratic Shortcut Mapper</a>:</p>
<blockquote>
<p dir="auto">Now that I describe it, this problem sounds familiar.</p>
</blockquote>
<p dir="auto">Found it.  <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5374" rel="nofollow ugc">issue #5374</a> – it was apparently closed/fixed in v7.6.6… so apparently this is a regression; I will need to experiment with v7.6.6 vs 7.9.5, and maybe even bisect it back to the original, to figure out when it came back (or whether I was wrong about it being fixed in v7.6.6)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64529</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64529</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 31 Mar 2021 13:51:45 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 13:38:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/64527">Macro ignores Python script &amp; erratic Shortcut Mapper</a>:</p>
<blockquote>
<p dir="auto">But even then, I cannot replicate those results</p>
</blockquote>
<p dir="auto">I take it back.  When I was cleaning things up after my experiment, I replicated it.<br />
I deleted the shortcut from the <code>blah</code> macro, and deleted the <code>blah</code> macro.  Then I went to my <code>PerlMonksQuestion</code> PythonScript entry, where I had assigned the <code>Ctrl+E</code> shortcut for the script.</p>
<p dir="auto">In the shortcut mapper view, it originally said “No shortcut conflicts for this item”:</p>
<p dir="auto"><img src="/assets/uploads/files/1617196821656-a7985132-73b0-4593-a3e7-1e4afeefc787-image.png" alt="a7985132-73b0-4593-a3e7-1e4afeefc787-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">But if I <strong>Modify</strong> that line’s shortcut, it claims it is conflicting with itself:</p>
<p dir="auto"><img src="/assets/uploads/files/1617196792091-9021eb54-0020-4951-aee6-f0d6e49557dd-image.png" alt="9021eb54-0020-4951-aee6-f0d6e49557dd-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">If I <strong>Clear</strong> it and modify it again to re-add the <code>Ctrl+E</code>, it finds no conflict.</p>
<p dir="auto">If I clear it there, and assign <code>Ctrl+E</code> to some other Plugin Command entry, the same thing happens (it claims CONFLICT on that keystroke if I <strong>Modify</strong> that same entry).</p>
<p dir="auto">More experiments show: It’s caused when I <em>filter</em> the view – and then, only when the number in the far-left column changes.  If I go to ShortcutMapper’s <strong>Main menu</strong> tab in a brand new unzip of v7.9.5 (no additional plugins, etc) and filter by <code>new</code>, then edit <code>Move to New Instance</code> to add <code>Ctrl+E</code>, it says no conflict.  If I then <strong>Modify</strong> the <code>Move to New Instance</code> while still filtered, it claims a conflict with itself at #167.  If I cancel the <strong>Modify</strong> (so it’s still <code>Ctrl+E</code>) and remove the filter, and scroll down to #167 <code>Move to New Instance</code> and <strong>Modify</strong>, it does <em>not</em> say it’s conflicting with itself.</p>
<p dir="auto">Now that I describe it, this problem sounds familiar.  If I get a chance, I may have to do some searching here and in the issues list, and see if I can find something similar (or if anyone beats me to it, feel free to link to the resulting discussion and/or issue).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64528</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64528</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 31 Mar 2021 13:38:53 GMT</pubDate></item><item><title><![CDATA[Reply to Macro ignores Python script &amp; erratic Shortcut Mapper on Wed, 31 Mar 2021 13:17:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peter-greistorfer" aria-label="Profile: Peter-Greistorfer">@<bdi>Peter-Greistorfer</bdi></a> ,</p>
<blockquote>
<p dir="auto">It appears, the macro simply ignores the call of the script when getting saved!</p>
</blockquote>
<p dir="auto">Correct.  Macro recording does not record calls to plugin menus, including calls to pythonscript entries.  This is because the macro recorder can record three basic actions, per <a href="https://npp-user-manual.org/docs/config-files/#macros" rel="nofollow ugc">the docs</a>: editor commands (essentially keystrokes inside the editor panes), most built-in Notepad++ menu actions, and search/replace actions.</p>
<p dir="auto">Honestly, though, anything you can do in a macro can be translated into PythonScript commands. So if you’ve already got a PythonScript that you’re running, why not just expand it – or write a wrapper PythonScript – to include the other commands that you had been trying to send with a macro?  (There should even be examples in the Forum of calling one pythonscript from another.)</p>
<p dir="auto">The macro system is good for automating built-in actions in a linear fashion.  If you want anything else – loops, conditionals, calling non-built-in actions, etc – then a scripting plugin like Python Script is your best bet.  That said, there is a caveat: the reason why the Macro recorder doesn’t like plugin actions is because they don’t have fixed IDs – as you add or remove plugins, the command-id for the menu actions change.  However, if you are 100% sure that you will not be adding or removing plugins or plugin menu entries, you can sometimes get away with cheating.  If you have a plugin like NppUISpy, you can look at what Command ID is <em>currently</em> assigned to a given PythonScript entry. If you make note of that entry, you can then go edit <code>%AppData%\Notepad++\shortcuts.xml</code> to add a <a href="https://npp-user-manual.org/docs/config-files/#macros" rel="nofollow ugc"><code>type=2</code> action</a> to the recorded macro, where it the <code>wParam</code> value is the Command ID that you manually looked up.  But that’s fragile, because lots of things can influence that.  (Which is why the Macro Recorder doesn’t try, because it would give you a false sense of security.)</p>
<blockquote>
<p dir="auto">With respect to Ctrl.-E … The Shortcut Mapper erratically announces a “CONFLICT FOUND!” (when re-opening the mapper) although it says “No conflict …” directly after assigning that shortcut.</p>
</blockquote>
<p dir="auto">Did you try to assign that keystroke to both the PythonScript <em>and</em> to the macro?  But even then, I cannot replicate those results.  If I assign <code>Ctrl+E</code> to a script, and then go and try to assign it to a macro as well, it tells me that there’s a conflict immediately.<br />
<img src="/assets/uploads/files/1617196086038-b5f257e1-bec3-425f-8ea5-5ce2a5727702-image.png" alt="b5f257e1-bec3-425f-8ea5-5ce2a5727702-image.png" class=" img-fluid img-markdown" /><br />
… the ShortcutMapper main menu will also tell you <em>where</em> this conflict is, so after CONFLICT FOUND suddenly starts appearing – even if you didn’t expect it to – look at the entry that it tells you, because that’s what’s causing the conflict.  If you need help debugging that, you could paste us a screenshot or two – one showing the conflict, and the other showing us the entry that the conflict points to.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64527</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64527</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 31 Mar 2021 13:17:31 GMT</pubDate></item></channel></rss>