我正在使用此AppleScript編輯我的剪貼板數據。但也有一些事情我無法弄清楚如何做到:編輯剪貼板文本而不會丟失格式樣式並連續運行腳本
此腳本將刪除剪貼板中的文本格式整體風格。有沒有辦法保存所有格式?
我試圖運行這個腳本作爲應用程序(保持打開檢查保存),但它只是一次新的開始後,不編輯任何新的複製文本。我怎樣才能讓這個腳本持續運行?
這裏是我的腳本:
on idle
get the clipboard
replacement of "SqlConnection" by "OleDbConnection" for the result
replacement of "SqlDataAdapter" by "OleDbDataAdapter" for the result
set the clipboard to (replacement of "SqlCommand" by "OleDbCommand" for the result)
end idle
on replacement of oldDelim by newDelim for sourceString
set oldTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to oldDelim
set strtoks to text items of sourceString
set text item delimiters of AppleScript to newDelim
set joinedString to strtoks as string
set text item delimiters of AppleScript to oldTIDs
joinedString
end replacement
如果我使用的頁面或類似的東西,然後我回到開頭,這意味着用手代替一切(當然我用查找/替換,但我有我自己做的,這也正是爲什麼我開始使用applescript - 來防止這種情況發生。當在拍攝的文本中一次又一次地替換相同的3-4個單詞時,有點奇怪) – TabulaRasa 2011-03-24 23:06:19
不,這正是您不需要做的。您可以編程方式進行查找和替換。只需使用GUI腳本來做到這一點 - 我會看看我今晚晚些時候是否無法展示腳本。 – Clark 2011-03-26 18:14:23