Turn screen On and Off

Hello,

i execute a worklfow that shows various information as it comes available. However the screens used are not 24/7 rated. Is there a activity which can turn the monitor on if there is a new information and turn it off after a specific amount of time?

Greetings randomtrash

1 Like

It is really interesting question. I am also interesting to get answer…

Regards
Balamurugan.S

Hi @randomtrash,
I haven’t heard about such activity. Anyway I think it’s not that easy. Monitor is controlled by graphic card and it’s stays up as long as graphic card gives the signal to it. This probably requires something related to graphic card driver but I guess it could provide some issues too. What if you want to use computer but screen is off and awaits for signal from workflow? :thinking:

2 Likes

I am not sure if the following code works or not. I have not tested but it will give you some idea about it.

Ref - c# - Turn on/off monitor - Stack Overflow

namespace MonitorOff {

    public enum MonitorState {
        MonitorStateOn = -1,
        MonitorStateOff = 2,
        MonitorStateStandBy = 1
    }

    public partial class Form1 : Form {
        [DllImport("user32.dll")]
        private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);

        public Form1() {
            InitializeComponent();
            SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
        }

        void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e) {
            SetMonitorInState(MonitorState.MonitorStateOff);
        }

        private void button1_Click(object sender, EventArgs e) {
            SetMonitorInState(MonitorState.MonitorStateOff);
        }

        private void SetMonitorInState(MonitorState state) {
            SendMessage(0xFFFF, 0x112, 0xF170, (int)state);
        }
    }
}

Regards,
Karthik Byggari

4 Likes