Hi !
Running an Innovation Center is half challenge, half fun. Everybody expect to have amazing experiences, and they must also be up and ready all the time! We are now updating / upgrading out Toronto IC, with all the new screens, we have some challenges and the screen savers is a good one.
The scenario is very simple: we have several Windows 10 machines connected to screens, and they go offline automatically until the W10 device screen gets back online. That’s the current scenario, however, before this I was working with the standards Windows 10 screen savers.
And I was wondering if I can find a fun way to disable all the screen savers at once using some kind of cool technology. So, after some tweets from @ChloeCondon where she described a cool scenario using Flic buttons, I decided to give them a try. And in my mind this is the process to follow
- Click on a Flic button
- Trigger a MS Flow
- MS Flow will disable the screen saver
It’s seems easy and the connection between Flic and Microsoft Flow is already in preview! We can connect the events click, double click and hold to Microsoft Flow.
The next step is to create a flow to process the event. Somehow I need to send a signal to the physical Windows 10 device to stop the screen saver. In my scenario, the signal will be the creation or update of a file in the remote machine (this is important, so I bolded it!) My 1st idea was to use Microsoft Flow Gateways, which seems to be the perfect tool to share data on-premise with Flows on the cloud.
So I created a blank Flow and added the Flic button trigger. The trigger settings allows me to select the type of event to hookup in the Flow.
And now it was time to setup my next step, the amazing Gateways. And, I didn’t like it. Hard coding paths, user names or password is usually a bad idea. And, after some minutes installing the gateway in a single machine, and this configuration screen, I decided to run some KMs and look for other options.
Lucky me, I already have a distributed cloud File System, very reliable and secure running in all my demo machines: OneDrive. And OneDrive have tons of triggers and actions available for Microsoft Flow!
So I updated my scenario with the following steps
- Click on a Flic button
- Trigger a MS Flow
- MS Flow will save a file in OneDrive
- Somehow this file will disable the screen saver
And the Flow was very simple
Some notes here. The convertTimeZone() is a custom expression I created to have a unique File Name for each created file:
convertTimeZone(utcnow(),’UTC’,’W. Europe Standard Time’,’yyyy MM dd HH mm ss’)
The file content is Flic button information. I really don’t need this, but you never know :D. A sample list of created files:
I’m almost there. Every time I click my Flic button, after a couple of seconds I got a new file in each Windows 10 machine. So now I need some kind of File System Watcher to detect changes and stop the screen saver. I was thinking to create a simple .Net Core Console App to do this, and then I remember:
My ITPro friends usually do magic using PowerShell
A quick search returned this amazing post from Jessica Cook: Flow of the Week: Local code execution and she got almost everything I need. She is using gateways to save a local file and then she uses PowerShell to look for changes into a specific folder. I made some modifications to her PS script and I got my working one:
$watcher = New-Object System.IO.FileSystemWatcher $watcher.Path = "<Folder to Watch>" $watcher.Filter = "*.*" $watcher.IncludeSubdirectories = $true $watcher.EnableRaisingEvents = $true $action = { Start-Process "taskkill /f /im bubbles.scr" } Register-ObjectEvent $watcher "Created" -Action $action while ($true) {sleep 5}
And done! I added my PowerShell script to the startup of the Windows 10 machine and it was amazing. A couple of seconds later after the clic, OneDrive sync the files, the PS script detect a new file and it stop the screen saver!
At the end my full process is
- Click on a Flic button
- Trigger a MS Flow
- MS Flow will save a file in OneDrive
- PowerShell script look for new files in the OD folder
- When a new file is detected, PS script will kill the Screen Saver process
Of course, there is some room for improvement. Like in example, try to do something nicer than kill a windows process. I’ve tried sending keys or moving the mouse using PowerShell but it didn’t work. The kill process is the one!
Also, this is not real-time. Sometimes it sync and works in 1 second and sometimes it tooks 10 seconds, but it’s a great hack to connect dots and use some cool tech.
Happy coding!
Greetings @ Toronto
El Bruno
References