-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
97 lines (72 loc) · 2.68 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'use strict';
// install node : https://nodejs.org/en/
// sudo npm install -g
// npm install electron-prebuilt -g
// in directory:
// npm install serialport
// npm install midi
//
// npm install midi --runtime=electron --target=2.0.1 --disturl=https://atom.io/download/atom-shell --abi=53
//electron-packager . --platform=darwin --arch=x64 --overwrite --icon=misbkit.icns
//electron-packager . --platform=darwin --arch=x64 --overwrite --icon=misbkit.icns --prune=true --out=/Users/Didier/Documents/Dev/_MisBKIT_releases
// git test....
//cecile path: /Users/Cecile ?
//didier path: /Users/Didier/Documents/
const electron = require('electron');
var fs = require('fs');
const app = electron.app; // Module to control application life.
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
var ipc = require("electron").ipcMain;
var mainWindow = null;
var appPath = "";
app.on('window-all-closed', function() {
//if (process.platform != 'darwin') {
app.quit();
//}
});
app.on('ready', function() {
console.log("versions:",process.versions); //v5.10.0
//console.log("version electron:",process.versions['electron']); //v5.10.0
//console.log("version chrome:",process.versions['chrome']); //v5.10.0
//mainWindow = new BrowserWindow({width: 1280, height: 760});
mainWindow = new BrowserWindow({width: 1520, height: 760});
mainWindow.loadURL('file://' + __dirname + '/index.html');
//mainWindow.loadURL('file://' + __dirname + '/index_alex.html');
//mainWindow.show();
////////// TO PUT IN COMMENT WHEN EXPORTING
appPath = app.getAppPath();
if(appPath.includes("/Didier/")||appPath.includes("/cecilebucher/"))
mainWindow.webContents.openDevTools();
mainWindow.on('close', function() {
mainWindow.webContents.send("close");
console.log(" close ...");
});
mainWindow.on('closed', function() {
console.log(" ... closed");
mainWindow = null;
});
console.log("USERDATA:",app.getPath('userData'));
console.log("DESKTOP:",app.getPath('desktop'));
//console.log("DOCUMENT:",app.getPath('document'));
console.log("APPPATH:",app.getAppPath());
console.log("LOCALES:",app.getLocale());
});
ipc.on('devTools', function (event,arg) {
mainWindow.webContents.openDevTools();
});
ipc.on('message', function (event,arg) {
console.log("message:evt:",arg);
});
ipc.on('console', function (event,arg) {
console.log("console:");
mainWindow.webContents.openDevTools();
});
ipc.on('capture',function (event,arg) {
console.log("capture:",arg);
mainWindow.capturePage(function(img){
var png = img.toPng();
fs.writeFile( __dirname +"/test.png",png,function(err){
console.log("capture error:",err);
})
})
});