devilman16 Posted April 22, 2010 Share Posted April 22, 2010 Hi all, I have already done a lot of automation with autoit (AD, Execl, unattended installations), but unfortunately I have no experience with reading windows events. So my problem is I want to read out when the computer gets locked or unlocked the hole day long (from event logging?) So I searched a bit and found this VB code which looked very nice: expandcollapse popupPublic Class Form1 Private Declare Function WTSRegisterSessionNotification Lib "Wtsapi32" (ByVal hWnd As IntPtr, ByVal THISSESS As Integer) As Integer Private Declare Function WTSUnRegisterSessionNotification Lib "Wtsapi32" (ByVal hWnd As IntPtr) As Integer Private Const NOTIFY_FOR_ALL_SESSIONS As Integer = 1 Private Const NOTIFY_FOR_THIS_SESSION As Integer = 0 Private Const WM_WTSSESSION_CHANGE As Integer = &H2B1 Private Enum WTS CONSOLE_CONNECT = 1 CONSOLE_DISCONNECT = 2 REMOTE_CONNECT = 3 REMOTE_DISCONNECT = 4 SESSION_LOGON = 5 SESSION_LOGOFF = 6 SESSION_LOCK = 7 SESSION_UNLOCK = 8 SESSION_REMOTE_CONTROL = 9 End Enum Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load WTSRegisterSessionNotification(Me.Handle, NOTIFY_FOR_ALL_SESSIONS) End Sub Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case m.Msg Case WM_WTSSESSION_CHANGE Select Case m.WParam.ToInt32 Case WTS.CONSOLE_CONNECT Debug.Print("A session was connected to the console session.") Case WTS.CONSOLE_DISCONNECT Debug.Print("A session was disconnected from the console session.") Case WTS.REMOTE_CONNECT Debug.Print("A session was connected to the remote session.") Case WTS.REMOTE_DISCONNECT Debug.Print("A session was disconnected from the remote session.") Case WTS.SESSION_LOGON Debug.Print("A user has logged on to the session.") Case WTS.SESSION_LOGOFF Debug.Print("A user has logged off the session.") Case WTS.SESSION_LOCK Debug.Print("A session has been locked.") Case WTS.SESSION_UNLOCK Debug.Print("A session has been unlocked.") Case WTS.SESSION_REMOTE_CONTROL Debug.Print("A session has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.") End Select End Select MyBase.WndProc(m) End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing WTSUnRegisterSessionNotification(Me.Handle) End Sub End Class also a mark to http://msdn.microsoft.com/en-us/library/aa383828.aspx So my problem is that I dont know VB well and want to write this in autoit. Can somebody help me with the basic so that I can read out the time when a computer gets locked? Thanks for help! br devilman Link to comment Share on other sites More sharing options...
Spiff59 Posted April 22, 2010 Share Posted April 22, 2010 This thread seems to be related and contains some example code for your call:http://www.autoitscript.com/forum/index.php?showtopic=8721&st=0&p=61934It doesn't appear that the outcome was successful, but the post is 5 years old. Maybe you will have (or someone else has had) better luck with it in 2010. Link to comment Share on other sites More sharing options...
Yoriz Posted April 22, 2010 Share Posted April 22, 2010 Take a look at this GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
devilman16 Posted April 23, 2010 Author Share Posted April 23, 2010 Thanks a lot, thats it ! 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