Last active
July 1, 2016 02:00
-
-
Save zakuroishikuro/974369ea2d6f41ef7927 to your computer and use it in GitHub Desktop.
Google先生も知らないJXAのプライベートメソッド ref: http://qiita.com/zakuroishikuro/items/a7def965f49a2ab55be4
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 app = Application("Finder"); | |
var win = app.windows[0]; | |
Automation.getDisplayString(win) | |
//=> "Application(\"Finder\").windows.at(0)" | |
>> Automation.log(win) | |
//[object ObjectSpecifier] | |
//=> undefined |
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 term = Application("Terminal"); | |
reveal(term); |
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 term = Application("Terminal"); | |
reveal(term); |
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
reveal(ObjC); |
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 qt = Application("QuickTime Player"); | |
qt.activate(); | |
qt.quit(); | |
qt.launch(); |
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 qt = Application("QuickTime Player"); | |
// この時点で起動してなかったら起動される | |
qt.activate(); //フォーカスを移す | |
qt.quit(); //終了 | |
qt.launch(); //起動 |
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
str = "hello" | |
// launch new TextEdit window | |
editor = Application("TextEdit"); | |
doc = editor.Document().make(); | |
// set text | |
doc.text = str; | |
//=> "hello" | |
doc.text.set(str); //same above | |
//=> true | |
doc.setProperty("text", str); //same above | |
//=> true | |
// get text | |
doc.text(); | |
//=> "hello" | |
doc.text.get(); //same above | |
//=> "hello" | |
doc.getProperty("text").get(); //same above | |
//=> "hello" |
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
// set text | |
doc["text"] = "hi" | |
// "hello" | |
// get text | |
doc["text"]() | |
// "hi" |
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 app = Application("Finder"); | |
var win = app.windows[0]; | |
Automation.getDisplayString(win) | |
//=> "Application(\"Finder\").windows.at(0)" | |
>> Automation.log(win) | |
//[object ObjectSpecifier] | |
//=> undefined |
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 finder = Application("Finder"); | |
ObjectSpecifier.hasInstance(finder); | |
//=> true | |
ObjectSpecifier.hasInstance("foo"); | |
//=> false | |
ObjectSpecifier.classOf(finder); | |
//=> "application"; | |
ObjectSpecifier.classOf("foo"); | |
//=> undefined |
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 itunes = Application("iTunes"); | |
itunes.properties() | |
/*=> { | |
"class": "application", | |
"name": "iTunes", | |
"playerState": "stopped", | |
"version": "12.1", | |
"frontmost": false, | |
"soundVolume": 100, | |
"mute": false, | |
"visualsEnabled": false, | |
"fullScreen": false, | |
"visualSize": "large", | |
"eqEnabled": false, | |
"fixedIndexing": false, | |
"playerPosition": null, | |
"converting": false, | |
"currentStreamTitle": null, | |
"currentStreamURL": null, | |
"airplayEnabled": false, | |
"currentAirPlayDevices": [ | |
null | |
], | |
"iadIdentifier": null | |
}*/ |
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 finder = Application("Finder"); | |
Object.keys(finder); //=> [] | |
Object.getOwnPropertyNames(finder) //=> ["__private__"] | |
finder.hasOwnProperty("a"); //=> true | |
finder.hasOwnProperty("ab"); //=> true | |
finder.hasOwnProperty("abc"); //=> true //なわけないじゃん |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment