However, I don't trust ChatGPT to have anything like the final word.
<rant>
A few days ago I asked ChatGPT for help in how to script opening a TextEdit file with preset parameters. I asked:
What properties do I use, and how do I use them, to create a new TextEdit document with a blue background on the entire page and white text, with a size 600px wide and 300px high?
And what I got was:
To create a new TextEdit document with specific properties like a blue background, white text, and a specific size, you can use the following AppleScript:
tell application "TextEdit"
activate
set newDoc to make new document with properties {text:"", background color:{0, 0, 65535}, color:{65535, 65535, 65535}, width:600, height:300}
end tell
This script tells the TextEdit application to create a new document with the specified properties. Here's what each property does:
text
: The initial text content of the document (empty in this case).
background color
: Sets the background color to blue (RGB values: {0, 0, 65535}).
color
: Sets the text color to white (RGB values: {65535, 65535, 65535}).
width
and height
: Set the dimensions of the document to 600 pixels wide and 300 pixels high.
You can adjust the RGB values and size to customize the appearance and dimensions of your new TextEdit document as needed.
That's a very nice answer, with a lovely, detailed explanation, and it's totally erroneous. It doesn't work. There is NO background color
parameter and separate width
and height
parameters are not the way to set the window size, you have to use the size
property instead which is a list of two values.
After five round trips of my reporting the error messages that I got and it tyring a slightly different script, it suggested changing background color
to document color
which didn't work either. Then it suggested trying page color
. It was guessing in the dark no better than I could. Finally it admitted:
It seems that TextEdit does not provide direct AppleScript support for setting the page background color. You can set text style attributes such as font, size, and color for text, but not the overall page background color.
To set the page background color, you may need to resort to automating GUI interactions, which can be more complex. This involves using tools like System Events to simulate user actions, which is less straightforward than direct AppleScript commands.
If setting the page background color is crucial for your workflow, you might want to consider using a more scriptable text editor that provides better automation support for this specific task.
This is far from the first time that I have watched ChatGPT make guesses in the dark that all seemed reasonable, when the issue was that the task could not be done in the direction that it was trying to go.
For more of it's hand-waving appearance of expertise where there is little, I notice that for simulating user GUI interactions to get the page background color, it does not mention KBM, while for positioning icons it seems to think that KBM can do magic.</rant>
So please forgive me if I am mistrustful of ChatGPT's advice.