2013-08-22 10 views
7

Pytanie newbie od Applelist ponownie :) Próbuję stworzyć mały bukszpryt, który pozwoli mi wybrać wiele pozycji z listy aktualnie uruchomionych aplikacji, a następnie zamknąć wybrane aplikacje. Coś takiego działa, ale zamiast klikać na każdym oknie dialogowym, byłoby o wiele łatwiej wybrać z listy.Jabłko dostaje listę uruchomionych aplikacji?

tell application "System Events" 
repeat with p in every process 
    if background only of p is false then 
     display dialog "Would you like to quit " & name of p & "?" as string 
    end if 
end repeat 
end tell 

Każda pomoc będzie bardzo ceniona!

Dzięki!

Odpowiedz

11

Spróbuj tego:

tell application "System Events" 
    set listOfProcesses to (name of every process where background only is false) 
    tell me to set selectedProcesses to choose from list listOfProcesses with multiple selections allowed 
end tell 
--The variable `selectedProcesses` will contain the list of selected items. 
repeat with processName in selectedProcesses 
    do shell script "Killall " & quoted form of processName 
end repeat 
+0

działa jak marzenie !!! Moje ostatnie pytanie brzmi: jak byś to zrobił bez komendy killall? Coś jak, powiedz aplikacji selectedProcesses, aby zakończyć. Dzięki! – user2555399

+0

Zobacz dolną część skryptu Parag powyżej. – user2555399

+0

Edytowano dodając część skryptu Parag. –

1

Można spróbować to

tell application "System Events" 
     set AppName to name of every process whose background only is false 
     choose from list AppName OK button name "Ok" cancel button name "Cancel" 
    end 
5
tell application "System Events" 
    set processList to get the name of every process whose background only is false 
    set processNameList to choose from list processList with prompt "Select process to quit" with multiple selections allowed 
    if the result is not false then 
     repeat with processName in processNameList 
      do shell script "Killall " & quoted form of processName 
     end repeat 
    end if 
end tell 

enter image description here

+0

Najlepsza część skryptu nie działa dla mnie, ale dolna część zrobiła! Dzięki! – user2555399

+0

Czy otrzymujesz błąd? –

1

& (name of every process whose (name is "AppName") mogą być dodawane do Michele Percich's i Parag Bafna's rozwiązań zawierać konkretne aplikacje paska menu według nazwy .

tell application processName to quit może być używany zamiast do shell script "Killall " & quoted form of processName.

tell application "System Events" 
    set processList to ¬ 
     (name of every process where background only is false) & ¬ 
     (name of every process whose ¬ 
      (name is "AppName") or ¬ 
      (name is "AnotherAppName")) 
    tell me to set selectedProcesses to choose from list processList with prompt "Select process(es) to quit:" with multiple selections allowed 
end tell 
if the result is not false then 
    repeat with processName in selectedProcesses 
     tell application processName to quit 
    end repeat 
end if 
2

można użyć tego skryptu, który jest znacznie prostszy

tell application "Finder" 
    get the name of every process whose visible is true 
end tell 
Powiązane problemy