<?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 script when txt content changes]]></title><description><![CDATA[<p dir="auto">I have a macro and I want it to run automatically whenever the content of a txt file changes. The txt is loaded in real time thanks to the “document monitor” plugin. Is there a way to automatically start a Notepad ++ macro, without the external use of powershell and the like?</p>
<p dir="auto">I am missing the string to run the script.</p>
<p dir="auto">Conditions:<br />
Upload the txt file from the following path \ SERVER \ Disk_C \ example.txt</p>
<ul>
<li>execute the script every time the txt file changes content</li>
<li>execute key combination “Ctrl + Shift + 9”</li>
<li>save the txt</li>
</ul>
<p dir="auto">thank you<br />
Mirko</p>
<p dir="auto">Ho una macro e voglio che venga eseguita automaticamente ogni volta che il contenuto di un file txt cambia. Il txt viene caricato in real time grazie al plugin “document monitor”. C’è un modo per avviare automaticamente una macro di Notepad ++, senza l’uso esterno di powershell e simile?</p>
<p dir="auto">Mi manca la stringa per eseguire lo script.</p>
<p dir="auto">Condizioni:<br />
Carica il file txt dal seguente percorso \SERVER\Disco_C\esempio.txt</p>
<ul>
<li>esegui lo script ogni qual volta il file txt cambia contenuto</li>
<li>esegui combinazione tasti “Ctrl+Shift+9”</li>
<li>salva il txt</li>
</ul>
<p dir="auto">grazie<br />
Mirko</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20795/macro-script-when-txt-content-changes</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 18:11:10 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20795.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 25 Feb 2021 14:08:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Macro script when txt content changes on Mon, 01 Mar 2021 12:05:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/63404">Macro script when txt content changes</a>:</p>
<blockquote>
<p dir="auto">You start the script via the PythonScript menu, BUT only once. If you call it multiple times, the macro will be called the same number of times. I should have mentioned that before, sorry.</p>
</blockquote>
<p dir="auto">ahahah you are right :) The title and the interpreter are reversed twice … I should have guessed it.</p>
<p dir="auto">It seems to work perfectly.<br />
now, I just have a txt encoding problem but that goes beyond this post</p>
<p dir="auto">thank you all</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63406</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63406</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Mon, 01 Mar 2021 12:05:44 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Mon, 01 Mar 2021 11:35:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mirko-rossi" aria-label="Profile: Mirko-Rossi">@<bdi>Mirko-Rossi</bdi></a></p>
<p dir="auto">that is strange, indeed. May I ask you how exactly you did it?<br />
I expect the following:</p>
<ol>
<li>The file \SERVER\Disco_C\rds.txt is open in npp.</li>
<li>You start the document monitor</li>
<li>You start the script via the PythonScript menu, BUT only once. If you call it multiple times, the macro will be called the same number of times. I should have mentioned that before, sorry.</li>
</ol>
<p dir="auto">For testing, open the PythonScript console (via menu) and run <code>notepad.clearCallbacks()</code> after each try to be sure that no<br />
callback is active anymore. Or add this line before <code>notepad.callback(on_buffer_activate, [NOTIFICATION.BUFFERACTIVATED])</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/63404</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63404</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 01 Mar 2021 11:35:45 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Mon, 01 Mar 2021 11:29:57 GMT]]></title><description><![CDATA[<p dir="auto">another example<br />
txt original: “No woman no cry - Bob Marley”<br />
no script: Bob Marley - No woman no cry<br />
with script: No woman no cr - ob Marley</p>
<p dir="auto">deletes one more character, next to the final leading quotes "</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63403</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63403</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Mon, 01 Mar 2021 11:29:57 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Mon, 01 Mar 2021 11:27:08 GMT]]></title><description><![CDATA[<p dir="auto">ok, it starts up but doesn’t work properly. The macro, if called manually, works correctly; if called via script (automatically) it compares badly.</p>
<p dir="auto">I write an example…<br />
Original txt, starting: “Shake you down - Gregory Abbott”<br />
This is the result with the automatic script: Shake you dow - regory Abbott<br />
This is the result if I run the macro manually: Gregory Abbott - Shake you down</p>
<p dir="auto">strange, right?<br />
thanks</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63402</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63402</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Mon, 01 Mar 2021 11:27:08 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Mon, 01 Mar 2021 11:04:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mirko-rossi" aria-label="Profile: Mirko-Rossi">@<bdi>Mirko-Rossi</bdi></a></p>
<p dir="auto"><code>\\SERVER\Disco_C\rds.txt</code> is the file which is monitored, correct? And <code>intero</code> is the name of the macro?</p>
<p dir="auto">If so, call <code>notepad.runMenuCommand('Macro', 'intero')</code><br />
but only, if Macro is the name of the menu.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63401</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63401</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 01 Mar 2021 11:04:52 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Mon, 01 Mar 2021 10:59:20 GMT]]></title><description><![CDATA[<p dir="auto">it seems not to work.<br />
I created and ran the script from the plugin menu. Am I wrong some steps?</p>
<p dir="auto">This is the script code:</p>
<pre><code>from Npp import notepad, editor, NOTIFICATION
import hashlib

def md5sum(): return hashlib.md5(editor.getText()).hexdigest()

def on_buffer_activate(args):
    global CURRENT_HASH
    if args['bufferID'] == FILE_TO_BE_MONITORED:
        NEW_HASH = md5sum()
        if CURRENT_HASH != NEW_HASH:
            CURRENT_HASH = NEW_HASH
            notepad.runMenuCommand('\\SERVER\Disco_C\rds.txt', 'intero')

FILE_TO_BE_MONITORED = notepad.getCurrentBufferID()
CURRENT_HASH = md5sum()
notepad.callback(on_buffer_activate, [NOTIFICATION.BUFFERACTIVATED]) 
</code></pre>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/63327">Macro script when txt content changes</a>:</p>
<blockquote>
<pre><code>        notepad.runMenuCommand('Macro', 'YOUR_MACRO_NAME')
</code></pre>
</blockquote>
<p dir="auto">i think i didn’t understand how to compile</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63400</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63400</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Mon, 01 Mar 2021 10:59:20 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 21:17:09 GMT]]></title><description><![CDATA[<p dir="auto">Ok, I misunderstood what was meant by “Document Monitor”.<br />
I assumed we are talking about this one</p>
<p dir="auto"><img src="/assets/uploads/files/1614373434465-2ef2cedf-0430-4c80-ae35-735b6ddf852c-image.png" alt="2ef2cedf-0430-4c80-ae35-735b6ddf852c-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">So, as <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a>  already mentioned, this one is generating a buffer activated event, which means your could do something like this</p>
<pre><code>from Npp import notepad, editor, NOTIFICATION
import hashlib

def md5sum(): return hashlib.md5(editor.getText()).hexdigest()

def on_buffer_activate(args):
    global CURRENT_HASH
    if args['bufferID'] == FILE_TO_BE_MONITORED:
        NEW_HASH = md5sum()
        if CURRENT_HASH != NEW_HASH:
            CURRENT_HASH = NEW_HASH
            notepad.runMenuCommand('Macro', 'YOUR_MACRO_NAME')

FILE_TO_BE_MONITORED = notepad.getCurrentBufferID()
CURRENT_HASH = md5sum()
notepad.callback(on_buffer_activate, [NOTIFICATION.BUFFERACTIVATED])  
</code></pre>
<p dir="auto">You have to give the document, which is monitored, the focus and run the script. I how this does what you want it to be done.</p>
<p dir="auto">If you are running a localized version of npp, you need to replace Macro with the localized name.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63327</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63327</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 26 Feb 2021 21:17:09 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 14:12:48 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></p>
<blockquote>
<p dir="auto">It might be nice to know how often the external process writes to the file, because that might influence whether or not there’s enough time to safely…</p>
</blockquote>
<p dir="auto">Here’s a hint:</p>
<blockquote>
<p dir="auto">the txt is updated every song change</p>
</blockquote>
<p dir="auto">I’m envisioning a DJ type situation, including disco ball…roughly 3 minute songs.  Could be totally wrong, though!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63293</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63293</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 26 Feb 2021 14:12:48 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 14:09:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mirko-rossi" aria-label="Profile: Mirko-Rossi">@<bdi>Mirko-Rossi</bdi></a> said in <a href="/post/63288">Macro script when txt content changes</a>:</p>
<blockquote>
<p dir="auto">path to the file is “\SERVER\Disco_C\rds.txt”<br />
…on the local network LAN, not locally</p>
</blockquote>
<p dir="auto">Do you mean <code>\\SERVER\Disco_C\rds.txt</code> ?  (the forum treats <code>\\</code> as an escaped backslash, so only displayed one)</p>
<blockquote>
<p dir="auto">[macro contents…]<br />
it’s enough?</p>
</blockquote>
<p dir="auto">That is the macro code, yes, so that can be translated into equivalent PythonScript commands.</p>
<p dir="auto">But I think you still haven’t responded to when <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> asked,</p>
<blockquote>
<p dir="auto">What puzzles me a bit is the document monitor, when it is on, the document is read-only from the Npp point of view, isn’t it? If you are willing to explain in more detail what needs to be done, …</p>
</blockquote>
<p dir="auto">In case you didn’t understand, often times with document-monitoring turned on, the file is marked as read-only, so that Notepad++ cannot edit it while it’s being written to by some external process.  Otherwise, you get in the dangerous condition where both the external process and Notepad++ both try to write the file to disk at the same time.  It might be nice to know how often the external process writes to the file, because that might influence whether or not there’s enough time to safely run your commands and save the file before the next time that the external process writes to it.  (Then again, since you seem able to run the macro manually between refreshes, without adverse effects, it’s probably okay for the script, too.)</p>
<p dir="auto">The process you want, as I understand it:</p>
<ol>
<li>The Document Monitor plugin will be used to refresh the contents of the editor window periodically</li>
<li>You want to check the contents after such a refresh, and see if the contents have changed</li>
<li>If they have changed, run the Macro you listed (or the equivalent translation into Python Script commands), then save the file</li>
<li>Repeat <em>ad infinitum</em></li>
</ol>
<p dir="auto">Please answer about “read only” status, and please add any additional details not captured in my summary of the process.  After that, there will probably be enough for someone who understands <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a>’s SC_MOD_INSERTCHECK suggestion to implement a possible script.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63292</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63292</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 26 Feb 2021 14:09:17 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 14:02:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mirko-rossi" aria-label="Profile: Mirko-Rossi">@<bdi>Mirko-Rossi</bdi></a> said in <a href="/post/63288">Macro script when txt content changes</a>:</p>
<blockquote>
<p dir="auto">it’s enough?</p>
</blockquote>
<p dir="auto">Yes.  I was worried that it was going to be extremely long.  That one is of a moderate length so that it would not be too difficult for someone to reverse engineer what it does.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63291</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63291</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 26 Feb 2021 14:02:58 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 14:00:00 GMT]]></title><description><![CDATA[<p dir="auto">the path to the file is “\SERVER\Disco_C\rds.txt”<br />
…on the local network LAN, not locally</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63290</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63290</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Fri, 26 Feb 2021 14:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 13:56:23 GMT]]></title><description><![CDATA[<p dir="auto">&lt;Macro Key=“53” Shift=“yes” Alt=“yes” Ctrl=“yes” name=“intero”&gt;</p>
<p dir="auto">&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2302” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2453” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2180” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2451” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2326” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“1700” type=“3”/&gt;<br />
&lt;Action sParam=“-” lParam=“0” wParam=“0” message=“1601” type=“3”/&gt;<br />
&lt;Action sParam=“” lParam=“2” wParam=“0” message=“1625” type=“3”/&gt;<br />
&lt;Action sParam=“” lParam=“768” wParam=“0” message=“1702” type=“3”/&gt;<br />
&lt;Action sParam=“” lParam=“1” wParam=“0” message=“1701” type=“3”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2319” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2177” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2453” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2179” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2326” type=“0”/&gt;<br />
&lt;Action sParam=" " lParam=“0” wParam=“0” message=“2170” type=“1”/&gt;<br />
&lt;Action sParam=“-” lParam=“0” wParam=“0” message=“2170” type=“1”/&gt;<br />
&lt;Action sParam=" " lParam=“0” wParam=“0” message=“2170” type=“1”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2453” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2180” type=“0”/&gt;<br />
&lt;Action sParam=“” lParam=“0” wParam=“0” message=“2180” type=“0”/&gt;<br />
&lt;/Macro&gt;</p>
<p dir="auto">it’s enough?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63288</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63288</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Fri, 26 Feb 2021 13:56:23 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 13:52:23 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></p>
<p dir="auto">I think so. if the final result doesn’t change, you can use PythonScript completely.<br />
is there any way to give you the code of a macro? to then convert it with PythonScript</p>
<p dir="auto">thank you</p>
<p dir="auto">penso di si. se il risultato finale non cambia, si può usare completamente PythonScript.<br />
esiste un modo per darvi il codice di una macro? per poi convertirlo con PythonScript</p>
<p dir="auto">grazie</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63287</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63287</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Fri, 26 Feb 2021 13:52:23 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 13:16:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mirko-rossi" aria-label="Profile: Mirko-Rossi">@<bdi>Mirko-Rossi</bdi></a></p>
<p dir="auto">So if I’m putting the pieces of the above together correctly…</p>
<p dir="auto">The idea of using SC_MOD_INSERTCHECK, if it will truly work in this case, would probably require the PythonScript callback, and not the macro, to do the changing of the text?  At least that’s the only way I’ve ever used such a thing (via the <code>editor.changeInsertion()</code> function).</p>
<p dir="auto">So…probably publishing the macro here, and having its functionality converted to PythonScript code, is probably a good idea?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63285</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63285</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 26 Feb 2021 13:16:34 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 12:49:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/63258">Macro script when txt content changes</a>:</p>
<blockquote>
<p dir="auto">PythonScript</p>
</blockquote>
<p dir="auto">no problem, just get to the solution</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63279</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63279</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Fri, 26 Feb 2021 12:49:44 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Fri, 26 Feb 2021 12:46:46 GMT]]></title><description><![CDATA[<p dir="auto">thank you all for the quick responses and I apologize for my very rough english.</p>
<p dir="auto">The key combination “Ctrl + Shift + 9” simply calls a macro.</p>
<p dir="auto">The txt file is generated by an old radio automation and contains a simple text “Title - Interpreter”. Below is an example of the txt:<br />
“Regardless - Raye”</p>
<p dir="auto">I need to invert the title with the interpreter in order to allow the correct association of the cover albums that are requested and retrieved by the streaming players.<br />
I have created the macro and it works correctly; The whole process, up to the final acquisition of the cover, works … obviously by manually activating the macro.</p>
<p dir="auto">I used notepad ++, the macro and only the “Document monitor” plugin (which reads the file in real time).</p>
<p dir="auto">the txt is updated every song change and so I wanted to create a script, which calls the macro or the key combination, whenever the content of the file changes.</p>
<p dir="auto">thank you all<br />
Mirko</p>
<p dir="auto">grazie a tutti per le rapide risposte e mi scuso per il mio inglese molto approssimativo.</p>
<p dir="auto">La combinazione di tasti “Ctrl+Shift+9” richiama semplicemente una macro.</p>
<p dir="auto">Il file txt viene generato da una vecchia radio automation e contiene un semplice testo “Titolo - Interprete”. A seguire un  esempio del txt:<br />
“Regardless - Raye”</p>
<p dir="auto">Ho necessità di invertire il titolo con l’interprete, al fine di permettere l’associazione corretta delle cover album che vengono richieste e recuperate dai player streaming.<br />
Ho creato la macro e funziona correttamente; Tutto il processo, fino all’acquisizione finale della cover, funziona…ovviamente attivando manualmente la macro.</p>
<p dir="auto">ho usato notepad++, la macro e il solo plugin “Document monitor” (che legge in real time il file).</p>
<p dir="auto">il txt viene aggiornato ogni cambio canzone e quindi volevo creare uno script, che richiama la macro o la combinazione di tasti, ogni qual volta il contenuto del file cambia.</p>
<p dir="auto">grazie<br />
Mirko</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63278</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63278</guid><dc:creator><![CDATA[Mirko Rossi]]></dc:creator><pubDate>Fri, 26 Feb 2021 12:46:46 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Thu, 25 Feb 2021 20:48:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> said in <a href="/post/63258">Macro script when txt content changes</a>:</p>
<blockquote>
<p dir="auto">The section is not 100 correct in the Scintilla documentation, there is one small way and that is to intercept the SC_MOD_INSERTCHECK,<br />
then, and only here, the text may be changed.</p>
</blockquote>
<p dir="auto">Ah, nice.  And it’s a good thing you’re working on this, because all the experiments I had run have not panned out:</p>
<ul>
<li>the SCI_GETMODIFY only returns true if scintilla thinks the contents have changed; since the <strong>View &gt; Monitoring (tail -f)</strong> mode (and presumably the document monitor plugin) reload the contents in a way that scintilla knows about it, scintilla claims the contents haven’t changed… because they haven’t been edited since the last time scintilla has loaded it from disk</li>
<li>I thought of trying to hook into notepad++'s FILEBEFORELOAD, but that only gets triggered when opening a new file, not from <strong>File &gt; Reload From Disk</strong> or <strong>View &gt; Monitoring</strong> (and thus, presumably not from the plugin)</li>
<li>Per @Scott -Sumner’s quick-and-dirty <a href="https://community.notepad-plus-plus.org/post/32984">“which notification is it using” script</a>,. the only notification that gets triggered repeatedly in <strong>View &gt; Monitoring (tail -f)</strong> is the NPPM_BUFFERACTIVATED, which isn’t one I thought would be triggered at all.
<ul>
<li>If your idea doesn’t pan out, I would go down the BUFFERACTIVATED route, and store a crc32 of the contents in a Python <code>dict</code> (with the filepath as the key and the crc as the value); when the notification is triggered, it would recompute the crc and compare-to-stored: if crc32 changed, then run the other tasks and update the <code>dict</code>).  But yours will probably be better</li>
</ul>
</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/63262</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63262</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 25 Feb 2021 20:48:16 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Thu, 25 Feb 2021 17:47:41 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></p>
<p dir="auto">I never thought this day would come, but now that it has, I’ll take the opportunity to tell, er - only half the truth. :-D</p>
<p dir="auto">The section is not 100 correct in the Scintilla documentation, there is one small way and that is to intercept the SC_MOD_INSERTCHECK,<br />
then, and only here, the text may be changed.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mirko-rossi" aria-label="Profile: Mirko-Rossi">@<bdi>Mirko-Rossi</bdi></a><br />
What puzzles me a bit is the document monitor, when it is on, the document is read-only from the Npp point of view, isn’t it?<br />
If you are willing to explain in more detail what needs to be done, and if you are willing to use the PythonScript plugin, then I suppose we can find a solution for you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63258</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63258</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Thu, 25 Feb 2021 17:47:41 GMT</pubDate></item><item><title><![CDATA[Reply to Macro script when txt content changes on Thu, 25 Feb 2021 15:29:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mirko-rossi" aria-label="Profile: Mirko-Rossi">@<bdi>Mirko-Rossi</bdi></a> said in <a href="/post/63239">Macro script when txt content changes</a>:</p>
<blockquote>
<p dir="auto">Is there a way to automatically start a Notepad ++ macro, without the external use of powershell and the like?</p>
</blockquote>
<p dir="auto">It depends on your definition of “External”.  Notepad++ by itself cannot.</p>
<p dir="auto">However, if you accept a plugin like PythonScript, that <em>can</em> hook into events like <a href="https://www.scintilla.org/ScintillaDoc.html#SCN_MODIFIED" rel="nofollow ugc">SCN_MODIFIED</a>.  Unfortunately, per the docs for that one, the handler for that notification is not allowed to modify the document – and I am assuming your macro <em>is</em> going to modify the document.</p>
<p dir="auto">On the other hand, you might be able hook into another message, and manually check <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_GETMODIFY" rel="nofollow ugc">SCI_GETMODIFY</a> using <code>editor.getModify()</code>.</p>
<p dir="auto">I don’t have time right now to experiment and come up with a solution, but there are other PythonScript users here who might take my ideas (or their own) and develop a solution before I get around to it.  But if no one else has something workable by the time I have free time, I will see what I can do.</p>
<blockquote>
<p dir="auto">execute key combination “Ctrl + Shift + 9”</p>
</blockquote>
<p dir="auto">oh, right; I am not 100% sure, but I cannot think of a PythonScript hook that will call a specific keyboard shortcut.  But there are commands that can access any of the Notepad++ menu entries that keystrokes are usually mapped to.  They keystroke combo isn’t mapped by default on my setup, so I need to ask: What command is <code>Ctrl+Shift+9</code> mapped to on your setup?  Is it a standard command (whether from normal Notepad++ menus or editor commands?  Or a specific plugin’s menu entry? or a Run-menu entry?  (Please note, if it’s an externally-handled keystroke, like an AutoHotKey script, then the PythonScript interface probably cannot call it directly; however, there are ways using standard Python libraries in a PythonScript to send keystrokes, but that will be essential to know before we can help you further)</p>
<p dir="auto">So, answer the question about <code>Ctrl+Shift+9</code>, and then please be patient while waiting for me or one of the PythonScript experts to have a chance to investigate and chime in.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63249</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63249</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 25 Feb 2021 15:29:36 GMT</pubDate></item></channel></rss>