ilcaa Posted January 6, 2010 Share Posted January 6, 2010 I want to activate the password on my ScreenSaver by just toggling it on and off when i execute a hotkey. This is for when I run out to lunch or am away from my desk for extended periods. I am going through the process of creating the script through pure mouse commands, arrow keys and keystrokes to get to the screen saver window and turn the password on/off. Is this the best way to accomplish this task or does Autoit3 have a way to manipulate the windows system easier? thanks if you can point me in the right direction. Link to comment Share on other sites More sharing options...
James Posted January 6, 2010 Share Posted January 6, 2010 Try this #include <WinAPI.au3> #include <Misc.au3> Global Const $SC_SCREENSAVE = 61760 Global Const $WM_SYSCOMMAND = 274 Func _ToggleScrnSaver($bScreenSaver, $lHwnd = -1, $sFormCaption = "") Dim $lState If $lHwnd = 0 Then $lHwnd = _WinAPI_FindWindow("", $sFormCaption) If $bScreenSaver Then $lState = 1 Else $lState = -1 EndIf _SendMessage($lHwnd, $WM_SYSCOMMAND, $SC_SCREENSAVE, $lState) EndFunc Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
ilcaa Posted January 6, 2010 Author Share Posted January 6, 2010 thanks for the code but it doesnt seem to turn my password protection in screensaver on and off... i run the code with no errors but when I check the box within the Screen Saver tab in Display Options there is no check... ive run it several times to see if it takes either way (starting on and also starting off) and it doesnt change the settings... Link to comment Share on other sites More sharing options...
James Posted January 6, 2010 Share Posted January 6, 2010 Sorry about that, try this: Func ToggleScrnSaver() Local $iSave = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaveActive") If $iSave Then RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaveActive", "REG_SZ", 0) Else RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaveActive", "REG_SZ", 1) EndIf EndFunc Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
ilcaa Posted January 6, 2010 Author Share Posted January 6, 2010 i appreciate the codes but still no success... i run it and get no error messages.. I then right click my desktop, go to properties, select the Screen Saver tab, and I look at the small check box labeled "on resume, password protect", this is the box that should be toggled on/off, when running the code nothing changes. when running the code there is no change in the status of this checkbox, which i assume would be the test to see if this code executes correctly. Remember I am not trying to turn screensavers on/off, i am trying to turn on/off the password protection feature. Also i check to see if Screen Saver is on/off with this code and there is no change in that status either.. thanks. Link to comment Share on other sites More sharing options...
James Posted January 6, 2010 Share Posted January 6, 2010 i appreciate the codes but still no success... Damn. Perhaps this then? ToggleScrnSaver() Func ToggleScrnSaver() Local $iSave = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaveActive") If $iSave Then RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaverIsSecure", "REG_SZ", 0) Else RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaverIsSecure", "REG_SZ", 1) EndIf EndFunc Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
ilcaa Posted January 6, 2010 Author Share Posted January 6, 2010 almost there... if the "resume on password" is checked and you run this script, it DOES turn it to off. But if it is off (unchecked), it will not toggle it on the password protect screen saver. have you been testing it on your system? Are you getting the same results I am? Link to comment Share on other sites More sharing options...
James Posted January 6, 2010 Share Posted January 6, 2010 almost there...Try adding in the other RegWrite from before. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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