title: Electron - Processing Input
body: <p>I recently started to get my feet wet with Electron. I really like the principles behind it but I find it a little confusing to do some things.</p>
  
  <p>For example, how do you process user input? I've an main.js and a BrowserWindow pointing to a local html file (containing some user settings with input field). </p>
  
  <p>How do I access this data when the HTML form is submitted (to either the same file or another one)?</p>
  
  <p>main.js</p>
  
  <pre><code>    const {app, BrowserWindow} = require('electron')
  let win
  
  function createWindow () {
    win = new BrowserWindow({width: 800, height: 600})
    win.loadURL('file://' + __dirname + '/index.html')
  
    // Emitted when the window is closed.
    win.on('closed', () =&gt; {
      win = null
    })
  
    // Open the DevTools.
    // win.webContents.openDevTools()
  }
  
  app.on('window-all-closed', () =&gt; {
    if (process.platform !== 'darwin') {
      app.quit()
    }
  })
  
  app.on('activate', () =&gt; {
    if (win === null) {
      createWindow()
    }
  })
  
  // In this file you can include the rest of your app's specific main process
  // code. You can also put them in separate files and require them here.
  
  //Start the main window
  app.on('ready', createWindow)
  </code></pre>
  
  <p>index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="" method="post"&gt;
          &lt;input type="text" name="test-1"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>