Minor glitch in opening TextEdit file

I’ve written an Applescript that calls up my song charts in TextEdit when I play songs on Ableton. I’m about ten days into working with Applescript. :slight_smile:

Here is part of the script that contains a minor glitch:

tell application “Finder”
open file “Love Shack” of folder “L” of folder “SONG TXT’s” of folder “Desktop” of folder “myComputer” of folder “Users” of startup disk
end tell
tell application “TextEdit” to set the bounds of the front window to {0, 0, 679, 768}
end tell

What happens is that the TextEdit file opens in the wrong position first and then is repositioned, and the repositioning creates a visual glitch.

Instead of the file opening and then being repositioned, is there a way of putting the “set to bounds” command in the first tell block so that the file is only opened once, in the final correct position?

Hi Ian whats the visual Glitch?

Something like this works for me and looks okay:

tell application "TextEdit"
	activate
	open alias "Dean Martin:Users:steve:Desktop:ToDo.rtf"
	set bounds of window 1 to {0, 0, 679, 768}
end tell

Ian is saying the window opens in a default position, and then moves to the position set in the script.
And he doesn’t like that.

Ian, I’m afraid there’s nothing you can do. You cannot set the position of a non-existent window.
There’s apps that save a window’s settings when it is closed, but TextEdit is not one of those.

Although, when I tried it, the window’s size seemed to be remembered.

Thanks pidge1 and alastor933 for your replies. :slight_smile:

The file opens in one position and then changes to another in a few ms, that’s the visual glitch. It’s livable but looks kinda jerky.

The files are all .txt files I made up on SimpleText so I’m looking for another popular app that opens those but remembers screen positions.

It did still happen when I tried the script you posted pidge1 (thanks) and like alastor933 said, there do seem like times when the screen is saved in the correct position (?) but it seems unpredictable. I tried resaving them as .rtf files but had the same problem.

The solution is probably to find another app that allows screen positions to be set.