Sign in to follow this  
Followers 0
cypher175

Invoke an Action Upon User: Switch User, Log Off, Stand By, Turn Off, Restart..?

16 posts in this topic

I need to Invoke an Action Upon a User: Switch User, Log Off, Stand By, Turn Off, Restart..

So when the user executes any of those tasks a certain action will happen like send a key or kill a process Ect..

Can anything like this be done..??

Share this post


Link to post
Share on other sites



I need to Invoke an Action Upon a User: Switch User, Log Off, Stand By, Turn Off, Restart..

So when the user executes any of those tasks a certain action will happen like send a key or kill a process Ect..

Can anything like this be done..??

Shutdown() function?

When the words fail... music speaks

Share this post


Link to post
Share on other sites

so how can I determine what the user does though..??

I want to send a key to a certain window when the user does any of these actions: Switch User, Log Off, Stand By, Turn Off, Restart..

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

so how can I determine what the user does though..??

I want to send a key to a certain window when the user does any of these actions: Switch User, Log Off, Stand By, Turn Off, Restart..

You can do following:

Go to Start, Run, gpedit.msc

after that: Computer configuration, Windows Settings, Scripts (Startup/Shutdown).

You put the scripts you want to run on shutdown/reboot there... :)

for Logoff you go under:

User Configuration, Windows Settings, Scripts (Logon/Logoff).

Edited by skysel

Share this post


Link to post
Share on other sites

You can do following:

Go to Start, Run, gpedit.msc

after that: Computer configuration, Windows Settings, Scripts (Startup/Shutdown).

You put the scripts you want to run on shutdown/reboot there... :)

for Logoff you go under:

User Configuration, Windows Settings, Scripts (Logon/Logoff).

That doesn't distinguish the shutdown type.

Share this post


Link to post
Share on other sites

That doesn't distinguish the shutdown type.

But it's as close as it is..for free :)

Share this post


Link to post
Share on other sites

is there anyway to tell when the user clicks any one of those buttons "Switch User, Log Off, Stand By, Turn Off, Restart" and then based on what button was clicked perform an action for it..??

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

From this forum http://www.vbforums.com/showthread.php?t=502073 ...

Add system power mode event handlers to the load event on your app:

Code:

'add the handlers for the system standby, resume, and shutdown AddHandler Microsoft.Win32.SystemEvents.PowerModeChanged, AddressOf PowerModeChanged AddHandler Microsoft.Win32.SystemEvents.Sessionending, AddressOf Sessionending

Then simply set up events to match:

Code:

Private Sub PowerModeChanged(ByVal sender As System.Object, _ ByVal e As Microsoft.Win32.PowerModeChangedEventArgs) Select Case e.Mode Case Microsoft.Win32.PowerModes.Resume 'windows is resuming from sleep Case Microsoft.Win32.PowerModes.Suspend 'goodnite windows End Select End Sub Private Sub Sessionending(ByVal sender As System.Object, _ ByVal e As Microsoft.Win32.SessionendingEventArgs) Select Case e.Reason Case Microsoft.Win32.SessionendReasons.Logoff 'logoff Case Microsoft.Win32.SessionendReasons.SystemShutdown 'shutdown End Select End Sub

This is for VBScripts.. I guess using Scriptomatic you could figure out for Autoit?

Edited by skysel

Share this post


Link to post
Share on other sites

can Scriptomatic convert that into Autoit?

Im not to familiar with doing such a thing..

Share this post


Link to post
Share on other sites

can Scriptomatic convert that into Autoit?

Im not to familiar with doing such a thing..

No. Scriptomatic doesn't "convert" anything and furthermore it only generates WMI scripts.

You cannot "capture" the click of the shutdown buttons because you cannot intervene with the shutdown process once it has been triggered, unless there is some kind of callback registered.

Share this post


Link to post
Share on other sites

so what can I do then..??

What is meant by this..?? "I guess using Scriptomatic you could figure out for Autoit?"

Share this post


Link to post
Share on other sites

I saw a script of an user that intercepts the windows message of shutdown etc, just search in the forum

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Maybe this thread contains some useful info for you

#607489

At least regarding the power-down functions. Intercept and prevent them and react as you like. Guess there are similar ways for log-off events etc...

Regards

Edit: Lol, 30 seconds to slow :)

Edited by KaFu

Share this post


Link to post
Share on other sites

search in the helpfile for OnAutoitExit then take a look at the @EXITMETHOD

Share this post


Link to post
Share on other sites

search in the helpfile for OnAutoitExit then take a look at the @EXITMETHOD

Yeah i just found that OnAutoitExit and it seems to work for me only except for the switch user part i am also needing..??

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0