Automatically running a script at shutdown

Started by DavidOfMA, January 01, 2016, 03:10:30 PM

Previous topic - Next topic

DavidOfMA

I'd like to write a short script that optionally updates data driven categories and writes pending metadata when I shut down IMatch. Pointers to how best to do that would be helpful, particularly if someone has already more or less done that. I'm assuming I create an Application script, but how to do the rest from a script I haven't been able to figure out.

Thanks,
David

Mario

You could use the application or database script for that.
Please be aware of potential consequences when you do that, especially side effects, slow performance, database timeouts and the like.
I generally don't recommend using the database or application scripts for normal users.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

DavidOfMA

I just want to use a shutdown script to do those two things, write all the pending metadata and update the data-driven categories, as a compromise between having them automatically updated and having to do these things manually. I was unable to find where, in the scripting API, how to do either of these things. If Mario or any of the script programmers out there could point me in the right direction, I'd much appreciate it.

Thanks,
David

Mario

USe a database or application script. See the help for more info.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

thrinn

Regarding pending meta data writeback, have a look at https://www.photools.com/community/index.php?topic=2949.0. Sounds like a task similar to yours.
Thorsten
Win 10 / 64, IMatch 2018, IMA

DavidOfMA

Thorsten,

Thanks, it looks as if John's script will do the metadata part of what I want to do, although apparently it is a brute-force way as, at least a year ago, there was no script way to write all pending metadata in one command.

Now I need to find a way to update data-driven categories from a script, and I should be able to complete this little project. Can anyone point me in the right direction to get this to happen?

Thanks,
David

JohnZeman

David when I saw your post I realized this would be a good thing to have so I'm rewriting two of my scripts to merge them into one.  First to writeback all pending metadata and right after that to refresh all DD categories.  I've only tested it once so far and it seems to do just what you and I want, if I don't find any problems I'll upload it to the scripts section shortly.

DavidOfMA


JohnZeman


DavidOfMA

Thanks! I'll check it out tonight.

I'm always amazed at how helpful this community is at finding ways to customize IMatch.

Aubrey

#10
John,
Nice script, I've added it to favorites.
It removes key strokes when one wants to update all metadata.

I must admit that I haven't worked out how to call it "automatically" as database is exiting.

I'm simply clicking on it, and when its finished closing database... is there another way?

Aubrey.

DavidOfMA

As I understand it, you can call the script, or copy the contents of the script, into an event-triggered function in either the Application script (imatch5.bas) or a Database script (yourdatabasename.bas). If you copy it or call it from the Application script, it can run each time the application starts or quits. If you copy it or run it from the Database script, it can run whenever that database opens, closes, or on a wide selection of other events. I haven't implemented either yet, though when I figure out how to call a script from another script I'll probably put it in the Application script so it runs when IMatch quits. So, the Application script would contain the following:

Private Sub Application_Quit()
[scripting code to write pending metadata and refresh data-driven categories and anything else that needs doing when IMatch closes]
End Sub


Query: If I remember correctly, in IMatch 3.6, you could call a script inside another script by using the "macro" command. I can't find that command in the Help and haven't been able to figure out how to call a script from another script. Can anyone point me to the right place in the Help where this is described?

David

Mario

I think it's called MacroRun. Please see the Basic language help available in the Help menu of the Basic Editor.

Notes: I don't know how such long-running tasks like writing back any number of files interferes with the shut-down of IMatch. I generally not recommend using the database or application scripts. I may remove this feature in a future IMatch version because it's very, very rarely used, if at all, and complex to maintain.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook