gmiller
3 discussion posts
I have a situation where I am remote controlling a computer in a way that does not blank the monitors on connection. Is there a way to define a DisplayFusion function to either blank the monitors or turn their brightness to zero while still being able to use the remote connection?
Collin Chaffin
69 discussion posts
I just finished writing this macro function (rewriting I use it today outside of DF) which utilizes nirsoft's nircmd. I have a question for Keith perhaps I missed in the macro docs but is there a built-in call I can make to always return the DF binaries install/execution path? I would like to utilize that in the function so that "in order to run" we can say you must always drop nircmd.exe in the DF install folder and be done, rather than having to edit paths, use system path, etc.
One I get clarification from Keith, I'll publish the code to the downloadable function library. My function will sleep all active attached monitors, and lock the workstation requiring a full unlock upon keyboard/mouse move.
EDIT: All remote functions work fine upon monitor sleep but I will also release a non-workstation-lock 2nd function which should meet your requirements as a workstation lock would impact remoting.
Dec 22, 2014 (modified Dec 22, 2014)
•
#3
Collin Chaffin
69 discussion posts
Here you go. I already submitted to be published to the library as well. I submitted 2 versions, the one here that sleeps all active monitors, and then also the one I use which also sleeps and initiates the workstation lock so that upon wakeup it is a full unlock required.
Assuming they approve quickly you should be able to pull it down using the settings GUI within a couple days, but if you need it sooner you can copy/paste from here (note the comment formatting is most likely screwed up in the web post):
using System;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
//////////////////////////////////////////////////////////////////////////////////////////
////
//Author: Collin Chaffin//
////
//Description:This function sets all active monitors to S3 sleep state but//
//does NOT lock workstation.//
////
//NOTE: THIS FUNCTION UTILIZES NIRSOFT'S NIRCMD.EXE//
//DOWNLOAD FROM:http://www.nirsoft.net/utils/nircmd.html//
//COPY ONLY NIRCMD.EXE TO THE DISPLAYFUSION ROOT APPLICATION FOLDER//
//USUALLY C:\Program Files (x86)\DisplayFusion for 64 bit//
////
//////////////////////////////////////////////////////////////////////////////////////////
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
// Set up exe path and arguments
string path = System.Windows.Forms.Application.StartupPath;
string nircmdPath = path + "\\nircmd.exe";
string sleepArgs = "monitor async_off";
ProcessStartInfo sleep = new ProcessStartInfo();
sleep.Arguments = sleepArgs;
sleep.FileName = nircmdPath;
// Hide windows
sleep.WindowStyle = ProcessWindowStyle.Hidden;
sleep.CreateNoWindow = true;
// Disable the annoying publisher verification
sleep.UseShellExecute = false;
// Execute and wait for it to finish
using (Process proc = Process.Start(sleep))
{
proc.WaitForExit();
}
}
}
Collin Chaffin
69 discussion posts
EDIT not sure why forum posted a reply to this thread when I was trying to reply to another, sorry!
Dec 22, 2014 (modified Dec 22, 2014)
•
#5
gmiller
3 discussion posts
Wow! This is pretty cool. I enabled the script, assigned it to a hotkey and sure enough, the monitors go right into sleep mode. Only problem is that the sleep mode cancels as soon as a key is pressed or the mouse moves, either directly or through a remote session.
It would be sweet if there was a way to keep the monitors sleeping while a remote session was active.
Collin Chaffin
69 discussion posts
Ahh so if it's a VNC-like remoting then yes I suppose that mouse-move would look the same as a local action and wake them. Let me think about it and what options might be.