Skip to content

Instantly share code, notes, and snippets.

@bobelev
Created June 6, 2014 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobelev/473f29ba82e938b14c90 to your computer and use it in GitHub Desktop.
Save bobelev/473f29ba82e938b14c90 to your computer and use it in GitHub Desktop.
App.byTitle = function(title) {
var apps = this.runningApps();
for (i = 0; i < apps.length; i++) {
var app = apps[i];
if (app.title() === title) {
app.show();
return app;
}
}
}
function testWindow(title){
var app = App.byTitle(title);
if (app){
api.alert(app.title())
api.alert(Window.focusedWindow().title())
api.alert(app.allWindows().indexOf(Window.focusedWindow()))
api.alert(_.indexOf(Window.allWindows(), Window.focusedWindow()))
api.alert(Window.focusedWindow() === Window.focusedWindow())
}
}
api.bind('c', mash, function(){testWindow('Safari')})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment