2013-08-12 2 views
0

저는 현재하고 싶은 일을하는 applescript가 있습니다. 특정 URL을 열고 페이지를 닫은 다음 2 초 후에 다시하십시오. 스크립트가 작동합니다.AppleScript로 백그라운드에서 Safari를 실행합니다.

문제는 내가 이것을 내 컴퓨터에서 실행할 때 동시에 다른 것을하려고 할 때 Safari 창이 계속 팝업된다는 것입니다. 나는이 일을 배경에서 실행하여 내가하고있는 일을 계속할 수 있기를 바란다.

내가 가진 코드는 다음과 같습니다

set theURL to "https://sites.google.com/site/whatever/" 

repeat 100 times 
    tell application "Safari" 
     activate 
     try 
      tell window 1 to set current tab to make new tab --with properties {URL:theURL} 
      set URL of document 1 to theURL 
     on error 
      open location theURL 
     end try 
     delay 2 
     try 
      close window 1 
     end try 
    end tell 

    tell application "Safari" 
     quit 
    end tell 

    delay 1 
end repeat 

사람이 하나의 해결책이?

답변

3

Safari가 루프 내에서 활성화되어 있기 때문에 앞으로오고 있습니다.

repeat 100 times 
    tell application "Safari" 
     if not (exists document 1) then reopen 
     set URL of document 1 to "https://sites.google.com/site/whatever/" 
     delay 2 
     close window 1 
     quit 
    end tell 
    delay 1 
end repeat 

편집

set myURLs to {"https://www.google.com/", "http://www.yahoo.com/"} 

repeat with aUrl in myURLs 
    repeat 100 times 
     tell application "Safari" 
      if not (exists document 1) then reopen 
      set URL of document 1 to aUrl 
      delay 2 
      close window 1 
      quit 
     end tell 
     delay 1 
    end repeat 
end repeat 
+0

이 걸릴 연속 시리즈를 실행하는 방법이있다. 예를 들어 이것이 version1이고 다른 URL이 version2 인 동일한 스크립트 인 경우 version2를 실행하면 version1이 실행되는 스크립트를 만들 수 있습니까? –

+0

두 개의 스크립트가 필요 없으며 다른 루프를 추가하면됩니다. – adayzdone

+0

8 개의 URL이 있습니다. 내가 이걸 너의 방식대로하면 딜레이를 늘려야 내가 닫히기 전에 모든 걸 열어 두어야한다고 생각해. 아니면 처음 반복 후에 다른 반복 시퀀스를 넣을 수 있습니까? –

관련 문제