Executing stuff on shutdown, plus standby stuff.

If you have a question or need help, this is the place to be.
User avatar
kgschlosser
Site Admin
Posts: 4754
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Executing stuff on shutdown, plus standby stuff.

Post by kgschlosser » Sun May 14, 2017 10:34 pm

and here is a bunch more events for power related things

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

nYce
Posts: 42
Joined: Wed Mar 28, 2018 2:29 am

Re: Executing stuff on shutdown, plus standby stuff.

Post by nYce » Thu Aug 30, 2018 8:17 pm

And how can i delay the shutdown now?

I want to do some stuff (like powering down the projector (CEC+), send a message to my smartphone (Autoremote)), but it seems that doesnt delay the shutdown.

Probably i can open an unsaved document and kill it after i got all my stuff done?

The wait doesnt seem to delay the shutdown in any way..

User avatar
kgschlosser
Site Admin
Posts: 4754
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Executing stuff on shutdown, plus standby stuff.

Post by kgschlosser » Fri Aug 31, 2018 3:00 pm

I am thinking this is going to give you a solution.

backup the file c:\program files (x86)\eventghost\plugins\system\__init__.py
download the 2 attached files and put them into c:\program files (x86)\eventghost\plugins\system
overwrite the __init__.py file

this will generate a couple new events

System.EndSession.SystemShutdown = Shutdown/Restart
System.EndSession.EventGhostShutdown = System is requesting the close of EventGhost
System.EndSession.LogOff = Local Logoff
System.EndSession.EventGhostForcedClose = System is forcing the close of EventGhost (out of memory.. things like that)


There are 2 new actions.

Shutdown\Block Shutdown
Shutdown\Block Logoff

They will do exactly as they state. with the Block Shutdown if you want to disable it run the same action with the message field blank.

This is going to stall the shutdown while the event System.EndSession.SystemShutdown is running. so any actions you are performing will get run before the shutdown occurs.

I have not fully tested this yet. but if someone wants to give it a go it should work.
Attachments
ShutdownNotifier.py
(3.17 KiB) Downloaded 28 times
__init__.py
(74.32 KiB) Downloaded 27 times
If you like the work I have been doing then feel free to Image

cvben
Posts: 38
Joined: Wed Jun 07, 2017 8:30 pm

Re: Executing stuff on shutdown, plus standby stuff.

Post by cvben » Fri Aug 31, 2018 10:15 pm

I'm not sure I've had an issue with a "wait" command not working, but as a temporary workaround you could have an event trigger the stuff you want to do before shutdown, then at the end of the event chain use the triggerevent function that actually shuts down. Thats what I always do to avoif any conflicts or oddity.

ex:

ir button press event::
do x
do y
do z
trigger "actual shutdown event" (the delay on trigger works for certain on my end)

then there would be a separate macro which listens for the "actual shutdown event"

User avatar
kgschlosser
Site Admin
Posts: 4754
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Executing stuff on shutdown, plus standby stuff.

Post by kgschlosser » Sat Sep 01, 2018 12:28 am

I am not sure But I do know that some remotes are hard coded for the shutdown through the driver it's self. and using EventGhost is not necessarly an option if you want to retain the use of that button.


Or if you use the mouse and shutdown the computer but still want EventGhost to perform a specific set of actions. that is where the above would come in useful.

Also if you didn't want the accidental shutdown of the computer. This can be used to block that shutdown process. At the present state of the additions it will display a screen telling you the reason why it cannot shutdown with the option to force terminate EventGhost. I can add an action that will simply stop windows from shutting down no matter what. if that is something that is wanted.
If you like the work I have been doing then feel free to Image

farbox
Experienced User
Posts: 58
Joined: Fri Jul 18, 2008 1:44 am

Re: Executing stuff on shutdown, plus standby stuff.

Post by farbox » Thu Feb 28, 2019 3:51 pm

Hi all!

Just got myself a Pulse8 HDMI CEC, and playing around with it.

My question is related to this topic.

For switching the TV off on shutdown I have played with the suggestions in this post, and using Main.OnEndSession works. However this also switches TV off when I restart windows, obviously cause windows ends on restart as well!
What event can I use, when I specifically tell windows to shutdown, eg from start menu? Is there one?

Thanks in advance!

PS While searching a lot of reference was made to a couple of threads eg the one below which seems to have disappeared, any ideas what it had?
http://www.eventghost.org/forum/viewtop ... f=2&t=2011

