If AppleScript Editor isn’t already running, AppleScript wants to launch it in order to display the script. Your final script can be saved as a text file, as a compiled script or as a self-contained. Script Debugger may automatically let you open a script as text, if you attempt to open a compiled script that targets an application which must be launched in order for AppleScript to decompile it.įor example, suppose AppleScript Editor is not running and you open a compiled script that targets AppleScript Editor. The OSA mechanism is only available for Mac OS computers. Open As Text Instead of Launching an Application Warning: If you edit a script with some other script editor application, the stored uncompiled text may no longer match the current state of the bytecode. The uncompiled text is placed in the file’s resource fork (or, if the file is a bundle, in a file within the bundle). Now, click on the Desktop, Press Cmd+Shift+N to create a new. This feature works because when Script Debugger saves a compiled script, it saves not only the compiled bytecode but also the uncompiled text. To get an idea of how recording scripts works, launch Script Editor and select New Document. If the script was originally saved with Script Debugger, you can open the script as text. For example, an application or scripting addition needed by the script is missing, or a script’s internal alias to an application has broken. This indicates that something has gone wrong with the decompilation process. Sounds like a bit of work on the handler might straighten this out, and then you would have "real" plain text with style info, but not font.Sometimes, AppleScript prevents Script Debugger from opening a compiled script file, or shows the file’s contents with raw Apple event codes. I tried the following as a replacement, based on what the original poster said: - set seed_char to «class ktxt» of (("x" as Unicode text) as record)tell sttr to copy StyledTextToRecord(seed_char) to defaultStyleInfobut now the handler throws up an error claiming the clipboard has non-styled text. Therefore, Gevena becomes the default font for the clipboard. And the original poster's comments.It's to do with the seed value "x" on the line: - tell sttr to copy StyledTextToRecord("x" as Unicode text) to defaultStyleInfoUnfortunately, Applescript assigns this "x" a Geneva font right from the start. The only way to get the script name is by getting its path and extracting the name. If you compile your script as an application then 'name of me' will work. However applescripts are run by applescript runner so when you use that on a script you get 'Applescript Runner' as the name. For some reason Applescript assigns what you might expect to be a plain text to a Geneva font! See my previous post on this. The normal way to get the name is by using 'name of me'. This is excellent! Does what it says on the tin! Well, almost.Although you get bolds etc, it isn't plain text - the font is Geneva. property sttr : missing value-> modify the following as neededif sttr is missing value then set sttr to load script alias "Macintosh HD:Library:Scripts:StyledTextToRecord:StyledText Record.scpt"end ifdisplay dialog "I will take the contents of the clipboard (styled text, please) and convert everything to plain text, except for bolds and italics" with icon noteset clipContents to (the clipboard) as styled texttell sttr to copy StyledTextToRecord(clipContents) to styleInfo-> get default styles to reset alltell sttr to copy StyledTextToRecord("x" as Unicode text) to defaultStyleInforepeat with i from 1 to count styleInfo's stylesOn set x to styleInfo's stylesOn's item i if x is not end repeatset the clipboard to (sttr's RecordToStyledText(styleInfo))beep 2here's the forum page where people helped me figure this out: Link Text: Save the script as a plain text file. As record splits out the style and text portions, and »class ktxt» grabs the plain text portion of that. You can save your script as a compiled script that opens in Script Editor and is ready for further editing. However, If you have quick access to AppleScripts through Apple's Script Menu or iKey, then the following line of AppleScript will remove the formatting and leave the plain text (which should then take on the default formatting of whatever program you are pasting it into): set the clipboard to «class ktxt» of ((the clipboard as text) as record)How it works: The as text portion grabs the stylized text from whatever other junk may be surrounding it (which can be significant). for the text to make it look like the text I'm pasting it beside. The problem is that when I paste the text, it brings along the style of other program, which means I now have to change font, weight, size, etc. I frequently find myself wanting to copy and paste text between two programs that use completely different styles for their text.
0 Comments
Leave a Reply. |