AntiVirusGuy Posted February 14, 2008 Posted February 14, 2008 Does anyone know how to only make a Run statement to run if no one is logged in or the workstation is locked?? Please provide an example as I am very unfamiliar with how to do this Thank you in advance
SpookMeister Posted February 14, 2008 Posted February 14, 2008 (edited) Well, I had a function way back in 2005 that worked with whatever the current version of AutoIt was at the time. However it is not functioning for me at the moment, probably because something has changed in how DllCall() works. Maybe someone else can figure out why quicker than I can: While 1 Sleep(1000) If ScreenLocked() Then ConsoleWrite(@HOUR & @MIN & @SEC & "- Locked" & @CRLF) Else ConsoleWrite(@HOUR & @MIN & @SEC & "- Not Locked" & @CRLF) EndIf WEnd Func ScreenLocked() $locked = DllCall("user32.dll", "Long", "OpenInputDesktop") If $locked[0] = 0 Then Return 1 Else Return 0 EndIf EndFunc ;==>ScreenLocked [edit] typos Edited February 14, 2008 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
AntiVirusGuy Posted February 14, 2008 Author Posted February 14, 2008 I think it can be done with WMI but I am not very well versed with WMI
baghenamoth Posted April 21, 2008 Posted April 21, 2008 Hi I use exactly the same dllcall and it worked well with autoit 3.2.2.0 and now it crashes autoitexe (3.2.10.0) Does someone knows how to call the dll correctly ? Well, I had a function way back in 2005 that worked with whatever the current version of AutoIt was at the time. However it is not functioning for me at the moment, probably because something has changed in how DllCall() works. Maybe someone else can figure out why quicker than I can: While 1 Sleep(1000) If ScreenLocked() Then ConsoleWrite(@HOUR & @MIN & @SEC & "- Locked" & @CRLF) Else ConsoleWrite(@HOUR & @MIN & @SEC & "- Not Locked" & @CRLF) EndIf WEnd Func ScreenLocked() $locked = DllCall("user32.dll", "Long", "OpenInputDesktop") If $locked[0] = 0 Then Return 1 Else Return 0 EndIf EndFunc ;==>ScreenLocked [edit] typos
SpookMeister Posted February 24, 2009 Posted February 24, 2009 I poked around at this today and figured out that the DLLcall needed more information to function properly... not sure why it worked once upon a time... but anyway, here it is for future reference HotKeySet("{ESC}", "Terminate") While 1 Sleep(1000) If ScreenLocked() Then ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & "- Locked" & @CRLF) Else ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & "- Not Locked" & @CRLF) EndIf WEnd Func ScreenLocked() $locked = DllCall("user32.dll", "long", "OpenInputDesktop", "dword", 0, "dword", 0, "dword", 0x0040) If @error Then Exit If $locked[0] = 0 Then Return 1 Else Return 0 EndIf EndFunc ;==>ScreenLocked Func Terminate() Exit 0 EndFunc ;==>Terminate [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
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