title: electron prevent multiple instance with middle click
body: <p>I am tying to make single instance <a href="https://github.com/electron" rel="nofollow noreferrer">Electron</a> application.
  I am using <a href="https://github.com/electron/electron/blob/v0.36.10/docs/api/app.md#appmakesingleinstancecallback" rel="nofollow noreferrer">app.makeSingleInstance</a> , see my sample below.</p>
  
  <p><strong>SingleInstance issue with middle click :</strong></p>
  
  <ol>
  <li>Single Instance works if I click on app.exe 2nd time</li>
  <li>It does not work if I middle click on a link inside my app</li>
  </ol>
  
  <p><strong>What I need:</strong></p>
  
  <ol>
  <li>Make electron app singleInstance and ensure it remaisn single instance even with middle click.</li>
  <li>I dont want to compeltey disable middle click in my app as at some places, I have a use case for them on non-link items</li>
  </ol>
  
  <p><strong>How to reproduce:</strong></p>
  
  <ol>
  <li>use repo: <a href="https://github.com/electron/electron-quick-start" rel="nofollow noreferrer">https://github.com/electron/electron-quick-start</a></li>
  <li>replace existing with my <code>index.html</code> and <code>main.js</code> , see below</li>
  <li><code>npm install</code> and then <code>npm start</code></li>
  </ol>
  
  <p><strong>index.html:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;&lt;meta charset="UTF-8"&gt;&lt;title&gt;Hello World!&lt;/title&gt;&lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;app.makeSingleInstance()&lt;/h1&gt;
      &lt;a href="$"&gt;Middle Click on it&lt;/a&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>main.js</strong></p>
  
  <pre><code>const electron = require('electron')
  const app = electron.app
  const BrowserWindow = electron.BrowserWindow
  const path = require('path')
  const url = require('url')
  let mainWindow
  const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) =&gt; {
    if (myWindow) {
      if (myWindow.isMinimized()) myWindow.restore()
      myWindow.focus()
    }
  })
  if (isSecondInstance) {
    app.quit()
  }
  function createWindow () {
    mainWindow = new BrowserWindow({width: 800, height: 600})
    mainWindow.loadURL(url.format({
      pathname: path.join(__dirname, 'index.html'),
      protocol: 'file:',
      slashes: true
    }))
    mainWindow.on('closed', function () {
      mainWindow = null
    })
  }
  app.on('ready', createWindow)
  app.on('window-all-closed', function () {
    if (process.platform !== 'darwin') {
      app.quit()
    }
  })
  app.on('activate', function () {
    if (mainWindow === null) {
      createWindow()
    }
  })
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/p6cZJ.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p6cZJ.gif" alt="enter image description here"></a></p>