Sign in to follow this  
Followers 0
onefish

How to get default Windows camera save location?

1 post in this topic

#1 ·  Posted (edited)

G'day, as mentioned in my first post HERE, I am working on a script to use the Windows camera app in conjunction with a database on a couple of Win10 tablets. I have all the different components of the AutoIt script working now but I'm just not sure if there's a better way to do some things (I tend to find the complicated solutions first!).

The AutoIt script monitors the camera apps save location for a new file before moving onto the next step and I was originally going to pass the save location to AutoIt from the database as a parameter. Then I kind of thought it might be better to have AutoIt fetch it from the system so I searched Google, the AutoIt forums, etc and I found lots of tutorials to change the default location through the Windows UI but nothing about how to fetch it from a script. I searched the registry too but couldn't find anything conclusive.

All the research led me to understand that the Windows camera app uses libraries to determine the default save location. There isn't any setting to change it within the camera app itself, just the general PC settings for the library. I was playing around with the actual library file and found that it was just a simple xml document and that AutoIt can read it.

So I wrote the below script which extracts the default save path from the CameraRoll.library-ms library and uses it to monitor the directory for a new file to be created (i.e. take a picture).  I'm just not sure if there's a better, more reliable, way to find the default save location? Any advice is welcome.

#include <Array.au3>

$Path = @AppDataDir&"\Microsoft\Windows\Libraries\CameraRoll.library-ms"
$StringPT = "(?:<url>)(.*)(?:</url>)"
$url = StringRegExp(FileRead($Path),$StringPT,1)[0]
$Count = DirGetSize($url,1)[1]
$TimeOut = 20000
$Timer = 0

While $Count = DirGetSize($url,1)[1]
    Sleep(10)
    $Timer = $Timer + 10
    If $Timer >= $TimeOut Then ExitLoop
WEnd

MsgBox(0,"","Old File Count: "&$Count&@CRLF&"New File Count: "&DirGetSize($url,1)[1],5)

PS> If anyone actually runs this script then the file count may be incorrect. Mine is off by 1 (probably a hidden config file or something) but that isn't important for my purposes, just need to know when it changes.

Edited by onefish

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0