AppleScript help - global window data gatherer
So I've had this idea kicking around for a while, and want to finally move forward on it.
Workspaces.
I already have virtual desktops going, and want to take it a step further.
I'd like to have a script that I can run that will query all running apps, and ask them for their list of windows. For each window, it will query the position and size, and the document info. For each document, it will find the file on disk, and make an alias to it in a folder.
Another script will go to that folder, select all, and open via the Finder.
Voila. Need to restart? Run the first script, reboot, run the second, and you're right back where you were. You can keep project folders independent of the storage. For instance, right now I have a massive project (my dissertation) that I'm constantly working on different parts of as subtasks. I could have subtask folders that slice across the rather large storage folders and pick out just the files I need for a specific job until its done, and then I can trash that subtask folder.
So I figure AS is good for this... but I haven't touched AS in months, if not years. Anyone want to give me a hand with it? Anything that comes of it will be posted here for everyone to use.
Workspaces.
I already have virtual desktops going, and want to take it a step further.
I'd like to have a script that I can run that will query all running apps, and ask them for their list of windows. For each window, it will query the position and size, and the document info. For each document, it will find the file on disk, and make an alias to it in a folder.
Another script will go to that folder, select all, and open via the Finder.
Voila. Need to restart? Run the first script, reboot, run the second, and you're right back where you were. You can keep project folders independent of the storage. For instance, right now I have a massive project (my dissertation) that I'm constantly working on different parts of as subtasks. I could have subtask folders that slice across the rather large storage folders and pick out just the files I need for a specific job until its done, and then I can trash that subtask folder.
So I figure AS is good for this... but I haven't touched AS in months, if not years. Anyone want to give me a hand with it? Anything that comes of it will be posted here for everyone to use.
Comments
Open the script editor (on your disk) and then use that to open the AppleScript dictionary for every application you use.
Most applications that are scriptable at all will let you count the open windows and get their positions.
What I have so far is irritatingly close:
on run
set docs to {}
getdocs from "SubEthaEdit"
makealiases(docs)
end run
on makealiases(docs)
tell application "Finder"
set wsref to folder "/Users/smithja/Library/Application Support/Workspaces" -- ERROR
repeat with doc in docs
make new alias file at folder "/Users/smithja" of startup disk to doc
end repeat
end tell
end makealiases
on getdocs from theApp
tell application "SubEthaEdit"
set winds to windows
repeat with wind in winds
set doc to (path of (text document of wind))
set my docs to my docs & doc
end repeat
end tell
end getdocs
The noted line returns "Finder got an error: Can't get folder "/Users/smithja/Library/Application Support/Workspaces"." This path vs. reference thing is really annoying. :P
set wsref to folder "workspaces" of folder "Application Support" of folder "Library" of folder "smithja" of folder "Users"
It seems awkward and there may be another way but this works format works.
Two lines down you'll need a similar change.
I also was unable to create a folder in /tmp/501/, which surprised me. Permissions looked correct. I'm wondering if the fact I'm running it from within Script Editor is the problem.
Maybe, if you feel like creating a whole app, which is not that difficult, you coud do it with AppleScript Studio. You can 'invoke' ASS when you start Xcode.