Create a Msg box in Notepad++ Macros

  • I have a macro that finds 's and replaces few strings. Below is the code. What I want Notepad++ to do is to show a message box if it doesn’t find the string “_last”. How to achieve this?

            <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
        <Action type="3" message="1601" wParam="0" lParam="0" sParam="_last" />
        <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
        <Action type="3" message="1702" wParam="0" lParam="1024" sParam="" />
        <Action type="3" message="1701" wParam="0" lParam="1" sParam="" />

    PS: I have found a very old post where it says that an older version of notepad++ shows a pop-up window on each step of a macro.

  • @Anwesh-Gangula

    The short answer is “You can’t”.

    However, if you have the Find window open when you run the macro, when text is not found, it will show it in red at the bottom of the window, e.g. Find: Can’t find the text “_last”.

    Perhaps the NppExec plugin could be of assistance here, although I am not familiar enough with it to know (maybe someone else?). A quick look at its docs had nothing leap out at me about message box functionality…

    If you will consider a scripting solution to your problem, you will often find a “message box” function there. For example, in Pythonscript there is notepad.messageBox():

    Notepad.messageBox(message[, title[, flags]]) → MessageBoxFlags 
    Displays a message box with the given message and title.
    Flags can be 0 for a standard ‘OK’ message box, or a combination of MESSAGEBOXFLAGS. title is “Python Script for Notepad++” by default, and flags is 0 by default.
    A RESULTxxxx member of MESSAGEBOXFLAGS as to which button was pressed. 

    Thus you could script the solution to your entire problem, and not use macros at all…

  • For text processing, I use the jN plug-in for Notepad ++.
    But it allows you to process text in the editor using JavaScript.
    For example, cut lines longer than 300 characters:

    function InputBox(psTxt, psCapt, psVal) {
    var rv = psVal;
    var so = new ActiveXObject(“MSScriptControl.ScriptControl”);
    so.Language = ‘VBScript’;
    var vCode =
    ’ Function getInputNumber() \n’+
    ’ val = InputBox("’+psTxt+’","’+psCapt+’","’+psVal+’") \n’+
    ’ getInputNumber = val \n’+
    ‘End Function \n’;
    rv = parseInt(so.Run(“getInputNumber”));
    return rv;

    // удаляем строки которые длинее n символов
    function rowsOverLengthRemote(psOper) {
    var vOLen = 300;
    if(!psOper) { psOper = 1; }
    vOLen = InputBox(‘Input length’,“For very long rows”,vOLen);
    vOLen = parseInt(vOLen);
    if(vOLen <= 40) {
    // debugger;
    // return;
    var vTextAll = Editor.currentView.text;
    var vArr = vTextAll.split(’\n’);
    var vTextNeed = ‘’;
    var vLine = ‘’;
    for(var i = 0; i<vArr.length; i++) {
    vLine = vArr[i];
    if(vLine.length <= vOLen) {
    vTextNeed = vTextNeed + ‘\n’ + vLine;
    } else {
    if(psOper == 2) {
    message(“Cut string N: “+i+’ length” ‘+vLine.length+’ >> ‘+vLine.substring(0, 500));
    vTextNeed = vTextNeed + ‘\n’ + vLine.substring(0,vOLen);
    } else if(psOper == 1) {
    message("Kill string N: "+i+’ length” ‘+vLine.length+’ >> '+vLine.substring(0, 500));

    Editor.currentView.text = vTextNeed;    


    var myKillVeryLengthRows = {
    text: “Удалить строки длинее N \tCtrl+Shift+K”,
    ctrl: true, shift: true, alt: false,
    key: 0x4B, // “K key”
    cmd: rowsOverLengthRemote


    function rowsOverLengthCut() { rowsOverLengthRemote(2); }
    var myCutVeryLengthRows = {
    text: "Обрезать строки длинее N ",
    cmd: rowsOverLengthCut

    It also has the ability to display messages:

    • JavaScript alert (‘Message’)
    • status (‘Message’); - in the status bar N ++
    • message (“Message”) - output to the man-made message box (my development):

Log in to reply