Esegui un applescript sul mouse

0

Come posso attivare un applescript sul mouse? Voglio che questo script di mele venga eseguito quando un utente fa il doppio clic su uno spazio vuoto nel desktop (cioè non facendo clic sulle icone presenti sul desktop).

Questo è il mio script finora:

try
    set toggle to do shell script "defaults read com.apple.finder CreateDesktop"
    if toggle = "true" then
        do shell script "defaults write com.apple.finder CreateDesktop false"
    else if toggle = "false" then
        do shell script "defaults write com.apple.finder CreateDesktop true"
    end if
end try

do shell script "killall Finder"
delay 0.1
activate application "Finder"
    
posta Sushi 22.08.2014 - 07:45
fonte

1 risposta

1

Non sono sicuro che il doppio clic sullo spazio vuoto possa essere fatto, ma sono sicuro che sarebbe più gentile chiedere al Finder di smettere piuttosto che ucciderlo ... Anche i Finder hanno dei sentimenti; -)

Potresti sempre salvarlo come app & mettilo nel Dock.

tell application "Finder" to quit
-- /*give it time, otherwise it will try to activate before it's quit & this simple version won't check if it relaunched.*/
delay 2 
try
    tell application "Finder" to activate
end try
--my testFinderRunning() --/*uncomment to add the belt & braces method*/

Aggiungi questa routine per assicurarti che venga riavviata

    on testFinderRunning()
    set test to 0
    repeat while test = 0
        log test
        tell application "System Events" to set test to count (every process whose name is "Finder")
        delay 2
        --/*we do this even if active because it doesn't naturally come to front.*/
        try
            tell application "Finder" to activate
        end try
        if (test > 0) then exit repeat
    end repeat
end testFinderRunning

Puoi mettere il menu di Applescript nella barra dei menu - link versione corta ... lancia Applescript, ottieni Pref, imposta 'Mostra menu script nella barra dei menu'

Questo potrebbe consentire di assegnare comandi chiave da Preferenze di sistema / Tastiera, ma non ho ancora avuto il tempo di testare.

    
risposta data 22.08.2014 - 08:46
fonte

Leggi altre domande sui tag