{"id":4760,"date":"2016-10-02T14:54:17","date_gmt":"2016-10-02T05:54:17","guid":{"rendered":"https:\/\/peta.okechan.net\/blog\/?p=4760"},"modified":"2016-10-02T21:11:00","modified_gmt":"2016-10-02T12:11:00","slug":"appscript-python%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%81%8csheepshaver%e3%81%ab%e5%af%be%e3%81%97%e3%81%a6%e5%8b%95%e4%bd%9c%e3%81%97%e3%81%aa%e3%81%84%e4%bb%b6%e3%81%ab%e3%81%a4%e3%81%84","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/4760","title":{"rendered":"appscript Python\u30d1\u30c3\u30b1\u30fc\u30b8\u304cSheepShaver\u306b\u5bfe\u3057\u3066\u52d5\u4f5c\u3057\u306a\u3044\u4ef6\u306b\u3064\u3044\u3066\u8abf\u3079\u305f"},"content":{"rendered":"<p>\u5c11\u3057\u524d\u306b<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/967\">\u3053\u3061\u3089\uff08Mac\u3067\u91cd\u3044\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5287\u7684\u306b\u8efd\u304f\u3059\u308bPython\u30b9\u30af\u30ea\u30d7\u30c8\uff09<\/a>\u306e\u8a18\u4e8b\u306b\u3064\u3044\u3066\u30b3\u30e1\u30f3\u30c8\u3092\u3044\u305f\u3060\u304d\u307e\u3057\u3066\u3001\u79c1\u304c\u66f8\u3044\u305fPython\u30b9\u30af\u30ea\u30d7\u30c8\u304cSheepShaver\u3068\u3044\u3046\u30a2\u30d7\u30ea\u306b\u5bfe\u3057\u3066\u306f\u52d5\u4f5c\u3057\u306a\u3044\u3088\u3001\u3068\u3044\u3046\u30b3\u30e1\u30f3\u30c8\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u6570\u5e74Mac\u3092\u4f7f\u3063\u3066\u304a\u3089\u305a\u691c\u8a3c\u7528\u306e\u74b0\u5883\u304c\u3059\u3050\u306b\u7528\u610f\u3067\u304d\u306a\u3044\u72b6\u614b\u3060\u3063\u305f\u306e\u3067\u7d50\u69cb\u9069\u5f53\u306b\u8fd4\u7b54\u3057\u3066\u3057\u307e\u3063\u3066\u307e\u3057\u305f\u3002<br \/>\n\u6700\u8fd1\u5c11\u3057\u6687\u306b\u306a\u3063\u305f\u306e\u3067\u74b0\u5883\u3092\u7528\u610f\u3057\u5c11\u3057\u6df1\u304f\u554f\u984c\u3092\u8abf\u67fb\u3057\u305f\u7d50\u679c\u3001\u539f\u56e0\u304c\u5224\u660e\u3057\u305f\u306e\u3067\u8efd\u304f\u30e1\u30e2\u7a0b\u5ea6\u306b\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h3>Carbon API\u306eGetProcessForPID\u3068GetProcessBundleLocation\u306b\u3064\u3044\u3066<\/h3>\n<p>\u30b3\u30e1\u30f3\u30c8\u3078\u306e\u8fd4\u4fe1\u3067\u3001appscript\u30d1\u30c3\u30b1\u30fc\u30b8\u304b\u3089\u6700\u7d42\u7684\u306b\u547c\u3070\u308c\u308b\u5f53\u8a72\u95a2\u6570\u304c\u3046\u307e\u304f\u52d5\u4f5c\u3057\u3066\u306a\u3044\u306e\u3067\u306f\u306a\u3044\u304b\u3001\u3068\u66f8\u3044\u3066\u3044\u305f\u306e\u3067\u305d\u306e\u4e88\u60f3\u304c\u30a2\u30bf\u30ea\u306a\u306e\u304b\u30cf\u30ba\u30ec\u306a\u306e\u304b\u3092\u307e\u305a\u8abf\u3079\u307e\u3057\u305f\u3002<br \/>\n\u7d50\u679c\u3092\u5148\u306b\u8ff0\u3079\u308b\u3068\u3001\u5b8c\u5168\u306b\u30cf\u30ba\u30ec\u3067\u3057\u305f\u3002\uff08\u304a\u6065\u305a\u304b\u3057\u3044\u2026\uff09<\/p>\n<p>\u78ba\u8a8d\u306e\u305f\u3081\u306bC\u8a00\u8a9e\u3067\u30b6\u30c3\u3068\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u5b9f\u884c\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001SheepShaver\u3067\u3082\u666e\u901a\u306b\u30d7\u30ed\u30bb\u30b9ID\u304b\u3089\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d0\u30f3\u30c9\u30eb\u306e\u30d1\u30b9\u304c\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3061\u306a\u307f\u306b\u691c\u8a3c\u74b0\u5883\u306eOS\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f10.11.6 El Capitan\u3067\u3059\u304c\u3001\u5f53\u8a72\u95a2\u6570\u306f\u73fe\u5728\u3067\u306f\u975e\u63a8\u5968\u306b\u306a\u3063\u3066\u308b\u3088\u3046\u3067\u3059\uff08\u30b3\u30e1\u30f3\u30c8\u53c2\u7167\uff09\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/\r\n\/\/  main.c\r\n\/\/  GetBundleLocationFromPID\r\n\/\/\r\n\/\/  Created by peta on 2016\/10\/02.\r\n\/\/  Copyright \u00a9 2016\u5e74 peta. All rights reserved.\r\n\/\/\r\n\r\n#include &lt;stdio.h&gt;\r\n#include &lt;Carbon\/Carbon.h&gt;\r\n\r\nint main(int argc, const char * argv&#x5B;]) {\r\n    if (argc != 2) {\r\n        printf(&quot;Usage: %s PID\\n&quot;, argv&#x5B;0]);\r\n        return 1;\r\n    }\r\n\r\n    int pid;\r\n    pid = atoi(argv&#x5B;1]);\r\n    if (pid &lt;= 0) {\r\n        printf(&quot;The PID is invalid.\\n&quot;);\r\n        return 1;\r\n    }\r\n\r\n    OSStatus stat;\r\n    ProcessSerialNumber psn;\r\n    stat = GetProcessForPID(pid, &amp;psn); \/\/ 10.9 \u304b\u3089 deprecated\r\n    if (stat != errSecSuccess) {\r\n        printf(&quot;Failed calling GetProcessForPID().\\n&quot;);\r\n        return 1;\r\n    }\r\n\r\n    FSRef loc;\r\n    stat = GetProcessBundleLocation(&amp;psn, &amp;loc); \/\/ 10.9 \u304b\u3089 deprecated\r\n    if (stat != errSecSuccess) {\r\n        printf(&quot;Failed calling GetProcessBundleLocation().\\n&quot;);\r\n        return 1;\r\n    }\r\n\r\n    UInt8 path&#x5B;PATH_MAX];\r\n    stat = FSRefMakePath(&amp;loc, path, sizeof(path)); \/\/ 10.8 \u304b\u3089 deprecated\r\n    if (stat != errSecSuccess) {\r\n        printf(&quot;Failed calling FSRefMakePath().\\n&quot;);\r\n        return 1;\r\n    }\r\n    \r\n    \/*\r\n    CFStringRef str = CFStringCreateWithBytes(kCFAllocatorDefault, path, sizeof(path), kCFStringEncodingUTF16, false);\r\n    CFIndex len = CFStringGetLength(str);\r\n    CFIndex max = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF16) + 1;\r\n    char *cstr = (char*)malloc(sizeof(char) * max);\r\n    if (!CFStringGetCString(str, cstr, max, kCFStringEncodingUTF16)) {\r\n        free(cstr);\r\n        printf(&quot;Failed calling CFStringGetCString().\\n&quot;);\r\n        return 1;\r\n    }\r\n    \r\n    printf(&quot;%s\\n&quot;, cstr);\r\n    free(cstr);\r\n    *\/\r\n    \r\n    printf(&quot;%s\\n&quot;, path);\r\n    return 0;\r\n}<\/pre>\n<p>\u203b\u521d\u51fa\u306e\u30bd\u30fc\u30b9\u3067\u306fFSRefMakePath\u3067\u5f97\u3089\u308c\u305f\u30d0\u30a4\u30c8\u5217path\uff08UTF8\u3067\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305f\u30c7\u30fc\u30bf\uff09\u3092UTF16\u3068\u3057\u3066\u30c7\u30b3\u30fc\u30c9\u3057\u518d\u5ea6UTF16\u3068\u3057\u3066\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u3066C\u8a00\u8a9e\u5f62\u5f0f\u306e\u6587\u5b57\u5217\u306b\u5909\u63db\u3059\u308b\u3068\u3044\u3046\u8b0e\u306a\u51e6\u7406\u3092\u884c\u3063\u3066\u307e\u3057\u305f\u304c\uff08\u8907\u6570\u884c\u30b3\u30e1\u30f3\u30c8\u306e\u90e8\u5206\uff09\u3001\u5143\u306e\u30c7\u30fc\u30bf\u304cUTF8\u306a\u3089\u30bf\u30fc\u30df\u30ca\u30eb.app\u3067\u3082\u666e\u901a\u306b\u8868\u793a\u3067\u304d\u308b\u3060\u308d\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u7279\u306b\u5909\u63db\u305b\u305a\u306bprintf\u306b\u6e21\u3059\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h3>\u3061\u3087\u3063\u3068appscript\u306e\u30bd\u30fc\u30b9\u3092\u8aad\u3093\u3067\u307f\u305f<\/h3>\n<p>\u4e88\u60f3\u304c\u30cf\u30ba\u30ec\u305f\u306e\u3067\u89b3\u5ff5\u3057\u3066\u5c11\u3057\u6df1\u304f\u30bd\u30fc\u30b9\u3092\u8aad\u3093\u3067\u307f\u308b\u3053\u3068\u306b\u3002<br \/>\n<a href=\"https:\/\/github.com\/mattneub\/appscript\/tree\/master\/py-appscript\/tags\/py-appscript-1.0.0\/appscript_2x\/lib\">appscript\/py-appscript\/tags\/py-appscript-1.0.0\/appscript_2x\/lib at master \u00b7 mattneub\/appscript \u00b7 GitHub<\/a><\/p>\n<p>\u8d85\u3056\u3063\u304f\u308a\u8a00\u3046\u3068appscript\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u5bfe\u3059\u308b\u6700\u521d\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u7b49\u306e\u547c\u3073\u51fa\u3057\u304c\u3042\u3063\u305f\u969b\u306b\u305d\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u3069\u3046\u3044\u3063\u305f\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30de\u30f3\u30c9\u7b49\u3092\u6301\u3063\u3066\u3044\u308b\u306e\u304b\u52d5\u7684\u306b\u8abf\u3079\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u30012\u56de\u76ee\u4ee5\u964d\u306f\u305d\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u4f7f\u3046\uff08\u3042\u304f\u307e\u3067\u3082\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3084\u30b3\u30de\u30f3\u30c9\u540d\u7b49\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3060\u3051\u3067\u591a\u5206\u7d50\u679c\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u306a\u3044\uff09\u3088\u3046\u306a\u4ed5\u7d44\u307f\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u3041\u4eca\u56de\u306e\u4ef6\u306b\u3064\u3044\u3066\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3068\u3044\u3046\u70b9\u306f\u95a2\u4fc2\u306a\u3044\u3093\u3067\u3059\u304c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3084\u30b3\u30de\u30f3\u30c9\u540d\u7b49\u3092\u52d5\u7684\u306b\u8abf\u3079\u308b\u3068\u3044\u3046\u70b9\u304c\u95a2\u4fc2\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>appscript\u3067\u306f\u52d5\u7684\u306b\u8abf\u3079\u308b\u305f\u3081\u306b\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5bfe\u3057\u3066&#8221;ascrgdte&#8221;(GetDynamicTerminology)Apple\u30a4\u30d9\u30f3\u30c8\u3068\u3044\u3046\u3082\u306e\u3092\u9001\u4fe1\u3057\u3066\u308b\u3088\u3046\u306a\u3093\u3067\u3059\u304c\u3001SheepShaver\u306e\u5834\u5408\u3060\u3051\u3053\u306e\u7d50\u679c\u304c\u7a7a\u3067\u3057\u305f\u3002<br \/>\n\u3064\u307e\u308aSheepShaver\u304c\u3069\u3093\u306a\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30de\u30f3\u30c9\u7b49\u3092\u6301\u3063\u3066\u3044\u308b\u304b\u3092appscript\u5074\u3067\u306f\u5168\u304f\u691c\u77e5\u4e0d\u53ef\u80fd\u3067\u3001\u5f53\u7136frontmost\u30d7\u30ed\u30d1\u30c6\u30a3\u3082appscript\u5074\u7684\u306b\u306f\u5b58\u5728\u3057\u306a\u3044\u3068\u3044\u3046\u4e8b\u306b\u306a\u308b\u306e\u3067\u79c1\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u307e\u3057\u305f\u3002<\/p>\n<p>\u3082\u3046\u3053\u3046\u306a\u308b\u3068appscript\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3046\u306e\u3092\u6b62\u3081\u3066\u5225\u306e\u65b9\u6cd5\u3092\u4f7f\u3046\u3057\u304b\u306a\u3044\u3058\u3083\u3093\u3001\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u3067\u3075\u3068\u601d\u3044\u5f53\u305f\u308b\u70b9\u304c\u3042\u3063\u305f\u306e\u3067\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u2026<\/p>\n<h3>AppleScript\u3092\u8a31\u53ef\u305b\u3088<\/h3>\n<p>\u7d50\u679c\u304b\u3089\u8a00\u3046\u3068\u4e0b\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u79c1\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3082\u554f\u984c\u306a\u304f\u52d5\u4f5c\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\uff08\u30a2\u30d7\u30ea\u306e\u30d1\u30b9\u306f\u5b9f\u969b\u306e\u74b0\u5883\u306b\u3042\u308f\u305b\u3066\u304f\u3060\u3055\u3044\u306d\uff09\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">defaults write '\/Applications\/SheepShaver_UB_20140201\/SheepShaver.app\/Contents\/Info' NSAppleScriptEnabled -bool YES<\/pre>\n<p>\u30a2\u30d7\u30ea\u306eInfo.plist\u3067AppleScript\u306b\u3088\u308b\u64cd\u4f5c\u3092\u8a31\u53ef\u3057\u305f\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u591a\u5206AppleScript\u306b\u3088\u308b\u64cd\u4f5c\u3092\u8a31\u53ef\u3057\u306a\u304f\u3066\u3082frontmost\u306a\u3069\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8aad\u3080\u3060\u3051\u306a\u3089\u53ef\u80fd\u306a\u3093\u3067\u3057\u3087\u3046\u3051\u3069\u3001&#8221;ascrgdte&#8221;Apple\u30a4\u30d9\u30f3\u30c8\u3067\u5168\u3066\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30de\u30f3\u30c9\u7b49\u3092\u5217\u6319\u3059\u308b\u3088\u3046\u306a\u64cd\u4f5c\u306fAppleScript\u306b\u3088\u308b\u64cd\u4f5c\u3092\u8a31\u53ef\u3057\u306a\u3044\u3068\u3067\u304d\u306a\u3044\u3093\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3057\u304b\u3057\u521d\u6b69\u7684\u306a\u3053\u3068\u3067\u89e3\u6c7a\u3067\u304d\u3066\u3057\u307e\u3044\u8131\u529b\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u2026<\/p>\n<h3>\u4f59\u8ac7<\/h3>\n<p>\u79c1\u304c\u66f8\u3044\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u306f6\u5e74\u304f\u3089\u3044\u524d\u306e\u3082\u306e\u3067\u4eca\u898b\u308b\u3068\u9177\u3044\u30bd\u30fc\u30b9\u3060\u306a\uff08\u7279\u306b\u30a8\u30e9\u30fc\u51e6\u7406\uff09\u3068\u601d\u3046\u3093\u3067\u3059\u304c\u3001\u3082\u3046Mac\u306f\u4f7f\u3063\u3066\u306a\u3044\u306e\u3067\u591a\u5206\u6539\u826f\u306f\u3057\u307e\u305b\u3093\u3002<br \/>\n\u3044\u3089\u3063\u3057\u3083\u308b\u304b\u3069\u3046\u304b\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u6539\u826f\u3057\u305f\u3044\u65b9\u306f\u3054\u81ea\u7531\u306b\u3069\u3046\u305e\u3002<br \/>\n\u305f\u3060appscript\u81ea\u4f53\u958b\u767a\u3082\u30b5\u30dd\u30fc\u30c8\u3082\u30b9\u30c8\u30c3\u30d7\u3057\u65b0\u898f\u958b\u767a\u3067\u306f\u4f7f\u308f\u306a\u3044\u3088\u3046<a href=\"http:\/\/appscript.sourceforge.net\/\">\u516c\u5f0f\u306b\u52e7\u3081\u3066\u3044\u308b<\/a>\u304f\u3089\u3044\u306a\u306e\u3067\u3001\u79c1\u3082\u304a\u3059\u3059\u3081\u306f\u3057\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c11\u3057\u524d\u306b<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/967\">\u3053\u3061\u3089\uff08Mac\u3067\u91cd\u3044\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5287\u7684\u306b\u8efd\u304f\u3059\u308bPython\u30b9\u30af\u30ea\u30d7\u30c8\uff09<\/a>\u306e\u8a18\u4e8b\u306b\u3064\u3044\u3066\u30b3\u30e1\u30f3\u30c8\u3092\u3044\u305f\u3060\u304d\u307e\u3057\u3066\u3001\u79c1\u304c\u66f8\u3044\u305fPython\u30b9\u30af\u30ea\u30d7\u30c8\u304cSheepShaver\u3068\u3044\u3046\u30a2\u30d7\u30ea\u306b\u5bfe\u3057\u3066\u306f\u52d5\u4f5c\u3057\u306a\u3044\u3088\u3001\u3068\u3044\u3046\u30b3\u30e1\u30f3\u30c8\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u6570\u5e74Mac\u3092\u4f7f\u3063\u3066\u304a\u3089\u305a\u691c\u8a3c\u7528\u306e\u74b0\u5883\u304c\u3059\u3050\u306b\u7528\u610f\u3067\u304d\u306a\u3044\u72b6\u614b\u3060\u3063\u305f\u306e\u3067\u7d50\u69cb\u9069\u5f53\u306b\u8fd4\u7b54\u3057\u3066\u3057\u307e\u3063\u3066\u307e\u3057\u305f\u3002<br \/>\n\u6700\u8fd1\u5c11\u3057\u6687\u306b\u306a\u3063\u305f\u306e\u3067\u74b0\u5883\u3092\u7528\u610f\u3057\u5c11\u3057\u6df1\u304f\u554f\u984c\u3092\u8abf\u67fb\u3057\u305f\u7d50\u679c\u3001\u539f\u56e0\u304c\u5224\u660e\u3057\u305f\u306e\u3067\u8efd\u304f\u30e1\u30e2\u7a0b\u5ea6\u306b\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h3>Carbon API\u306eGetProcessForPID\u3068GetProcessBundleLocation\u306b\u3064\u3044\u3066<\/h3>\n<p>\u30b3\u30e1\u30f3\u30c8\u3078\u306e\u8fd4\u4fe1\u3067\u3001appscript\u30d1\u30c3\u30b1\u30fc\u30b8\u304b\u3089\u6700\u7d42\u7684\u306b\u547c\u3070\u308c\u308b\u5f53\u8a72\u95a2\u6570\u304c\u3046\u307e\u304f\u52d5\u4f5c\u3057\u3066\u306a\u3044\u306e\u3067\u306f\u306a\u3044\u304b\u3001\u3068\u66f8\u3044\u3066\u3044\u305f\u306e\u3067\u305d\u306e\u4e88\u60f3\u304c\u30a2\u30bf\u30ea\u306a\u306e\u304b\u30cf\u30ba\u30ec\u306a\u306e\u304b\u3092\u307e\u305a\u8abf\u3079\u307e\u3057\u305f\u3002<br \/>\n\u7d50\u679c\u3092\u5148\u306b\u8ff0\u3079\u308b\u3068\u3001\u5b8c\u5168\u306b\u30cf\u30ba\u30ec\u3067\u3057\u305f\u3002\uff08\u304a\u6065\u305a\u304b\u3057\u3044\u2026\uff09<\/p>\n<p>\u78ba\u8a8d\u306e\u305f\u3081\u306bC\u8a00\u8a9e\u3067\u30b6\u30c3\u3068\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u5b9f\u884c\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001SheepShaver\u3067\u3082\u666e\u901a\u306b\u30d7\u30ed\u30bb\u30b9ID\u304b\u3089\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d0\u30f3\u30c9\u30eb\u306e\u30d1\u30b9\u304c\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3061\u306a\u307f\u306b\u691c\u8a3c\u74b0\u5883\u306eOS\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f10.11.6 El Capitan\u3067\u3059\u304c\u3001\u5f53\u8a72\u95a2\u6570\u306f\u73fe\u5728\u3067\u306f\u975e\u63a8\u5968\u306b\u306a\u3063\u3066\u308b\u3088\u3046\u3067\u3059\uff08\u30b3\u30e1\u30f3\u30c8\u53c2\u7167\uff09\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/\r\n\/\/  main.c\r\n\/\/  GetBundleLocationFromPID\r\n\/\/\r\n\/\/  Created by peta on 2016\/10\/02.\r\n\/\/  Copyright \u00a9 2016\u5e74 peta. All rights reserved.\r\n\/\/\r\n\r\n#include &lt;stdio.h&gt;\r\n#include &lt;Carbon\/Carbon.h&gt;\r\n\r\nint main(int argc, const char * argv&#x5B;]) {\r\n    if (argc != 2) {\r\n        printf(&quot;Usage: %s PID\\n&quot;, argv&#x5B;0]);\r\n        return 1;\r\n    }\r\n\r\n    int pid;\r\n    pid = atoi(argv&#x5B;1]);\r\n    if (pid &lt;= 0) {\r\n        printf(&quot;The PID is invalid.\\n&quot;);\r\n        return 1;\r\n    }\r\n\r\n    OSStatus stat;\r\n    ProcessSerialNumber psn;\r\n    stat = GetProcessForPID(pid, &amp;psn); \/\/ 10.9 \u304b\u3089 deprecated\r\n    if (stat != errSecSuccess) {\r\n        printf(&quot;Failed calling GetProcessForPID().\\n&quot;);\r\n        return 1;\r\n    }\r\n\r\n    FSRef loc;\r\n    stat = GetProcessBundleLocation(&amp;psn, &amp;loc); \/\/ 10.9 \u304b\u3089 deprecated\r\n    if (stat != errSecSuccess) {\r\n        printf(&quot;Failed calling GetProcessBundleLocation().\\n&quot;);\r\n        return 1;\r\n    }\r\n\r\n    UInt8 path&#x5B;PATH_MAX];\r\n    stat = FSRefMakePath(&amp;loc, path, sizeof(path)); \/\/ 10.8 \u304b\u3089 deprecated\r\n    if (stat != errSecSuccess) {\r\n        printf(&quot;Failed calling FSRefMakePath().\\n&quot;);\r\n        return 1;\r\n    }\r\n    \r\n    \/*\r\n    CFStringRef str = CFStringCreateWithBytes(kCFAllocatorDefault, path, sizeof(path), kCFStringEncodingUTF16, false);\r\n    CFIndex len = CFStringGetLength(str);\r\n    CFIndex max = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF16) + 1;\r\n    char *cstr = (char*)malloc(sizeof(char) * max);\r\n    if (!CFStringGetCString(str, cstr, max, kCFStringEncodingUTF16)) {\r\n        free(cstr);\r\n        printf(&quot;Failed calling CFStringGetCString().\\n&quot;);\r\n        return 1;\r\n    }\r\n    \r\n    printf(&quot;%s\\n&quot;, cstr);\r\n    free(cstr);\r\n    *\/\r\n    \r\n    printf(&quot;%s\\n&quot;, path);\r\n    return 0;\r\n}<\/pre>\n<p>\u203b\u521d\u51fa\u306e\u30bd\u30fc\u30b9\u3067\u306fFSRefMakePath\u3067\u5f97\u3089\u308c\u305f\u30d0\u30a4\u30c8\u5217path\uff08UTF8\u3067\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305f\u30c7\u30fc\u30bf\uff09\u3092UTF16\u3068\u3057\u3066\u30c7\u30b3\u30fc\u30c9\u3057\u518d\u5ea6UTF16\u3068\u3057\u3066\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u3066C\u8a00\u8a9e\u5f62\u5f0f\u306e\u6587\u5b57\u5217\u306b\u5909\u63db\u3059\u308b\u3068\u3044\u3046\u8b0e\u306a\u51e6\u7406\u3092\u884c\u3063\u3066\u307e\u3057\u305f\u304c\uff08\u8907\u6570\u884c\u30b3\u30e1\u30f3\u30c8\u306e\u90e8\u5206\uff09\u3001\u5143\u306e\u30c7\u30fc\u30bf\u304cUTF8\u306a\u3089\u30bf\u30fc\u30df\u30ca\u30eb.app\u3067\u3082\u666e\u901a\u306b\u8868\u793a\u3067\u304d\u308b\u3060\u308d\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u7279\u306b\u5909\u63db\u305b\u305a\u306bprintf\u306b\u6e21\u3059\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h3>\u3061\u3087\u3063\u3068appscript\u306e\u30bd\u30fc\u30b9\u3092\u8aad\u3093\u3067\u307f\u305f<\/h3>\n<p>\u4e88\u60f3\u304c\u30cf\u30ba\u30ec\u305f\u306e\u3067\u89b3\u5ff5\u3057\u3066\u5c11\u3057\u6df1\u304f\u30bd\u30fc\u30b9\u3092\u8aad\u3093\u3067\u307f\u308b\u3053\u3068\u306b\u3002<br \/>\n<a href=\"https:\/\/github.com\/mattneub\/appscript\/tree\/master\/py-appscript\/tags\/py-appscript-1.0.0\/appscript_2x\/lib\">appscript\/py-appscript\/tags\/py-appscript-1.0.0\/appscript_2x\/lib at master \u00b7 mattneub\/appscript \u00b7 GitHub<\/a><\/p>\n<p>\u8d85\u3056\u3063\u304f\u308a\u8a00\u3046\u3068appscript\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u5bfe\u3059\u308b\u6700\u521d\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u7b49\u306e\u547c\u3073\u51fa\u3057\u304c\u3042\u3063\u305f\u969b\u306b\u305d\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u3069\u3046\u3044\u3063\u305f\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30de\u30f3\u30c9\u7b49\u3092\u6301\u3063\u3066\u3044\u308b\u306e\u304b\u52d5\u7684\u306b\u8abf\u3079\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u30012\u56de\u76ee\u4ee5\u964d\u306f\u305d\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u4f7f\u3046\uff08\u3042\u304f\u307e\u3067\u3082\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3084\u30b3\u30de\u30f3\u30c9\u540d\u7b49\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3060\u3051\u3067\u591a\u5206\u7d50\u679c\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u306a\u3044\uff09\u3088\u3046\u306a\u4ed5\u7d44\u307f\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u3041\u4eca\u56de\u306e\u4ef6\u306b\u3064\u3044\u3066\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3068\u3044\u3046\u70b9\u306f\u95a2\u4fc2\u306a\u3044\u3093\u3067\u3059\u304c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3084\u30b3\u30de\u30f3\u30c9\u540d\u7b49\u3092\u52d5\u7684\u306b\u8abf\u3079\u308b\u3068\u3044\u3046\u70b9\u304c\u95a2\u4fc2\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>appscript\u3067\u306f\u52d5\u7684\u306b\u8abf\u3079\u308b\u305f\u3081\u306b\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5bfe\u3057\u3066&#8221;ascrgdte&#8221;(GetDynamicTerminology)Apple\u30a4\u30d9\u30f3\u30c8\u3068\u3044\u3046\u3082\u306e\u3092\u9001\u4fe1\u3057\u3066\u308b\u3088\u3046\u306a\u3093\u3067\u3059\u304c\u3001SheepShaver\u306e\u5834\u5408\u3060\u3051\u3053\u306e\u7d50\u679c\u304c\u7a7a\u3067\u3057\u305f\u3002<br \/>\n\u3064\u307e\u308aSheepShaver\u304c\u3069\u3093\u306a\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30de\u30f3\u30c9\u7b49\u3092\u6301\u3063\u3066\u3044\u308b\u304b\u3092appscript\u5074\u3067\u306f\u5168\u304f\u691c\u77e5\u4e0d\u53ef\u80fd\u3067\u3001\u5f53\u7136frontmost\u30d7\u30ed\u30d1\u30c6\u30a3\u3082appscript\u5074\u7684\u306b\u306f\u5b58\u5728\u3057\u306a\u3044\u3068\u3044\u3046\u4e8b\u306b\u306a\u308b\u306e\u3067\u79c1\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u307e\u3057\u305f\u3002<\/p>\n<p>\u3082\u3046\u3053\u3046\u306a\u308b\u3068appscript\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3046\u306e\u3092\u6b62\u3081\u3066\u5225\u306e\u65b9\u6cd5\u3092\u4f7f\u3046\u3057\u304b\u306a\u3044\u3058\u3083\u3093\u3001\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u3067\u3075\u3068\u601d\u3044\u5f53\u305f\u308b\u70b9\u304c\u3042\u3063\u305f\u306e\u3067\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u2026<\/p>\n<h3>AppleScript\u3092\u8a31\u53ef\u305b\u3088<\/h3>\n<p>\u7d50\u679c\u304b\u3089\u8a00\u3046\u3068\u4e0b\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067\u79c1\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3082\u554f\u984c\u306a\u304f\u52d5\u4f5c\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\uff08\u30a2\u30d7\u30ea\u306e\u30d1\u30b9\u306f\u5b9f\u969b\u306e\u74b0\u5883\u306b\u3042\u308f\u305b\u3066\u304f\u3060\u3055\u3044\u306d\uff09\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">defaults write '\/Applications\/SheepShaver_UB_20140201\/SheepShaver.app\/Contents\/Info' NSAppleScriptEnabled -bool YES<\/pre>\n<p>\u30a2\u30d7\u30ea\u306eInfo.plist\u3067AppleScript\u306b\u3088\u308b\u64cd\u4f5c\u3092\u8a31\u53ef\u3057\u305f\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u591a\u5206AppleScript\u306b\u3088\u308b\u64cd\u4f5c\u3092\u8a31\u53ef\u3057\u306a\u304f\u3066\u3082frontmost\u306a\u3069\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8aad\u3080\u3060\u3051\u306a\u3089\u53ef\u80fd\u306a\u3093\u3067\u3057\u3087\u3046\u3051\u3069\u3001&#8221;ascrgdte&#8221;Apple\u30a4\u30d9\u30f3\u30c8\u3067\u5168\u3066\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30de\u30f3\u30c9\u7b49\u3092\u5217\u6319\u3059\u308b\u3088\u3046\u306a\u64cd\u4f5c\u306fAppleScript\u306b\u3088\u308b\u64cd\u4f5c\u3092\u8a31\u53ef\u3057\u306a\u3044\u3068\u3067\u304d\u306a\u3044\u3093\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3057\u304b\u3057\u521d\u6b69\u7684\u306a\u3053\u3068\u3067\u89e3\u6c7a\u3067\u304d\u3066\u3057\u307e\u3044\u8131\u529b\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u2026<\/p>\n<h3>\u4f59\u8ac7<\/h3>\n<p>\u79c1\u304c\u66f8\u3044\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u306f6\u5e74\u304f\u3089\u3044\u524d\u306e\u3082\u306e\u3067\u4eca\u898b\u308b\u3068\u9177\u3044\u30bd\u30fc\u30b9\u3060\u306a\uff08\u7279\u306b\u30a8\u30e9\u30fc\u51e6\u7406\uff09\u3068\u601d\u3046\u3093\u3067\u3059\u304c\u3001\u3082\u3046Mac\u306f\u4f7f\u3063\u3066\u306a\u3044\u306e\u3067\u591a\u5206\u6539\u826f\u306f\u3057\u307e\u305b\u3093\u3002<br \/>\n\u3044\u3089\u3063\u3057\u3083\u308b\u304b\u3069\u3046\u304b\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u6539\u826f\u3057\u305f\u3044\u65b9\u306f\u3054\u81ea\u7531\u306b\u3069\u3046\u305e\u3002<br \/>\n\u305f\u3060appscript\u81ea\u4f53\u958b\u767a\u3082\u30b5\u30dd\u30fc\u30c8\u3082\u30b9\u30c8\u30c3\u30d7\u3057\u65b0\u898f\u958b\u767a\u3067\u306f\u4f7f\u308f\u306a\u3044\u3088\u3046<a href=\"http:\/\/appscript.sourceforge.net\/\">\u516c\u5f0f\u306b\u52e7\u3081\u3066\u3044\u308b<\/a>\u304f\u3089\u3044\u306a\u306e\u3067\u3001\u79c1\u3082\u304a\u3059\u3059\u3081\u306f\u3057\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"author":1,"featured_media":4765,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[567,568,222,60],"class_list":["post-4760","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-applescript","tag-appscript","tag-mac","tag-python"],"_links":{"self":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/4760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/comments?post=4760"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/4760\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media\/4765"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=4760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=4760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=4760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}