AppleScript 新手在这里....
尝试设置一个applescript,它将替换.htm文件中的几行代码
这很丑陋,但有效:
tell application "Finder"
activate
tell application "System Events"
key down {command}
keystroke "a"
key up {command}
end tell
end tell
tell application "Finder"
activate
set fileCount to count files in front window
set fileCountAlert to fileCount
end tell
tell application "System Events"
tell process "Finder"
tell menu bar 1
tell menu bar item "File"
tell menu "File"
tell menu item "Open With"
tell menu "Open With"
click menu item "TextEdit"
end tell
end tell
end tell
end tell
end tell
end tell
delay 3
end tell
repeat until fileCount = 0
tell application "TextEdit"
activate
tell application "System Events"
key down {command}
keystroke "f"
key up {command}
--delay 1
keystroke "BORDER=1"
delay 0.5
keystroke tab
keystroke tab
keystroke "BORDER=0"
delay 0.5
key down {command}
keystroke "w"
key up {command}
delay 0.5
end tell
end tell
set fileCount to (fileCount - 1)
end repeat
tell application "Finder"
display dialog "Completed Adjusting " & fileCountAlert & " files."
end tell
我也尝试过使用这样的东西......但是这个东西根本不起作用......
set the search_document to (choose file)
replaceText("BORDER=1", "BORDER=0", search_document)
on replaceText(search_string, replacement_text, this_document)
tell application "TextEdit"
open this_document
set AppleScript's text item delimiters to the search_string
set this_text to the text of the front document as list
set AppleScript's text item delimiters to the replacement_text
set the text of the front document to (this_text as string)
close this_document saving yes
end tell
end replaceText
最后......我试图弄清楚如何使用这样的东西点击applescript中的按钮:
tell application "System Events"
tell process "TextEdit"
click button "All" of scroll area of window "3.htm"
end tell
end tell
**但是 - 我在这里不断收到错误。我正在使用 UIElementInspector 应用程序,但没有运气。
想知道是否有人有任何快速帮助建议?**