MSlavutin Posted January 8, 2008 Share Posted January 8, 2008 Hi. I have a simple script for taking screen shot each 10 minutes (just as in Help): #include <ScreenCapture.au3> While 1 Local $hBmp $hBmp = _ScreenCapture_Capture ("") _ScreenCapture_SaveImage (@HOUR & @MIN & ".jpg", $hBmp) Sleep(600000) WEnd But i have a problem: when my computer is blocked, there is an error message appears "_WinAPI_BitBlt: wrong descriptor". Any ideas what is this??? Is there any way to make screen shot of the blocked session or, simply, check if it is blocked or not? Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 8, 2008 Share Posted January 8, 2008 Hi, expandcollapse popup; Detect if System is Locked ; Author GaryFrost Global Const $DESKTOP_ENUMERATE = 0x40 Global Const $SPI_GETSCREENSAVERRUNNING = 114 Global Const $DESKTOP_SWITCHDESKTOP = 0x100 HotKeySet("{ESC}", "_Terminate") AdlibEnable("IsDeskTopLocked", 500) While 1 Sleep(10) WEnd Func IsDeskTopLocked() Local $p_lngHwnd, $p_lngRtn, $p_lngErr, $p_lngScreenSaver, $p_blnIsScreenSaver ;~ ' ------------------------------------------ ;~ ' First check for screen saver one of 2 ways, ;~ ' based of OS ;~ ' ------------------------------------------ If @OSTYPE = "WIN32_WINDOWS" Then ;~ ' --------------------------------------- ;~ ' Pre W2K -- Note, will only be TRUE if ;~ ' the "Password Protected" box is ;~ ' checked. ;~ ' --------------------------------------- $p_lngHwnd = DllCall("user32.dll", "int", "OpenDesktopA", "str", "screen-saver", "int", 0, "int", False, "int", $DESKTOP_ENUMERATE) If $p_lngHwnd[0] <> 0 Then $p_blnIsScreenSaver = True Else $p_blnIsScreenSaver = False EndIf Else ;~ ' --------------------------------------- ;~ ' W2K+ -- Will determine if screen saver ;~ ' is running whether or not the ;~ ' "Password Protected" box is checked ;~ ' --------------------------------------- $p_lngRtn = DllCall("user32.dll", "int", "SystemParametersInfoA", "int", $SPI_GETSCREENSAVERRUNNING, "int", 0, "int", $p_lngScreenSaver, "int", 0) If $p_lngRtn[0] = 0 Then ConsoleWrite("Error detecting screen saver" & @LF) Else $p_blnIsScreenSaver = $p_lngScreenSaver EndIf EndIf ;~ ' ------------------------------------------ ;~ ' If screen saver is *not* running, then ;~ ' check for locked workstation ;~ ' ------------------------------------------ If $p_blnIsScreenSaver Then If @OSTYPE = "WIN32_WINDOWS" Then ConsoleWrite("Screen saver is running..., Handle #" & $p_lngHwnd[0] & @LF) $p_lngHwnd = DllCall("user32.dll", "int", "CloseDesktop", "int", $p_lngHwnd[0]) Else ConsoleWrite("Screen saver is running on W2K+" & @LF) EndIf Else $p_lngHwnd = DllCall("user32.dll", "int", "OpenDesktopA", "str", "Default", "int", 0, "int", False, "int", $DESKTOP_SWITCHDESKTOP) If $p_lngHwnd[0] = 0 Then ConsoleWrite("Error with OpenDesktop" & @LF) Else $p_lngRtn = DllCall("user32.dll", "int", "SwitchDesktop", "int", $p_lngHwnd[0]) $p_lngErr = _GetLastErrorMessage() If $p_lngRtn[0] = 0 Then If $p_lngErr = 0 Then ConsoleWrite("Desktop is locked" & @LF) Else ConsoleWrite("Error with SwitchDesktop" & @LF) EndIf Else ConsoleWrite("Not locked!" & @LF) EndIf $p_lngHwnd = DllCall("user32.dll", "int", "CloseDesktop", "int", $p_lngHwnd[0]) EndIf EndIf EndFunc ;==>IsDeskTopLocked Func _Terminate() Exit EndFunc ;==>_Terminate ;=============================================== ; _GetLastErrorMessage($DisplayMsgBox="") ; Format the last windows error as a string and return it ; if $DisplayMsgBox <> "" Then it will display a message box w/ the error ; Return Window's error as a string ;=============================================== Func _GetLastErrorMessage($DisplayMsgBox = "") Local $ret, $s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll", "int", "GetLastError") $ret = DllCall("kernel32.dll", "int", "FormatMessage", _ "int", $FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr", 0, _ "int", $ret[0], _ "int", 0, _ "ptr", DllStructGetPtr($p), _ "int", 4096, _ "ptr", 0) $s = DllStructGetData($p, 1) If $DisplayMsgBox <> "" Then MsgBox(0, "_GetLastErrorMessage", $DisplayMsgBox & @CRLF & $s) Return $s EndFunc ;==>_GetLastErrorMessageoÝ÷ Ù«¢+Ù]¡¥±Ä(M±À ÄÀÀÀ¤(%}¥Í]½ÉÍÑÑ¥½¹1½ ¤Q¡¸ ½¹Í½±]ɥѡ!=UHµÀìÅÕ½ÐìèÅÕ½ÐìµÀì5%8µÀìÅÕ½ÐìèÅÕ½ÐìµÀìMµÀìÅÕ½Ðì´ÅÕ½ÐìµÀìÅÕ½ÐíݽÉÍÑÑ¥½¸±½ÅÕ½ÐìµÀì I1¤)]¹()Õ¹}¥Í]½ÉÍÑÑ¥½¹1½ ¤(%MÑÉ¥¹%¹MÑÈ¡]¥¹ÑQáÐ ÅÕ½ÐìÅÕ½Ð줰ÅÕ½ÐíAɽɴ5¹ÈÅÕ½Ð줱ÐìÐìÀ¹]¥¹ÑQ¥Ñ± ÅÕ½ÐìÅÕ½Ðì¤ôÅÕ½ÐìÅÕ½ÐìQ¡¸IÑÕɸÄ(IÑÕɸÀ)¹Õ¹ìôôÐí}¥Í]½ÉÍÑÑ¥½¹1½ So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
MSlavutin Posted January 8, 2008 Author Share Posted January 8, 2008 thanks 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