Hi,
I am using USB UIRT to control my VLC player using EventGhost on my laptop.
I need that when my laptop goes into battery mode from Ac mode, then eventghost should pause VLC player, if it is running.
How can i achieve this?
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.
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.
How to respond on power failure?
Re: How to respond on power failure?
I don't run from a laptop. I know EG posts several power messages, like idle/unidle. Does it generate any messages for switching the power mode? If so, just attach action to that event. Otherwise, it would be necessary to change the power plugin code to add that event....
Brett
Brett
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: How to respond on power failure?
Currently you only get "POWERSTATUSCHANGE" events when switching between battery/line back and forth
To find out if running on batteries (or mains) a plugin or eg itself would need to dig "deeper" calling GetSystemPowerStatus and checking the SYSTEM_POWER_STATUS structure
To find out if running on batteries (or mains) a plugin or eg itself would need to dig "deeper" calling GetSystemPowerStatus and checking the SYSTEM_POWER_STATUS structure
Code: Select all
typedef struct _SYSTEM_POWER_STATUS {
BYTE ACLineStatus;
BYTE BatteryFlag;
BYTE BatteryLifePercent;
BYTE Reserved1;
DWORD BatteryLifeTime;
DWORD BatteryFullLifeTime;
} SYSTEM_POWER_STATUS, *LPSYSTEM_POWER_STATUS;
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: How to respond on power failure?
I just elaborated a bit and found that this simple script will generate an event when changing from AC to Battery and vice versa. Below is also a picture showing my configuration. You just have to create a macro with a python script and copy the code below. Then you add the system event "System.PowerStatusChange" as I did
You can then use the "Main.Energy.Source.Battery" event to control another macro to pause VLC
Best regards, Walter
You can then use the "Main.Energy.Source.Battery" event to control another macro to pause VLC
Best regards, Walter
Code: Select all
import ctypes
import ctypes.wintypes
class SYSTEM_POWER_STATUS(ctypes.Structure):
_fields_ = [("ACLineStatus", ctypes.c_byte), ("BatteryFlag", ctypes.c_byte), ("BatteryLifePercent", ctypes.c_byte), ("Reserved1", ctypes.c_byte), ("BatteryLifeTime", ctypes.wintypes.DWORD), ("BatteryFullLiveTime", ctypes.wintypes.DWORD)]
sps = SYSTEM_POWER_STATUS()
ctypes.windll.kernel32.GetSystemPowerStatus(ctypes.byref(sps))
status_constants = ["", "High", "Low", "Critical", "Charging", "No system battery", "Unknown"]
ac_constants = ["Battery", "AC Power", "Unknown"]
hours, rest = divmod(sps.BatteryLifeTime , 3600)
minutes, seconds = divmod(rest, 60)
#print "Battery charge status:", status_constants[sps.BatteryFlag]
#print "Energy source:", ac_constants[sps.ACLineStatus]
#print "Battery life percentage: %s%%" % sps.BatteryLifePercent
#print "Estimated remaining time: %s:%s:%s" % (hours, minutes, seconds)
eg.TriggerEvent("Energy.Source."+ac_constants[sps.ACLineStatus])
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM