cypher175 Posted December 10, 2008 Share Posted December 10, 2008 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..?? Link to comment Share on other sites More sharing options...
Andreik Posted December 10, 2008 Share Posted December 10, 2008 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. Link to comment Share on other sites More sharing options...
cypher175 Posted December 10, 2008 Author Share Posted December 10, 2008 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.. Link to comment Share on other sites More sharing options...
weaponx Posted December 10, 2008 Share Posted December 10, 2008 I have only ever seen a 3rd party program for this, called Shutdown Folder. (not free)http://www.hs-lab.com/products/df/ Link to comment Share on other sites More sharing options...
skysel Posted December 10, 2008 Share Posted December 10, 2008 (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.mscafter 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 December 10, 2008 by skysel Link to comment Share on other sites More sharing options...
weaponx Posted December 10, 2008 Share Posted December 10, 2008 You can do following:Go to Start, Run, gpedit.mscafter 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. Link to comment Share on other sites More sharing options...
skysel Posted December 10, 2008 Share Posted December 10, 2008 That doesn't distinguish the shutdown type.But it's as close as it is..for free Link to comment Share on other sites More sharing options...
cypher175 Posted December 10, 2008 Author Share Posted December 10, 2008 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..?? Link to comment Share on other sites More sharing options...
skysel Posted December 10, 2008 Share Posted December 10, 2008 (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 December 10, 2008 by skysel Link to comment Share on other sites More sharing options...
cypher175 Posted December 10, 2008 Author Share Posted December 10, 2008 can Scriptomatic convert that into Autoit? Im not to familiar with doing such a thing.. Link to comment Share on other sites More sharing options...
weaponx Posted December 10, 2008 Share Posted December 10, 2008 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. Link to comment Share on other sites More sharing options...
cypher175 Posted December 10, 2008 Author Share Posted December 10, 2008 so what can I do then..?? What is meant by this..?? "I guess using Scriptomatic you could figure out for Autoit?" Link to comment Share on other sites More sharing options...
oMBRa Posted December 10, 2008 Share Posted December 10, 2008 I saw a script of an user that intercepts the windows message of shutdown etc, just search in the forum Link to comment Share on other sites More sharing options...
KaFu Posted December 10, 2008 Share Posted December 10, 2008 (edited) Maybe this thread contains some useful info for you#607489At 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...RegardsEdit: Lol, 30 seconds to slow Edited December 10, 2008 by KaFu  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
oMBRa Posted December 10, 2008 Share Posted December 10, 2008 search in the helpfile for OnAutoitExit then take a look at the @EXITMETHOD Link to comment Share on other sites More sharing options...
cypher175 Posted December 10, 2008 Author Share Posted December 10, 2008 search in the helpfile for OnAutoitExit then take a look at the @EXITMETHODYeah i just found that OnAutoitExit and it seems to work for me only except for the switch user part i am also needing..?? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now