Jump to content

run script on locked computer


Recommended Posts

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

well is it possible to unlock the computer quickly run the script and relock the computer?

sorry - I don`t have the users password..... :geek:

So I have to do my work while XP is lockend....

I read about "alternative tools" - may they be named here??? :o

Thanks for help

Andy

Link to comment
Share on other sites

by the way if ur not logged in u cant run stuff

OK, 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...)

:o

Andy

Link to comment
Share on other sites

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 by tonedeaf
Link to comment
Share on other sites

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 by tonedeaf
Link to comment
Share on other sites

@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

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

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

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 :o .

Still I'm missing the bits to get all the parts together....

Is this acceptable as a "valid reason"? :geek:

regards

Andy

Link to comment
Share on other sites

sorry - I don`t have the users password..... :mellow:

So I have to do my work while XP is lockend....

I read about "alternative tools" - may they be named here??? :)

Thanks for help

Andy

Oh, 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

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

@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

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.

regards

Andy

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...