This project has moved. For the latest updates, please go here.

Random Element in Blackouts?

Dec 16, 2014 at 1:25 AM
Edited Dec 16, 2014 at 1:27 AM
Good job!
Here's a function that could be useful:
Having the option to set random Blackout Start and End times within a specified range. E.g.
  • Blackout Starts sometime between 17:00:00 & 18:00:00
  • Blackout Ends sometime between 09:00:00 & 10:00:00
Would be more than pleased to donate £15 for this.
Thanks!

Cornelius 2^16-1
Coordinator
Dec 23, 2014 at 2:58 PM
Hi,

The latest release of Move Mouse allows for the underlying XML (the file that stores the various settings) to be manipulated whilst it is running. That means we can use scripts to change the settings on the fly, which will be refreshed when Move Mouse pauses.

Here is some PowerShell code that should do exactly what you require:
$MoveMouseXml = Join-Path $env:APPDATA "Ellanet\Move Mouse\Move Mouse.xml"

if (Test-Path -Path $MoveMouseXml) {
    $RandomBlackoutStartTime = (Get-Date -Hour 18 -Minute 0).AddSeconds((Get-Random -Minimum 0 -Maximum (New-TimeSpan -Minutes 60).TotalSeconds))
    $RandomBlackoutEndTime = (Get-Date -Hour 9 -Minute 0).AddSeconds((Get-Random -Minimum 0 -Maximum (New-TimeSpan -Minutes 60).TotalSeconds))
    $XmlDoc = New-Object System.Xml.XmlDocument
    $XmlDoc.Load($MoveMouseXml)
    $XmlDoc.SelectSingleNode("settings/blackouts").RemoveAll()
    $BlackoutNode = $XmlDoc.CreateElement("blackout")
    $BlackoutNode.InnerXml = "<start/><end/>"
    $BlackoutNode.SelectSingleNode("start").InnerText = $RandomBlackoutStartTime.ToString("HH:mm:ss")
    $BlackoutNode.SelectSingleNode("end").InnerText = $RandomBlackoutEndTime.ToString("HH:mm:ss")
    $XmlDoc.SelectSingleNode("settings/blackouts").AppendChild($BlackoutNode)
    $XmlDoc.Save($MoveMouseXml)
}
Simply copy this into a Start script, and each time Move Mouse starts, the blackout schedules will be updated.

Let me know how you get on.

sw3103
Marked as answer by sw3103 on 1/26/2015 at 4:52 PM