Zinthose Posted August 14, 2009 Posted August 14, 2009 Here are some useful functions I pieced together and thought I'd share. >_< expandcollapse popupDllOpen("user32.dll") While 1 Sleep(2000) ConsoleWrite(" IsWorkStationLocked = " & IsWorkStationLocked() & @CRLF) ConsoleWrite("IsScreenSaverRunning = " & IsScreenSaverRunning() & @CRLF) WEnd Func IsWorkStationLocked() Local $Desktop, $Return $Return = DllCall("user32.dll", "long", "OpenDesktopA", "str", "Default", "dword", 0, "ubyte", 0, "dword", 0x100) $Desktop = $Return[0] If $Desktop = 0 Then Return True EndIf $Return = DllCall("user32.dll", "long", "SwitchDesktop", "dword", $Desktop) DllCall("user32.dll", "long", "CloseDesktop", "dword", $Desktop) If $Return[0] = 0 Then Return True Else Return False EndIf EndFunc Func IsScreenSaverRunning() Local $Desktop, $Return, $Result $Result = DllStructCreate("uint") $Return = DllCall("user32.dll", "ubyte", "SystemParametersInfoA", "uint", 0x72, "uint", 0, "ptr", DllStructGetPtr($Result), "uint", 0) If $Return[0] = 0 Then Return SetError(, 0, False) Return DllStructGetData($Result, 1) <> 0 EndFunc --- TTFN
wibni Posted August 14, 2009 Posted August 14, 2009 Hi, would it be possible to unlock a workstation with your script or is this something AutoIt can't do?
Yashied Posted August 14, 2009 Posted August 14, 2009 (edited) @ZinthoseWhat do you think about this (few hours ago) and this? Edited August 14, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
SoulSHepard Posted August 14, 2009 Posted August 14, 2009 (edited) @Zinthose, just what i was thinking about. saw the functions and while case looped a logger arround it for the console as an addendum expandcollapse popup; workstation idle logger for windows ; Functions : IsWorkStationLocked() and IsScreenSaverRunning() by Zinthose ; crappy case while loop code by S0ulSHepard ; #include <Date.au3> DllOpen("user32.dll") $actiondate = _NowCalc() $timehaspastmin = 0 $timehaspasthour =0 $tmpString1=0 $tmpString2=0 $prediction="was working for" While 1 $actiontrigger = False $file = FileOpen("lockstatus.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $tmpString1=IsWorkStationLocked() $tmpString2=IsScreenSaverRunning() Sleep(10000) if $tmpString1 <> IsWorkStationLocked() Then $actiontrigger = True EndIf if $tmpString2 <> IsScreenSaverRunning() Then $actiontrigger = True EndIf if $actiontrigger = True Then $timehaspastsec = _Datediff ( 's' , $actiondate , _NowCalc()) $timehaspastmin = Round($timehaspastsec / 60,1) $timehaspasthour = Round($timehaspastmin /60,1) select case $timehaspasthour >= 1 $timetype="hour(s)" $timehaspast=$timehaspasthour case $timehaspastmin >= 1 $timetype="minute(s)" $timehaspast=$timehaspastmin case Else $timetype="second(s)" $timehaspast=$timehaspastsec EndSelect select case IsScreenSaverRunning() = False and IsWorkStationLocked() = False $prediction = "was away for" case IsScreenSaverRunning() = True and IsWorkStationLocked() = False $prediction = "was working for" case IsScreenSaverRunning() = True and IsWorkStationLocked() = True $prediction = "(really idle now) was watching my screen for " case IsScreenSaverRunning() = False and IsWorkStationLocked() = True $prediction = "was working for" EndSelect $outputstring = _NowCalc() & " - " & "scrsaver=" & IsScreenSaverRunning() & ",Locked=" & IsWorkStationLocked() & ", " & $prediction & " " & $timehaspast & " " & $timetype & @CRLF FileWrite($file , $outputstring ) ConsoleWrite ( $outputstring) $actiondate = _NowCalc() EndIf FileClose($file) WEnd Func IsWorkStationLocked() Local $Desktop, $Return $Return = DllCall("user32.dll", "long", "OpenDesktopA", "str", "Default", "dword", 0, "ubyte", 0, "dword", 0x100) $Desktop = $Return[0] If $Desktop = 0 Then Return True EndIf $Return = DllCall("user32.dll", "long", "SwitchDesktop", "dword", $Desktop) DllCall("user32.dll", "long", "CloseDesktop", "dword", $Desktop) If $Return[0] = 0 Then Return True Else Return False EndIf EndFunc Func IsScreenSaverRunning() Local $Desktop, $Return, $Result $Result = DllStructCreate("uint") $Return = DllCall("user32.dll", "ubyte", "SystemParametersInfoA", "uint", 0x72, "uint", 0, "ptr", DllStructGetPtr($Result), "uint", 0) If $Return[0] = 0 Then Return SetError( 0, False) Return DllStructGetData($Result, 1) <> 0 EndFunc Edited August 14, 2009 by SoulSHepard
SoulSHepard Posted August 22, 2009 Posted August 22, 2009 @all.based upon these functions, i got a bit wild with getting this to work to log all in a nice way,check here a new tool i got for this. Jeeves, your personal assistant (time tracking tool)thx Zinthose.Soul
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