Hi Pros,
Could you give me idea how I can check if active document has changed while I’am working. E.g. in the qlab workspace .
Thanks in advance
Sincerely
Kalman
Hi Pros,
Could you give me idea how I can check if active document has changed while I’am working. E.g. in the qlab workspace .
Thanks in advance
Sincerely
Kalman
I took a look at the qlab applescript dictionary, which they publish online, but I didn’t see anything specific to that request. You might just run a simple script inside a qlab tell block that asks for the properties of document 1, like so:
set abc to properties of document 1
And see if there is anything comes up that is related to a modification timestamp.
Without knowing more about the app, it’s difficult to say. If the application saves the document somewhere, you could likely get its file’s modification date property but then you’d need something to compare it to, which would imply running a script upon opening the document and then having it try and monitor the file for changes. Dunno.
As an aside, in many applications on the mac, the document icon on the window bar will fade when the document has been changed from the saved version.
Finally, on their site, they suggest contacting support with applescript questions.
EDIT: the code I suggested originally does not work because the properties of the close button do NOT include whether or not it has the standard “modified” dot indicator, so that’s disappointing.
If for some reason you did want to talk to the close button, here’s better code to address that button specifically:
tell application "System Events"
set frontProc to first application process whose frontmost is true
tell frontProc
get properties of first button of window 1 whose subrole is "AXCloseButton"
end tell
end tell
As @Mockman has said, better to hope that your app (QLab?) properly supports the standard AppleScript dictionary object: document
, which has a modified
property that should do what you want.
]
[ OLD, INCORRECT CODE BELOW: ]
I’m not at my Mac right now, so I can’t test this. But, if you mean that the document has unsaved changes, the standard behavior is that the document windows close button (red circle in upper left corner) gets a dot in it when the document has unsaved changes. That might be visible in the properties of that button.
Run this code to check the properties:
tell app “System Events” to get properties of button 1 of window 1
I’m not sure if the close button is button 1, but I think it is.
Like I said, I’m not at my Mac, so that’s off the top of my head, but hopefully you can try that to see what shows.
I tried to use this command:
abc’s modified
It gives me the answer for my question.
Obviously I have to use it at the proper situation.
Thanks for your reply.
Kalman
Thanks for your reply.
I will try it.
Kalman
Glad it helped.
You can likely consolidate the two lines, eg
set abc to modified of document 1
Some apps are stubborn with their properties and require an extra shove…
set abc to (get modified of document 1)
The parentheses can sometimes make a difference.
Dunno how you plan on using it but if it’s something that you want really handy, export the script to an application and then, when you are using qlab, drag it onto the dock. Then, a single click will run it. When you are done, you can drag it off of the dock until the next time it is needed.
Also, you could likely put it into an idle handler which would stay open after it is launched and periodically get the modified and then you use that to test whether the document was recently modified. That would be more complex however.