从Python中查找MacOS中的默认屏幕截图路径以监控屏幕截图

时间:2018-04-04 22:30:59

标签: python macos directory screenshot

我有一个监控新屏幕截图的程序但是,我必须将默认的屏幕截图目录更改为/ screenshots而不是com.apple.screencapture

如何从Python中获取com.apple.screencapture中设置的目录,以便程序可以在任何MacOS计算机上运行,​​而无需先手动更改屏幕截图目录位置。

示例代码(当前更改目录后):

path = os.path.join(os.path.curdir, 'screenshots')
observer = Observer()
event_handler = ScreenshotEventHandler()
# Create a watchdog to watch <current_dir>/screenshots directory
observer.schedule(event_handler, path)
observer.start()

2 个答案:

答案 0 :(得分:0)

只需使用shell命令{ "persistent_menu":[ { "locale":"default", "composer_input_disabled": true, "call_to_actions":[ { "title":"My Account", "type":"nested", "call_to_actions":[ { "title":"Pay Bill", "type":"postback", "payload":"PAYBILL_PAYLOAD" }, { "type":"web_url", "title":"Latest News", "url":"https://www.messenger.com/", "webview_height_ratio":"full" } ] } ] } ] } 来读取位置。

defaults

答案 1 :(得分:0)

<script>
function AllProposals() {
  let getProposalsUrl = '/proposals/index';
  $.ajax({
      url: getProposalsUrl,
      contentType: 'application/json; charset=utf-8',
      type: 'GET',
      dataType: 'json',
      processData: false,
      success: function (data) {
          $("#proposals").empty();
          var list = data;
          for (var i = 0; i <= list.length - 1; i++) {

              var mycolor = "";
              switch (list[i].Status) {
                    case "Approved":
                        mycolor = "style="color:green";
                        break;
                    case "Rejected":
                        mycolor = "style="color:red";
                        //Add more if needed
                }

              var tableData = '<tr>' +
                  '<td class="proposalId">' +
                  list[i].Id +
                  '</td>' +
                  '<td > ' +
                  list[i].Project +
                  '</td>' +
                  '<td > ' +
                  moment(list[i].DateFrom).format('DD/MM/YYYY') + "--" + moment(list[i].DateTo).format('DD/MM/YYYY') +
                  '</td>' +
                  '<td> ' +
                  list[i].WorkTime + "--" +list[i].WorkTimeTo +
                  '</td>' +
                  '<td > ' +
                  list[i].Quantity+
                  '</td>' +
                  '<td> ' +
                  list[i].Service +
                  '</td>' +
                  '<td> ' +
                  list[i].Price +
                  '</td>' +
                  '<td' + mycolor +'> ' +
                  list[i].Status +
                  '</td>' +

                  '</tr>';
              $('#proposals').append(tableData);
          }
      }
  })
}
</script>

这是我使用的答案。