OS X 10.1.2下的AppleScript

本區專門提供 Mac OS X 使用者交換使用心得

版主: ross_ttbryanchangdigdogchester

回覆文章
內容
發表人
頭像
janusng
嗜冰客
文章: 1048
註冊時間: 04/30/2001 1:01 am
來自: Metropolis Asylum
聯繫:

OS X 10.1.2下的AppleScript

#1 文章 janusng »

update 10.1.2後,AppleScript內的say statement,總是沒有了最頭大約5 second。不只一條script有此問題! [img]images/smiles/icon_confused.gif[/img]
但又會不會是Dec DeveloperTools才是問題呢?我是一起update的!

[ 12-23-2001: 留言編輯者: 真理士 ]
頭像
janusng
嗜冰客
文章: 1048
註冊時間: 04/30/2001 1:01 am
來自: Metropolis Asylum
聯繫:

OS X 10.1.2下的AppleScript

#2 文章 janusng »

我發現是另外的問題作怪…
頭像
Alex Tsai
討論區管理員
文章: 8515
註冊時間: 04/26/2001 1:01 am
來自: Taipei, Taiwan
聯繫:

OS X 10.1.2下的AppleScript

#3 文章 Alex Tsai »

<BLOCKQUOTE><font size="1" face="XYZ">quote
我發現是另外的問題作怪…
聽來,真兄似乎狂玩 AppleScript 呢!發表一些心得吧! [img]images/smiles/icon_biggrin.gif[/img]
頭像
janusng
嗜冰客
文章: 1048
註冊時間: 04/30/2001 1:01 am
來自: Metropolis Asylum
聯繫:

OS X 10.1.2下的AppleScript

#4 文章 janusng »

沒有很多心得耶,只是玩玩greeting、bye等,嚇嚇Wintel同事。其他的不外乎做一些Windows上很簡單,已經是全自動,但Mac上要自己寫AppleScript才行的事了吧,如上網後,自己叫出ICQ、Mail等(當 然,這些缺陷不會讓他們知! [img]images/smiles/icon_razz.gif[/img] )

投訴反而有,如為何Application中沒有Hide command的? [img]images/smiles/icon_mad.gif[/img] Window中又沒有Minimize command? [img]images/smiles/icon_mad.gif[/img] Network又只有configure可以改,但竟不能叫OS X改用 Airport connect! [img]images/smiles/icon_mad.gif[/img]也不能知道現在的status? [img]images/smiles/icon_mad.gif[/img]

希望Apple會令AppleScript更齊全。可以如Unix的 script一般,幾乎沒有事情是做不到的。

[ 12-25-2001: 留言編輯者: 真理士 ]
頭像
janusng
嗜冰客
文章: 1048
註冊時間: 04/30/2001 1:01 am
來自: Metropolis Asylum
聯繫:

OS X 10.1.2下的AppleScript

#5 文章 janusng »

悲兄:

強呀!無怪乎我反轉本AppleScript In A Nutshell也找不到!不過現在process放在Legacy suite內,會不會命不久焉? [img]images/smiles/icon_sad.gif[/img]

要寫log才知status也想出來,悲兄真的study了AppleScript很久了! [img]images/smiles/icon_eek.gif[/img]
留言五百如一日
文章: 610
註冊時間: 12/25/2001 1:01 am

OS X 10.1.2下的AppleScript

#6 文章 »

真理士兄:


about "不過現在process放在Legacy suite內,會不會命不久焉?", well, it's unknown. But you can use system events to simulate the effect :


tell application "System Events"
-- keep the following code in one line
set visible of (every process whose visible is true and frontmost is false) to false
-- keep the above code in one line
end tell

remark : same effect if you run it from script menu; hide other applications if you run by script editor.

about "Network又只有configure可以改,但竟不能叫OS X改用 Airport connect!"

though the system preferences is not scriptable; there would be two work around:

--pseudo code 1

a preference file "com.apple.internetconnect.plist" is in your preferences folder

path to preferences folder

write the necessary change to this file, save it & connect.

--pseudo code 2

change the setting in network, copy the above mentioned preferneces file to another folder.

for example you have 3 dummy preference files for 3 settings :

pre 1 -- dial by internal modem
pre 2 -- using airport
pre 3 -- using PPPoE

if connected, disconnect
rename file "pre 1"( or pre 2 or pre 3 ) to "com.apple.internetconnect.plist", move it to preferences folder replacing yes
connect

remark : guess only, try with caution.

about "嚇嚇Wintel同事"

did you show them the speech recognition?

[ 12-26-2001: 留言編輯者: 悲 ]
留言五百如一日
文章: 610
註冊時間: 12/25/2001 1:01 am

OS X 10.1.2下的AppleScript

#7 文章 »

Hi 真理士,

try :


about "如為何Application中沒有Hide command的?" :

tell application "Finder"
activate
-- keep the following code in one line
set visible of (every process whose visible is true and frontmost is false) to false
-- keep the above code in one line
end tell


about "Window中又沒有Minimize command?" :

tell application "Finder"
try
set collapsed of every window to true
end try
end tell

for other applications, need to check their dictionaries, in order to find out if they support this event or not.


about "Network又只有configure可以改,但竟不能叫OS X改用 Airport connect!"

well, the system preferences is not scriptable at this moment. However, if the current configuration is using Airport, you can:

tell application "Internet Connect" to connect

about "也不能知道現在的status?"

analyse the log of Internet Connect, if you are using PPPoE or Airport, the log may be different, amend the script to fit your need :

tell application "Internet Connect"
set iLog to log
end tell

if paragraph -2 of iLog contains "disconnected" then
say "idle"
else if paragraph -2 of iLog contains "secondary DNS address" then
say "connected"
end if


Best Wishes
悲 [img]images/smiles/icon_sad.gif[/img]
頭像
janusng
嗜冰客
文章: 1048
註冊時間: 04/30/2001 1:01 am
來自: Metropolis Asylum
聯繫:

OS X 10.1.2下的AppleScript

#8 文章 janusng »

Thanks for your help. I learned something more. haven't tried yet.

In order to demostrate the speech recognization, a mic is requeired. The PowerMac G4/450 in my office does not have one. I have to bring my PowerBook back office to show it.

You know, for best effect of shocking, I have to done it as intuitive as I could. There is no chance to show it without too much artificially.

The text-to-speech has done its job already. I had hard time to make them believe that has been included in Mac OS 7 years ago. [img]images/smiles/icon_biggrin.gif[/img]
回覆文章