Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Disable a macro based on sleep/awake?

If you have a question or need help, this is the place to be.
Post Reply
jachin99
Experienced User
Posts: 614
Joined: Sat Feb 13, 2016 8:39 pm

Disable a macro based on sleep/awake?

Post by jachin99 »

I want to disable an action within a macro I have setup to execute an IR blast when I press the wake button on my MCE remote but first, I'll explain why in a little more detail. I have my PC setup to sleep normally in order to save power, and I want to be able to press the power button, and have my PC wake up, and turn my TV on. While this happens for the most part, If I turn the machine off, and it wakes for a recording or some other task, I end up turning the TV on but putting the computer to sleep. So what I'm looking for is a way to read the power state of the machine, and have EG make a decision about weather it should try to wake the machine or not based on the machine's power state. In order to wake the machine I am using the WOL function if that helps. How can I accomplish this and thanks
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: Disable a macro based on sleep/awake?

Post by Flyingsubs »

I'm not sure you can read the power state. Once the computer is on then Eventghost can function. I believe the media remote only triggers the computer to turn on. When the computer turns on, do you want to know if it came out of sleep vs a normal boot up?
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Disable a macro based on sleep/awake?

Post by kgschlosser »

Here are the list of events that are generated relating to logging off and on and suspend types of things

Code: Select all

Main.OnInit
Main.OnClose
Main.OnEndSession
System.ConsoleConnect
System.ConsoleDisconnect
System.RemoteConnect
System.RemoteDisconnect
System.SessionLogon
System.SessionLogoff
System.SessionLock
System.SessionUnlock
System.SessionRemoteControl
System.Suspend
System.Resume
System.ResumeAutomatic
System.AwayMode.Entering
System.AwayMode.Exiting

and here is a bunch more events for power related things

Code: Select all

System.Monitor.Off
System.Monitor.On
System.Monitor.Dim

System.PowerSource.Line
System.PowerSource.Battery
System.PowerSource.UPS

System.BatteryLevel.0%
thru
System.BatteryLevel.100%

System.PowerSaving.Off
System.PowerSaving.On

System.PowerProfile.PowerSaver
System.PowerProfile.HighPerformance
System.PowerProfile.Balanced

windows xp only
System.BatteryLevel.Low
System.OemEvent
System.QuerySuspendFailed
System.ResumeCritical
System.QuerySuspend

If you like the work I have been doing then feel free to Image
jachin99
Experienced User
Posts: 614
Joined: Sat Feb 13, 2016 8:39 pm

Re: Disable a macro based on sleep/awake?

Post by jachin99 »

That looks like it will help but I also need to know if system.suspend puts the computer into sleep or hibernation. This gets me a step closer but if I'm not mistaken generating an event in the log when the computer goes to sleep isn't going to work quite as well as asking the computer "are you asleep or awake right now?" and generating an event based on that answer Either way I'll try to set something up and see how it works out
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Disable a macro based on sleep/awake?

Post by kgschlosser »

I would have to check on that. I do not know to what extent you can ask the computer anything if it's sleeping. Hence why servers are always on. 100% because I know that unless I get woken up from sleeping to ask me something I sure as hell am not going to answer you. I am thinking computers are very much the same way
If you like the work I have been doing then feel free to Image
jachin99
Experienced User
Posts: 614
Joined: Sat Feb 13, 2016 8:39 pm

Re: Disable a macro based on sleep/awake?

Post by jachin99 »

Thats true but If I see someone laying down, and they don't respond to my voice It would be a safe bet that the person probably is sleeping. Maybe there is a way to accomplish the opposite, and have windows constantly saying "I'm awake"
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Disable a macro based on sleep/awake?

Post by kgschlosser »

Yes that can be done. Set a variable eg.globals.system_active = True Add this as a PythonCommand to your autostart as the first item. Then create 2 macros one with system.resume and the other with system.suspend as the events. And add Python command actions for each setting the eg.globals.system_active variable to True for the resume. And False for the suspend. Now you have a way to check by doing if eg.globals.system_active:
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Disable a macro based on sleep/awake?

Post by kgschlosser »

Now I would have to look again but the resume and resume automatic are created by how the machine gets woken up. The resume automatic should always get triggered and the resume will only trigger if the resume was caused by user input. Meaning you pressed a key on the keyboard
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Disable a macro based on sleep/awake?

Post by kgschlosser »

I would also assume pressing a button on. The remote would cause the resume event as well
If you like the work I have been doing then feel free to Image
Post Reply