jachin99
Experienced User
Posts: 598
Joined: Sat Feb 13, 2016 8:39 pm

Re: Executing stuff on shutdown, plus standby stuff.

Post by jachin99 » Thu Feb 28, 2019 5:12 pm

EG lost its .org domain but if you change it to .net like so viewtopic.php?f=2&t=2011 it works

farbox
Experienced User
Posts: 58
Joined: Fri Jul 18, 2008 1:44 am

Re: Executing stuff on shutdown, plus standby stuff.

Post by farbox » Fri Mar 01, 2019 9:53 am

Thanks for that!

User avatar
kgschlosser
Site Admin
Posts: 4754
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Executing stuff on shutdown, plus standby stuff.

Post by kgschlosser » Fri Mar 01, 2019 5:56 pm

there is no way of telling the difference between say a shutdown or a restart. This was not something that was coded into windows.

The easiest way for you to be able to set something up like this is by use of a remote. and this is how I would set this up.
I would make a button a "restart" button. and that button when pressed would start a timer. and inside of say 10 seconds you would have to enter 4 digits from the remote. and the restart would begin first by disabling the action that turns off the TV. and then it would run the shutdown.

the whole password retry thing would be so that the button cannot be accidentally pressed.
If you like the work I have been doing then feel free to Image

rgb
Posts: 2
Joined: Thu Mar 28, 2019 3:11 pm

Re: Executing stuff on shutdown, plus standby stuff.

Post by rgb » Thu Mar 28, 2019 3:24 pm

kgschlosser wrote:
Fri Aug 31, 2018 3:00 pm
I am thinking this is going to give you a solution.

backup the file c:\program files (x86)\eventghost\plugins\system\__init__.py
download the 2 attached files and put them into c:\program files (x86)\eventghost\plugins\system
overwrite the __init__.py file

this will generate a couple new events

System.EndSession.SystemShutdown = Shutdown/Restart
System.EndSession.EventGhostShutdown = System is requesting the close of EventGhost
System.EndSession.LogOff = Local Logoff
System.EndSession.EventGhostForcedClose = System is forcing the close of EventGhost (out of memory.. things like that)


There are 2 new actions.

Shutdown\Block Shutdown
Shutdown\Block Logoff

They will do exactly as they state. with the Block Shutdown if you want to disable it run the same action with the message field blank.

This is going to stall the shutdown while the event System.EndSession.SystemShutdown is running. so any actions you are performing will get run before the shutdown occurs.

I have not fully tested this yet. but if someone wants to give it a go it should work.

I've tried to use these Shutdown events and actions, but so far I am unable to get them to work in Windows 10. I am on the Insider Skip ahead preview if that makes a difference build 18865. I copied both files to the EG\Plugin\System folder and when I start EG, the 2 actions do show up in the actions list.

I added the System.EndSession.SystemShutdown event with an Autoremote Send Message action and a Block ShutDown action after that but it doesn't seem to send the message to AutoRemote and it doesn't block the shutdown either. Same with the System.EndSession.LogOff event as well.

I noticed that all of the other plugins in the System folder also had a .pyc file to match but the ShutDownNotifier does not have one. Is that file needed?

I'm sure I am doing something wrong but I haven't been able to figure it out yet. Any help would be appreciated!

User avatar
kgschlosser
Site Admin
Posts: 4754
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Executing stuff on shutdown, plus standby stuff.

Post by kgschlosser » Thu Mar 28, 2019 5:05 pm

return the system files back to their original ones and install this plugin instead

viewtopic.php?f=9&t=10276&p=52662#p52662
If you like the work I have been doing then feel free to Image

rgb
Posts: 2
Joined: Thu Mar 28, 2019 3:11 pm

Re: Executing stuff on shutdown, plus standby stuff.

Post by rgb » Thu Mar 28, 2019 5:24 pm

kgschlosser wrote:
Thu Mar 28, 2019 5:05 pm
return the system files back to their original ones and install this plugin instead

viewtopic.php?f=9&t=10276&p=52662#p52662
That Works!!! Thanks you very much.. I really do appreciate it!

User avatar
kgschlosser
Site Admin
Posts: 4754
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Executing stuff on shutdown, plus standby stuff.

Post by kgschlosser » Thu Mar 28, 2019 9:56 pm

no worries m8. I made that plugin because it is a good feature to have. and we might at some point merge it with the core. it is something that should be included in the core.
If you like the work I have been doing then feel free to Image

Post Reply