捕捉事件是它在所有可能的一個AppleScript(或也許一些其他腳本),而其他(無關)應用程序更改狀態,以接收通知,即關閉,最小化? 我們的目標是保持5個最近關閉或最小化應用使用AppleScript
0
A
回答
0
的列表,讓您的觸發器設置可能是一種方法http://www.dssw.co.uk/blog/2011/01/28/how-to-run-an-applescript-when-switching-to-battery-power/
以下script'll讓你當前最小化所有應用程序(除了Finder之外,由於某種原因,確定的bug),你可以設置爲間隔運行,甚至可以設置爲連續運行(性能會受到我的設想),但希望它能讓你更接近一個解決方案(實現當然,這並沒有真正解決的狀態變化觸發任何窗口的問題)
property top5 : {"None", "None", "None", "None", "None"}
property oldest : 0
tell application "System Events" to set _list to (name of application processes)
repeat with i from 1 to number of _list
set current_name to item i of _list
if top5 does not contain current_name then
tell application "System Events" to tell application process current_name to set win_num to (number of every window)
if not win_num is 0 then
try
tell application current_name
set _windows to every window
repeat with i from 1 to number of _windows
set this_window to item i of _windows
try
log "mini"
if miniaturized of this_window is true then
my addNewToTop5(current_name)
exit repeat
end if
end try
try
log "collapsed"
if collapsed of this_window is true then
my addNewToTop5(current_name)
exit repeat
end if
end try
end repeat
end tell
end try
end if
end if
end repeat
log top5
on oldestOfTop5()
if oldest is 5 then
set oldest to 1
else
set oldest to oldest + 1
end if
return oldest
end oldestOfTop5
on addNewToTop5(_item)
set item oldestOfTop5() of top5 to _item
end addNewToTop5
0
你真的不能用applescript做到這一點。如果你知道objective-c,雖然它相當簡單。 NSWorkspace職位的通知講了很多東西,其中有你想知道的應用程序隱藏,激活等看一看類文檔here所有你能得到的通知的一切。
基本上所有你需要做的就是寫接收這些通知,然後你可以做任何你想要與他們小的後臺應用程序。像下面這樣一個簡單的通話將您註冊所有的通知,然後一個簡單的「if語句」的「nsworkspaceNotification:」方法可以用來找出你正在接受哪些,並允許您對其採取行動。
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(nsworkspaceNotification:) name:nil object:nil];
相關問題
- 1. 使用AppleScript
- 2. 使用AppleScript
- 3. 使用AppleScript
- 4. 使用AppleScript
- 5. 使用AppleScript
- 6. 使用AppleScript
- 7. 使用AppleScript
- 8. 使用AppleScript
- 9. 使用AppleScript
- 10. 使用AppleScript
- 11. 無法在applescript中使用新的applescript
- 12. 如何使用AppleScript
- 13. 嘗試使用AppleScript
- 14. 使用pngquant和AppleScript
- 15. 創建使用AppleScript
- 16. 添加使用AppleScript
- 17. 使用AppleScript打字
- 18. 點擊使用AppleScript
- 19. 獲取使用AppleScript
- 20. 無法使用AppleScript
- 21. 登錄到Mac使用AppleScript
- 22. 使用System.cmd運行AppleScript的
- 23. 在AppleScript中使用Python
- 24. 使用node.js的JavaScript的Applescript
- 25. setStringValue使用AppleScript列表
- 26. 錯誤而使用AppleScript
- 27. 副本組使用AppleScript
- 28. 的AppleScript - 幫助使用Safari
- 29. 如何使用AppleScript外殼
- 30. zip文件夾使用applescript