But to no avail -- it returns false rather than true. (Meaning, I assume, that '--Edited' is not technically part of the window title.)
If anyone can tell me whether or not there is something in KM that can detect the document's Saved/Edited state, I would very much appreciate it. Thanks.
Yes, you would think that would work, but TextEdit at least leaves the Save menu permanently enabled, even when no save is required (poor programming, but it is Apple, so I suppose they can do what they like).
Thanks for the help, Phillippe and Peter. Hopefully some day Apple will toggle the state of the Save menu item appropriately.
Is there a way Iām unaware of to detect a fileās āEditedā state via AppleScript? (Iām assuming the answer is ānoā, so no need to reply unless my assumption is incorrect.)
So, it looks like the File > āRevert toā menu will have n == 1 items if itās currently in an unchanged state, and will have n >= 2 items if itās modified and unsaved. I just started using KM a couple of days ago, so unfortunately, I donāt know how to proceed with that information, but if you do figure it out, please post the solution as I think the general workflow for this would be really useful!
A good catch, indeed ā thanks woof; improved one of my macros vastly. Much appreciated.
Peter, forgive my naivete, but can I ask what function the ā^ā preceding āLast Savedā serves? (I am guessing that the ā.*ā following it is Regex for āany number of any charactersā, but I am not entirely certain.)
You would think that the modified property of a document would tell you, but with both Script Editor and TextEdit, modified of the front document is false even after typing a character in that document. I havenāt tried other applications. Can someone explain this?
Iām getting inconsistent, and in some cases somewhat mysterious, results across applications:
TextEdit
Unmodified document:
Type a character:
Script Editor
Unmodified document:
Type a character.
Script Debugger
Unmodified Document:
Type a character:
Menu item unchanged.
Xcode
Unmodified Document:
Type a character:
I could go on.
In most cases checking the state of the buttons at the extreme upper left of the window works (I had to snapshot all three and set fuzziness all the way to the left to get it to work), but not all: in Xcode, the button doesn't change when a file is modified.
Also, you would expect the File>Save menu item to be grayed out when there are no modifications, but that isnāt the case ā at least I haven't noticed an application where it is. Upon reflection, though this was always right in front of my face, it does seem bizarre.
Thatās really weird. I certainly expected them to do so, but they don't for me. All I did was type a character in a saved file then did something like
the modified of the front document of application "TextEdit"
How? I never use it, but it does sometimes get in the way, especially with files that havenāt been saved for the first time.