質問編集履歴

1

コードの修正

2017/10/27 09:30

投稿

kysk
kysk

スコア10

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ###前提・実現したいこと
2
2
 
3
- ・デスクトップのキャプチャを定期的に撮るelectronアプリを作成したい。
3
+ ・デスクトップのキャプチャを数秒おきに撮影するelectronアプリを作成したい。
4
4
 
5
5
  →キャプチャの撮影はelectronAPIの「desktopCapturer」で実現出来ました。
6
6
 
@@ -24,31 +24,41 @@
24
24
 
25
25
  const desktopCapturer = require('electron').desktopCapturer;
26
26
 
27
- //キャプチャを撮る
27
+ var capture=function(){
28
28
 
29
- desktopCapturer.getSources({
29
+ //キャプチャを撮る
30
30
 
31
- types: ['screen'],
31
+ desktopCapturer.getSources({
32
32
 
33
- thumbnailSize: { width: 1000, height: 1000 }
33
+ types: ['screen'],
34
34
 
35
- }, function(error, sources){
35
+ thumbnailSize: { width: 1000, height: 1000 }
36
36
 
37
- for (var i = 0; i < sources.length; ++i) {
37
+ }, function(error, sources){
38
38
 
39
- if (sources[i].name === 'Entire screen') {
39
+ for (var i = 0; i < sources.length; ++i) {
40
40
 
41
- //キャプチャを保存
41
+ if (sources[i].name === 'Entire screen') {
42
42
 
43
- fs.writeFile("保存先のファイルを指定", sources[i].thumbnail.toPng(), function() {
43
+ //キャプチャを保存
44
44
 
45
- });
45
+ fs.writeFile("保存先のファイルを指定", sources[i].thumbnail.toPng(), function() {
46
46
 
47
- }
47
+ setTimeout(function() {
48
48
 
49
- }
49
+ capture();
50
50
 
51
+ }, 2*1000);
52
+
51
- });
53
+ });
54
+
55
+ }
56
+
57
+ }
58
+
59
+ });
60
+
61
+ }
52
62
 
53
63
  ```
54
64