Search code examples
emeditor

copy search results of emeditor macro output to clipboard and send it to potplayer


i am using the emeditor macro code ExtractLinesContain.jsee (downloaded from emeditor macro library) to search text file for certain text. this code is perfectly working. it is pasting the results to new file. but i want the result to be copied to clipboard and also should be sent to potplayer. three modifications are required in the above code.

  1. multiple texts are entered using separator '|'. i want to use ',' in place of '|'.
  2. search results to be automatically copied to search results.
  3. the following code to be appeneded to the above macro code. editor.ExecuteCommandByID(4445); WshShell = new ActiveXObject( "WScript.Shell" );

WshShell.Run ( "PotPlayerMini64.exe /clipboard" );

please help me.


Solution

  • The ExtractLinesMulti.jsee macro is very old, and I rewrote the macro using the Batch Find/Extract feature of EmEditor instead. Here is the macro that extracts lines that do contain any of the specified multiple strings separated by |:

    if( !editor.EnableTab ){ 
       editor.EnableTab = true; 
       alert( "Please run this macro again." ); 
       Quit(); 
    }
    
    sFind = prompt( "This macro extracts lines that do contain any of the specified multiple strings separated by |:", "" );
    if( sFind == "" ){
        Quit();
    }
    
    var sArr = sFind.split("|");
    batch_list = editor.filters;
    for( i = 0; i < sArr.length; ++i ) {
        batch_list.AddFind(sArr[i],eeFindReplaceCase,0);
    }
    document.selection.BatchFind(batch_list, eeFindExtract | eeFindLineOnly,0);
    
    document.selection.SelectAll();  // select all text
    document.selection.Copy(eeCopyUnicode);  // copy the seleciton to the Clipboard
    

    You can add any code you want to the end of this macro.

    References: http://www.emeditor.org/en/macro_selection_batch_find.html