Daha etkili bir yol olabilir, ancak bunu AppleScript kodunu Script Editor'de bir uygulama olarak kaydederseniz, ihtiyaçlarınızı özelleştirdikten sonra…… bu uygulamayı çalıştırmak için, şu anda yapılandırıldığı şekilde çalıştırmaya devam edene kadar her beş saniyede bir çalışıp kontrol etmeye devam edeceksiniz. ek monitör algılandı.
property displayCount : 1
repeat until displayCount is greater than 1
tell application "Image Events"
set theDisplays to count of displays
end tell
set displayCount to theDisplays
delay 5 -- How Often To Check How Many Connected Monitors.. In Seconds
end repeat
-- The Following Line Will Execute When An Additional Display Is Connected
-- Replace The Following Code With Whatever Actions You Choose
activate
display dialog "New Display Connected" buttons {"Cancel", "OK"} default button "OK"
-- OR use the "run script" command as in the sample below
--set theScript to (path to desktop as text) & "whatever.scpt"
--set runScript to run script alias theScript
return
Bu sonraki seçenek bir monitörün bağlı olup olmadığını tespit eder ve çalışmaya devam eder
property displayCount : missing value
property tempDisplayCount : missing value
countDisplays()
repeat
repeat until displayCount is greater than 1
countDisplays()
end repeat
displayConnected()
countDisplays()
copy displayCount to tempDisplayCount
repeat until tempDisplayCount is not equal to displayCount
countDisplays()
end repeat
copy displayCount to tempDisplayCount
if tempDisplayCount is greater than displayCount then
displayConnected()
else if tempDisplayCount is equal to displayCount then
displayDisconnected()
end if
end repeat
on displayConnected()
-- The Following Lines Will Execute When An Additional Display Is Connected
-- Replace The Following Code With Whatever Actions You Choose
-- OR use the "run script" command as in the sample below
-- set theScript to (path to desktop as text) & "whatever.scpt"
-- set runScript to run script alias theScript
activate
set newDisplayConnected to button returned of (display dialog "New Display Connected" buttons {"Stop Monitoring", "Continue Monitoring"} default button "Continue Monitoring")
if newDisplayConnected is "Stop Monitoring" then
quit me
end if
end displayConnected
on displayDisconnected()
-- The Following Lines Will Execute When A Display Is Disconnected
-- Replace The Following Code With Whatever Actions You Choose
-- OR use the "run script" command as in the sample below
-- set theScript to (path to desktop as text) & "whatever.scpt"
-- set runScript to run script alias theScript
activate
set newDisplayDisconnected to button returned of (display dialog "A Display Was Disconnected" buttons {"Stop Monitoring", "Continue Monitoring"} default button "Continue Monitoring")
if newDisplayDisconnected is "Stop Monitoring" then
quit me
end if
end displayDisconnected
on countDisplays()
tell application "Image Events"
set theDisplays to count of displays
end tell
set displayCount to theDisplays
delay 5 -- How Often To Check How Many Connected Monitors.. In Seconds
end countDisplays