Macro woes
-
After recording a macro to replace several lines of text, I noticed on playing it back some replacements had been made and some had skipped and were unchanged. To isolate the problem, I manually created a new macro containing only the step that was skipped in the larger macro. Still no go. Only running the macro a second time made it work, or doubling the lines in the same macro.
This is the set of actions that show this behaviour;
<Action type=“0” message=“2178” wParam=“0” lParam=“0” sParam=“” />
<Action type=“2” message=“0” wParam=“42002” lParam=“0” sParam=“” />
<Action type=“3” message=“1700” wParam=“0” lParam=“0” sParam=“” />
<Action type=“3” message=“1601” wParam=“0” lParam=“0” sParam=‘loadplugin(“\192.168.254.10\core\avisynth\plugins\ffms2.dll”)’ />
<Action type=“3” message=“1625” wParam=“0” lParam=“0” sParam=“” />
<Action type=“3” message=“1602” wParam=“0” lParam=“0” sParam=‘Import(“\phobos\c$\core\engine\avisynth\plugins_library\ffindex\v_2_23_1\loader.avs”)’ />
<Action type=“3” message=“1702” wParam=“0” lParam=“768” sParam=“” />
<Action type=“3” message=“1701” wParam=“0” lParam=“1608” sParam=“” />As said, only when I invoke this one 2 times it will work. No clue what may cause this. Is there anyone that can shed some light on this problem? (Using latest version)
Thanks
Tim
-
@Tim-Koeleman said in Macro woes:
Is there anyone that can shed some light on this problem?
The macro is behaving exactly like the Replace dialog.
If I start with my cursor on line 1, if I hit Replace, it has nothing actively matched, so then moves forward and highlights the first instance of the text (line2) without replacing anything. Subsequent Replace clicks will actually do the replacements and move to the next match.My modus operendi in search-and-replace is to use Find Next to highlight the first instance, then Replace thereafter. In a recorded macro, that would have one time through the main setup with
message="1701"
set tolparam='1'
for Find Next, and the next time through it would be1608
for Replace.References:
- https://npp-user-manual.org/docs/config-files/#macros => official docs, describes the action type#'s
- https://npp-user-manual.org/docs/searching/#searching-actions-when-recorded-as-macros => official docs, describes the search-and-replace (type=“3”) sequences in detail
-
@PeterJones thanks a lot! That explains it.