Created
May 19, 2016 16:27
-
-
Save s-shin/91108fb0b4d0d904b0bab7c5900dc46c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = { | |
map: function(arr, fn) { | |
var r = []; | |
for (var i = 0, len = arr.length; i < len; i++) { | |
r.push(fn(arr[i])); | |
} | |
return r; | |
}, | |
filter: function(arr, fn) { | |
var r = []; | |
for (var i = 0, len = arr.length; i < len; i++) { | |
if (fn(arr[i])) { | |
r.push(arr[i]); | |
} | |
} | |
return r; | |
} | |
}; | |
//--- | |
function dumpProcessName(processes) { | |
return _.map(processes, function(proc) { | |
return proc.name(); | |
}); | |
} | |
function dumpProcessInfo(processes) { | |
return _.map(processes, function(proc) { | |
var info = {}; | |
["name", "shortName", "visible", "backgroundOnly"].forEach(function(prop) { | |
info[prop] = proc[prop](); | |
}); | |
return info; | |
}); | |
} | |
//--- | |
var app = Application.currentApplication(); | |
app.includeStandardAdditions = true; | |
var se = Application("System Events"); | |
var visibleProcs = _.filter(se.processes, function(proc) { | |
return proc.visible(); | |
}); | |
dumpProcessName(visibleProcs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment