0

I have a .js that selects some texts and starts a C# program parsing the selected text into Main() as arguments. I want to know is there anyway that .js can parse text into an existing instance of a Winform program. For example, display the selected text into a rich text box.

This is my current implementation:

<script type="text/javascript">

    function getSelectionText(input) {
        var text = "";
        if (input.getSelection) 
        {
            text = input.getSelection().toString();
        } 
        else if (input.document.selection && input.document.selection.type != "Control") 
        {
            text = input.document.selection.createRange().text;
        }
        return text;
    }

    var extInput = external.menuArguments;

    var selected = getSelectionText(extInput);

    var oShell = new ActiveXObject("Shell.Application");

    var commandtoRun = "MyFileLoc"; 

    oShell.ShellExecute(commandtoRun,"\""+selected+"\"","","open","1");

</script>
  • Take a look at this [link](http://stackoverflow.com/questions/9315814/how-to-pass-a-command-line-argument-to-a-c-sharp-windows-forms-application-while) – Ponas Justas Apr 29 '16 at 16:00
  • Here is some more information that might be useful [link](http://web.archive.org/web/20080506103924/http://www.flawlesscode.com/post/2008/02/Enforcing-single-instance-with-argument-passing.aspx). This code sampe using a mutex is forcing a single application instance and using namedpipes is passing the new command line arguments to already running application. – Ponas Justas Apr 29 '16 at 16:13

0 Answers0