Andy16 Posted March 7, 2006 Share Posted March 7, 2006 Hi out there! beeing quite new to autoIt it didn't take long to fall in love.... ;-) Now I'd like to create a script that should - check if the WinXP PC is locked - if it is locked start some action on some windows. This ends up in -> how can I check if the screen is locked? -> Can I juggle some windows behind a locked screen???? (general question....) Thanks for help Andy Link to comment Share on other sites More sharing options...
CyberSlug Posted March 7, 2006 Share Posted March 7, 2006 Unfortunately, AutoIt has limitations with locked workstations:http://www.autoitscript.com/forum/index.php?showtopic=18026http://www.autoitscript.com/forum/index.php?showtopic=15814 Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 7, 2006 Share Posted March 7, 2006 well is it possible to unlock the computer quickly run the script and relock the computer? Link to comment Share on other sites More sharing options...
Andy16 Posted March 7, 2006 Author Share Posted March 7, 2006 well is it possible to unlock the computer quickly run the script and relock the computer?sorry - I don`t have the users password..... So I have to do my work while XP is lockend....I read about "alternative tools" - may they be named here??? Thanks for helpAndy Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 7, 2006 Share Posted March 7, 2006 (edited) log in in safemode, or get a bootdisk , by the way if ur not logged in u cant run stuff Edited March 7, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Andy16 Posted March 7, 2006 Author Share Posted March 7, 2006 by the way if ur not logged in u cant run stuffOK, let`s differentiate- User is logged in, but screen is locked -> this should be possible to be caught and "stuff" shold be executable- No user is logged on -> ok, there I need a service deamon to help out.... (but this case is of minor interest for me...) Andy Link to comment Share on other sites More sharing options...
Andy16 Posted March 8, 2006 Author Share Posted March 8, 2006 let's turn the question arround: starting a AutoIT executable using "winat" - how can I check if the workstation is locked? regards Andy Link to comment Share on other sites More sharing options...
tonedeaf Posted March 8, 2006 Share Posted March 8, 2006 (edited) Ok, back to the original questions: -> how can I check if the screen is locked? -> Can I juggle some windows behind a locked screen???? (general question....)Check if the computer is locked. SwitchDesktop API call will fail when it is called from a process associated with a secured desktop if the computer is locked. This script will tell if the computer is locked: $DESKTOP_SWITCHDESKTOP = 0x100 Sleep(3000) $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $ret = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0]) DllCall("User32.dll", "int", "CloseDesktop", "int", $ret[0]) If $ret[0] = 0 Then ConsoleWrite("Desktop is locked" & @CRLF) ElseIf $ret[0] = 1 Then ConsoleWrite("Desktop is not locked" & @CRLF) EndIf To test, modify the Sleep(3000). Right now it is giving you 3 seconds to lock your workstation and after that it will check if the computer is locked. It will write the status to the console, when you run it from SciTe. For the second question: You cannot send any commands to any use interfaces when the computer is locked. Send() and other windows manipulating functions will not work. EDIT: This script will only work for Win2k and XP Edited March 8, 2006 by tonedeaf Link to comment Share on other sites More sharing options...
Intellitree Posted March 8, 2006 Share Posted March 8, 2006 well is it possible to unlock the computer quickly run the script and relock the computer?I would like to learn hot to do this. it relate to problem am having in my script. Link to comment Share on other sites More sharing options...
tonedeaf Posted March 8, 2006 Share Posted March 8, 2006 (edited) well is it possible to unlock the computer quickly run the script and relock the computer?There is no way to unlock a computer through a script. However, if you want to lock the computer through a script, this line of code will do it: DllCall("User32.dll", "int", "LockWorkStation") If you're not working with any user interface elements, your scripts will run fine when the computer is lokced. Edited March 8, 2006 by tonedeaf Link to comment Share on other sites More sharing options...
Andy16 Posted March 8, 2006 Author Share Posted March 8, 2006 @tonedeaf: briliant! this is exactly the part of code I as looking for!!! Thanks a lot! Also this is only half of the game.... Depending on wether locked or not I want to start a IE with a given URL, wait for loading to complete and close window again. Currently this works fine in unlock mode - but it fails in locked mode. Is this due to restricions or did I do something wrong: AutoItSetOption("WinTitleMatchMode", 1) $DESKTOP_SWITCHDESKTOP = 0x100 $offline ="http://offline.com" $online ="http://online.com" $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $ret = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0]) DllCall("User32.dll", "int", "CloseDesktop", "int", $ret[0]) sleep(3000) If $ret[0] = 0 Then Run ( "c:\Programme\Internet Explorer\iexplore.exe " & $offline ) WinWaitActive("http://offline.com") sleep (5000) WinClose("http://offline.com") ElseIf $ret[0] = 1 Then Run ( "c:\Programme\Internet Explorer\iexplore.exe " & $online ) WinWaitActive("http://online.com") sleep (5000) WinClose("http://online.com") EndIf regards and thanks for help Andy Link to comment Share on other sites More sharing options...
Confuzzled Posted March 8, 2006 Share Posted March 8, 2006 Hi out there!beeing quite new to autoIt it didn't take long to fall in love.... ;-)Now I'd like to create a script that should- check if the WinXP PC is locked- if it is locked start some action on some windows.This ends up in-> how can I check if the screen is locked?-> Can I juggle some windows behind a locked screen???? (general question....)Thanks for helpAndy Welcome to the forums. By design Windows is designed to prevent you doing what you are wanting to do. Can you offer a valid reason (ie legitimate and not nasty) why you would do something to bypass locking? Link to comment Share on other sites More sharing options...
Andy16 Posted March 9, 2006 Author Share Posted March 9, 2006 Can you offer a valid reason (ie legitimate and not nasty) why you would do something to bypass locking?Yes I can - I can remote control my phone and answering machine via http.In case my PC is locked I`m not at my desk and I want my answering machine to pick up all calls.In case my PC is no locked I`m online and I wan`t my phone to ring.To switch the settings via AutoIt during an "open" session is easy .Still I'm missing the bits to get all the parts together....Is this acceptable as a "valid reason"? regardsAndy Link to comment Share on other sites More sharing options...
tonedeaf Posted March 9, 2006 Share Posted March 9, 2006 @Andy16Depending on wether locked or not I want to start a IE with a given URL, wait for loading to complete and close window again.Use DaleHohm's Internet Explorer Automation UDF Library. IE ActiveX control will work when the computer is locked. Link to comment Share on other sites More sharing options...
Confuzzled Posted March 11, 2006 Share Posted March 11, 2006 sorry - I don`t have the users password..... So I have to do my work while XP is lockend....I read about "alternative tools" - may they be named here??? Thanks for helpAndyOh, I see - this is the computer on your desk that you don't have the password to...Maybe you don't need to unlock, but that is another subject. Link to comment Share on other sites More sharing options...
DeFuser Posted March 11, 2006 Share Posted March 11, 2006 Oh, I see - this is the computer on your desk that you don't have the password to... Link to comment Share on other sites More sharing options...
Andy16 Posted March 11, 2006 Author Share Posted March 11, 2006 Oh, I see - this is the computer on your desk that you don't have the password to...@Confuzzled:Maybe I didn't express myself good enough. Let's try again:I can switch my phone to an answering machine by calling an URL.This I want to happen at the moment my screen get's locked (either via alt-ctrl-del_enter or via timeout/Screensaver) - vice versa the moment I unlock my screen.For my PC I have a user/pwd - but the solution I'd like to create should also work for my collegues, without having an ini file including user/pwd.OK?Andy Link to comment Share on other sites More sharing options...
Confuzzled Posted March 12, 2006 Share Posted March 12, 2006 @Confuzzled:Maybe I didn't express myself good enough. Let's try again:I can switch my phone to an answering machine by calling an URL.This I want to happen at the moment my screen get's locked (either via alt-ctrl-del_enter or via timeout/Screensaver) - vice versa the moment I unlock my screen.For my PC I have a user/pwd - but the solution I'd like to create should also work for my collegues, without having an ini file including user/pwd.OK?Andy Ah, I see, a different problem: you don't want to crack the locking mechanism - just replace the screensaver with one of your own. Switch the answering machine on when the program starts, and switch it back off when it exits (OnExitFunc), and call the usual screen saver in between with a WinWaitClose clause should probably work. Windows should take care of the user/password mechanism for each user. Just compile your program, rename it to a *.SCR extension and put it in place of your current screensaver. You should be able to read the current screensaver from the current Windows installation on each PC on installation and maybe save that setting somewhere for when you uninstall the program to put it back how it was before, and to allow users to change the settings for the current one. Link to comment Share on other sites More sharing options...
Andy16 Posted March 12, 2006 Author Share Posted March 12, 2006 Ah, I see, a different problem: you don't want to crack the locking mechanism - just replace the screensaver with one of your own.....yeah - we're getting closer :"> The main issue - it`s a company PC, having a compnay setup that I can`t change.The screensaver is a given thing that I can`t change...The only thing I can do is to ADD a little program (autostart - I can`t define it as service...) that does remote control the answering machine by reacting on "pc lock".As soon as I can I'll give the active X stuff a try.regardsAndy 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