Jump to content

Recommended Posts

Posted

I use AutoIt a lot when I am at work, but I like to lock my computer using the (WinKey + L) when I am away from my desk. I needed a way to let my AutoIt apps and scripts run while I am away form my deak for maximum use of the automation, without appearing like the computer is "doing something magical" or looking like it is open to people stopping by to read my email...

Enter the Phony Windows Lock-Out. This is just a VERY basic GUI script that will make it look like the computer has been locked, while it's not really locked at all, therefore allowing your apps to run and not be stopped by windows.

This was put together quickly, so there may be issues, but I know it's something that I need so maybe you do too. :">

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 (beta)
; Language:    English
; Platform:    WinXP
; Author:        Cybie
;
; Script Function:
;   Fake the "computer locked" dialog so that AutoIt may run in the background.
;
; ----------------------------------------------------------------------------
#include <GuiConstants.au3>
HotKeySet("{F2}","KillSwitch")

$LockImage = @TempDir & "/" & "locked.jpg"
FileInstall("locked.jpg", $LockImage, 1)
$SecurityImage = @TempDir & "/" & "security.jpg"
FileInstall("security.gif", $SecurityImage, 1)

$username = "MKTNG\yourname (Your Name)"

; GUI looks like background.
GuiCreate("x", @DesktopWidth, @DesktopHeight, -1, -1, 0x80000000)
GUISetBkColor (0x6E8ADE)
GuiSetState()

GUICreate("Computer Locked", 400, 200, -1, -1, 0x00000000)
GUISetBkColor (0xE0E0C0)
GUICtrlCreatePic ($LockImage, 0, 0, 400, 75)
GUICtrlCreatePic ($SecurityImage, 10, 85, 32, 25)
GUICtrlCreateLabel("This computer is in use and has been locked.",52,85,325,20)
GUICtrlCreateLabel("Only " & $username & " or an administrator can unlock this computer.",52,105,325,40)
GUICtrlCreateLabel("Press Ctrl-Alt-Del to unlock this computer.",52,145,325,20)
GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
;Keeps the computer from actually locking due to inactivity.
    $RandomMoveX = Random (1, @DesktopWidth)
    MouseMove ($RandomMoveX, @DesktopHeight)
    $RandomTime = Random (5000, 10000)
    Sleep($RandomTime)
    WinActivate("x")
    WinActivate("Computer Locked")
Wend

;FUNCTIONS
;---------
Func KillSwitch()
    Exit 0
EndFunc

NOTE: You will need to put the graphics attached to this post in the same directory as the script so that it may find them.

Writing damaged code since 1996.

  • Replies 74
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 6 months later...
Posted

Man that thing is great!

I ran it without looking what the password is and couldn't close the program, NO matter what!

Works really great!

(I had to restart my Comp :graduated::oB) )

GJ

Felix N. (tdlrali)

Posted

No , i mean i looked at the stuff inside the script, but skipped the password and didn't remember it B)

I know it was dumb, but after i clicked Run there was nothing i could do about it!^^

Posted (edited)

If you happened to have a script that relies on PixelGetColor or PixelChecksum, you could use WinSetTrans to make an ALMOST opaque window....

Edit to clarify: PixelGetColor "sees through" or ignores windows that have any degree of transparency.

Example below; click the screen to close it:

#include <GuiConstants.au3>

$GUI = GuiCreate("foo", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)

;Color Code from Josbe <http://www.autoitscript.com/forum/index.php?s=&showtopic=16243&view=findpost&p=111443>
$out = DllCall("user32", "long", "GetSysColor", "long", 1);1==Background color
$hColor = Hex( $out[0], 6); BGR output to RGB mode....
$hexColor = StringMid($hColor, 5, 2) & StringMid($hColor, 3, 2) & StringMid($hColor, 1, 2)
GuiSetBkColor(Dec($hexColor))

GuiSetState()
WinSetTrans($GUI, "", 254); one less than opaque
While GuiGetMsg() <> $GUI_EVENT_PRIMARYDOWN
    sleep(100)
WEnd
Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Posted (edited)

I've been trying to figure out the check password thing. If the user does not have a password set, it WILL error out.

Func ValidUserPassword($Password)
    Local $Previous_Run_Opt = Opt('RunErrorsFatal', 0)
    RunAsSet(@Username, '', 'default')
    $Valid_Password = RunWait(@Comspec & ' /c dir 1')
    Opt('RunErrorsFatal', $Previous_Run_Opt)
    Return Not $Valid_Password
EndFunc

That's not guaranteed, but it worked with my tests.

Highly suggest this method for the user-password, as it allows for portability of pre-compiled code. For private purposes, a master override might not be a bad idea...

Edited by MSLx Fanboy

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Posted (edited)

i was trying to make it look as much like a regular windows login dialog as i could.

i edited the script again, now when you type in the pass word the input text will be masked.

i also removed the code to move the mouse around, as i can just go into the desktop settings and disable the login after screensaver option.

the default password is "pass".

i should have mentioned that in my post, as i am bad about running scripts with out readin through them.

Edited by random667

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Posted (edited)

archrival, i tried yours but it didnt work, i like the idea of the diffrent images. your script seems to look for the users name and password, but i dont see any inputs for the user to enter their name and password.

Edited by random667

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Posted

archrival, i tried yours but it didnt work, i like the idea of the diffrent images. your script seems to look for the users name and password, but i dont see any inputs for the user to enter their name and password.

What didn't work exactly? It just pulls the current user name and domain, it's only for cosmetic purposes. I did notice that it doesn't work right with the latest beta. I had the same problem with the original though.

Posted

What didn't work exactly? It just pulls the current user name and domain, it's only for cosmetic purposes. I did notice that it doesn't work right with the latest beta. I had the same problem with the original though.

When i ran the script nothing happened at all.

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Posted

one problem with my script, although i have used WinMinimizeAll()

firefox doesnt minimize when i run my script.

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Posted (edited)

not sure why it doesnt work for me,

but i dont like the idea of someone hitting ctrl+alt+del or F2 to get around my login.

a logon should require a password.

Yeah, I just modified the original script, the display is almost identical to the actual "Computer Locked" dialog. That was my purpose. If someone wanted to modify it a little further, that's fine. Maybe it's a problem with the codebox, here's the actual au3 file.

Edited by archrival
Posted

Yeah, I just modified the original script, the display is almost identical to the actual "Computer Locked" dialog. That was my purpose. If someone wanted to modify it a little further, that's fine. Maybe it's a problem with the codebox, here's the actual au3 file.

understood,

i will probably change my script to include your script to change the images dependant on the users OS,

but i think using a password from the .ini file is best incase the user doesnt have a windows password setup (most people dont).

It is really sad to see a family torn apart by something as simple as a pack of wolves.

Posted

I modified my posted au3 file to search for the actual full name of the user as well, which now requires use of the latest beta, also no longer moves the mouse in the lower left hand corner (sends a null character every 5 seconds).

Posted

Maybe I would suggest using the Windows password, if the code sample I posted above throws an error, fallback to a password in an ini file...

i.e.

If Not ValidUserPassword('mypassword')Then
If $TestPassword = $PasswordFromIni Then
$Allow_Access = True
EndIf
EndiF

Just something to think about

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())

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
  • Recently Browsing   0 members

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