2017-01-27 1 views
0

(AppleScript로 처음 ...) 단일 업로드 양식을 통해 서버에 로컬 폴더의 파일을 일괄 업로드하려고합니다 (기존 서버 측 DDOS 벽 뒤에 소프트웨어는, 그 위에 통제)AppleScript 자동화 - 폴더에있는 파일을 일괄 업로드 양식에 일괄 업로드

는 이해가 없기 때문에 :

  • 내가 할 수있는 파일 시스템의 각 파일을 통해 루프. 각 파일로
  • : 호출, ID에 의해 "
  • 파일 업로드 대화 상자 버튼을 클릭"자바 스크립트를 호출
  • "사파리"에게 "업로드 할 파일을 선택

난 (?) 그 구현에 구문 몇 가지 문제가 ...

를 (또한, 즉 올바른/가장 좋은 방법이 아니라면, 아래 더 나은 하나를 제공하십시오!)

 
on run 
    tell application "Finder" 
     set mlist to (every file of folder "Macintosh HD:Users:username:filestouploadfolder") as alias list 

     repeat with this_file in mlist 

      tell application "Safari" 
       activate 

       do JavaScript "document.getElementById('selectToOpenFileDialog').click();" in document 1 
       choose file this_file 

      end tell 
     end repeat 

    end tell 
    return 0 
end run 

답변

0

아마도 더 세련 될 수 있지만 솔루션을 해킹했습니다.

 
on run 
    tell application "Finder" 
     set mfolder to "Macintosh HD:Users:yosun:png:" 
     set myFiles to name of every file of folder mfolder 
    end tell 

    repeat with aFile in myFiles 

     tell application "Safari" 
      activate 
      delay 1 
      do JavaScript "document.getElementById('addDeviceTargetUserView').click();" in document 1 
      delay 1 
      do JavaScript "document.getElementById('targetDimension').value=10;" in document 1 
      do JavaScript "document.getElementById('targetImgFile').click();" in document 1 


     end tell 

     tell application "System Events" 
      keystroke "G" using {command down, shift down} 
      delay 1 
      keystroke "~/png/" & aFile as string 
      delay 1 
      keystroke return 

      delay 1 
      keystroke return 

      delay 1 

     end tell 

     tell application "Safari" 
      activate 
      delay 1 
      do JavaScript "document.getElementById('AddDeviceTargetBtn').click();" in document 1 
     end tell 

     delay 10 

    end repeat 
end run