AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Locking the computer
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Petru



Joined: 17 Dec 2007
Posts: 64
Location: Galatz, Romania

PostPosted: Tue Jan 15, 2008 4:08 pm    Post subject: Locking the computer Reply with quote

This is a script I made to lock the computer using a password so no one will work on it while I'll be out. Don't worry about the variable/subroutine names. I first wrote the program in the Romanian language ('cause I'm Romanian Smile ) and I translated only the strings after that.

Code:

#NoTrayIcon
START:
gui,2:destroy
gui,destroy
Gui, Font, S8 CDefault, tahoma
Gui, Add, Text, x26 y20 w80 h20 ,Name:
Gui, Add, Text, x26 y40 w80 h20 ,Password:
Gui, Add, Text, x26 y60 w80 h20 ,Repeat it:
Gui, Add, Edit, x116 y20 w140 h20 vNume,
Gui, Add, Edit, x116 y40 w140 h20 vParola +Password,
Gui, Add, Edit, x116 y60 w140 h20 vParola2 +Password,
Gui, Add, Button, x100 y87 w86 h27 gBLOCARE, Lock
Gui, Show,center h128 w320, Lock computer
Return


Blocare:
gui,submit
if NOT(Nume<>)
{
msgbox 16,Error,You must write a type or a nickname.
goto START
}
if parola<>%parola2%
{
msgbox 16,Error,The passwords do not match.
goto START
}
gui,2:color, black
gui,2:show, center h2024 w2000
gui,destroy
Gui, Font, S8 CBlack, tahoma
Gui, Add, Text, x16 y10 w250 h40 vMSJ,%Nume% locked the computer using a password. Only %Nume% (or someone else who knows the password) can unlock it.
Gui, Add, Button, x92 y51 w87 h26 gDEBLOCARE, Unlock
gui,-sysmenu +alwaysontop +WS_EX_TOPMOST -caption
gui,show
loop
{
IfWinExist ahk_class #32770
{
winkill,ahk_class #32770
GuiControl,,MSJ,No cheating please!
sleep 5000
GuiControl,,MSJ,%Nume% locked the computer using a password. Only %Nume% (or someone else who knows the password) can unlock it.
}
}
return

DEBLOCARE:
gui,destroy
gui,+alwaysontop -caption
Gui, Font, S8 CDefault, tahoma
Gui, Add, Text, x16 y10 w50 h20 , Password:
Gui, Add, Edit, x66 y10 w380 h20 vParolaNoua +Password,
Gui, Add, Button, x452 y9 w101 h23 vMSJ2 gVER, Enter
Gui, Show, center h40 w561, Parola
loop
{
IfWinExist ahk_class #32770
{
winkill,ahk_class #32770
GuiControl,,MSJ2,No cheating!
sleep 5000
GuiControl,,MSJ2,Enter
}
}
Return

VER:
gui,submit
if ParolaNoua<>%parola%
{
msgbox 16,Error,Incorrect password.
goto BLOCARE
return
}
else
exitapp

GuiClose:
ExitApp


PS:If you didn't inspect the script, then, after the screen turns black, try to access Task Manager (via Ctrl+Alt+Del) and see what it happens. Very Happy
Back to top
View user's profile Send private message
jar



Joined: 29 Apr 2007
Posts: 11

PostPosted: Tue Jan 15, 2008 4:22 pm    Post subject: Reply with quote

Win-key L does that also ...
Back to top
View user's profile Send private message
Petru



Joined: 17 Dec 2007
Posts: 64
Location: Galatz, Romania

PostPosted: Tue Jan 15, 2008 4:29 pm    Post subject: Reply with quote

Oops, you're right. I'll modify the script...
Back to top
View user's profile Send private message
fmate14



Joined: 28 Oct 2007
Posts: 59
Location: Hungary, Érd

PostPosted: Tue Jan 15, 2008 4:30 pm    Post subject: Re: Locking the computer Reply with quote

Petru wrote:
PS:If you didn't inspect the script, then, after the screen turns black, try to access Task Manager (via Ctrl+Alt+Del) and see what it happens. Very Happy

Rolling Eyes I try it. Just press Ctrl + Esc (to Start menu) or simple the Win button... So... Alt + Tab is works to... But I run it with administrator privileges...

Okay, I understand! I can not kill it, BUT I can use the computer! Confused

But... There is a simple hack:

  1. Click to unlock
  2. Type an incorrect password
  3. Click to enter
  4. Do NOT click OK.
  5. Press Ctrl + Shift + Esc
  6. Kill the AutoHotkey
  7. Enjoy.
Back to top
View user's profile Send private message Visit poster's website
Petru



Joined: 17 Dec 2007
Posts: 64
Location: Galatz, Romania

PostPosted: Tue Jan 15, 2008 4:53 pm    Post subject: Reply with quote

Oh! I have no idea about how to remap the Win key because my keyboard is an old one, which hasn't got any Win key! Crying or Very sad
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Tue Jan 15, 2008 5:11 pm    Post subject: Reply with quote

also holding the winkey and r then typing
cmd
then from command prompt
taskkill /f /im autohotkey.exe ends it irregardless
sorry but short of actually locking the pc this is without a point
also alt + f4

just lock the pc and get it over with why even bother with this???????????
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Petru



Joined: 17 Dec 2007
Posts: 64
Location: Galatz, Romania

PostPosted: Tue Jan 15, 2008 5:15 pm    Post subject: Reply with quote

OK OK I understood! My program is wrong. Crying or Very sad
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Tue Jan 15, 2008 5:17 pm    Post subject: Reply with quote

no no thats not what we are saying
we are saying that its a nice idea but you cant use a user run script to give you protection that is better implemented in windows


i aplaud you for the effort i wishe every one would read the documentation and forums and try things like this
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 387
Location: Midwest, USA

PostPosted: Tue Jan 15, 2008 6:34 pm    Post subject: Reply with quote

I concur with Tank. It is an interesting idea, some of which I might be able to apply to some of my locked down workstations in the lab. It is always good to have a goal in mind to try to code for. Smile Keep coding! Don't give up. Very Happy
_________________
SilverEdge78
Back to top
View user's profile Send private message
dmsuperman



Joined: 15 Jan 2008
Posts: 5

PostPosted: Tue Jan 15, 2008 6:43 pm    Post subject: Reply with quote

I personally have a similar script that I modded. It turns the whole screen black, and you have to put in the right password to show it again. I also blocked winkey r, winkey l, ctrl shift esc, and other such commands. It defeats all but the most computer literate, which aren't much around here. The reason I wanted my own was so I could still use my hotkeys to control winamp and such things, without having to enter my password.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Tue Jan 15, 2008 6:52 pm    Post subject: Reply with quote

the point is that it wont stop anything that win +L

also no one is saying not to keep trying ideas these attempts no matter how faulty the idea may be the ability to write successful scripts will aid you when you do finally get that really good idea. your experience with bad ideas well implemented will give you excelent coding skills for the really good ideas
beleive it or not the thing that separate sean and majkinator for instance from this. is that they post the code they find to be a really good idea. i garantee they write p-lenty of pointless scripts that they themselves find novelty in. and this is what makes them great programers
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Petru



Joined: 17 Dec 2007
Posts: 64
Location: Galatz, Romania

PostPosted: Tue Jan 15, 2008 7:10 pm    Post subject: Reply with quote

So I have no ideas about how to improve it (maybe because I'm tired). Can someone help me? Confused
Back to top
View user's profile Send private message
fmate14



Joined: 28 Oct 2007
Posts: 59
Location: Hungary, Érd

PostPosted: Tue Jan 15, 2008 7:17 pm    Post subject: Do not try this! Reply with quote

Do not try this Exclamation You can kill it only with reboot. (Or log in as a different administrator) Sorry my english.
Code:
#UseHook
#NoTrayIcon
#WinActivateForce

gui,2:color, black
gui,2:show, center h2024 w2000
gui,destroy
Gui, Font, S8 CBlack, tahoma
Gui, Add, Text, x16 y10 w250 h40 vMSJ,This Computer is locked.
gui,-sysmenu +alwaysontop +WS_EX_TOPMOST -caption
gui,show

loop
{
   WinActivate, %A_ScriptName%
   IfWinExist ahk_class #32770
      winkill,ahk_class #32770
   SendInput {LAlt Down}{RShift Down}{LCtrl Down}
}
Back to top
View user's profile Send private message Visit poster's website
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Tue Jan 15, 2008 7:32 pm    Post subject: Reply with quote

well first we need to clearly define your goal
0 create a gui to save user and pass combo in variables
1 remove interactivity of input devices
2 require specified key combo to activate a password prompt
3 store a set username and pass combo
4 verify user and pass combo after specified key combo
5 exit gui on successfule user pass combo and release access to input devices
6 go back to locked screen on failed user pass combo

we might make these each functions and test them separately
then experiment with putting them together
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
fmate14



Joined: 28 Oct 2007
Posts: 59
Location: Hungary, Érd

PostPosted: Wed Jan 16, 2008 7:38 am    Post subject: I can. Reply with quote

tank wrote:
we are saying that its a nice idea but you cant use a user run script to give you protection that is better implemented in windows

I can. Please, try this.
Code:
#UseHook
#NoTrayIcon
#WinActivateForce

myPassword = lucky
myName = Someone

START:
   Gui, Font, S8 CDefault, tahoma
   Gui, Add, Text, x26 y20 w80 h20 ,Name:
   Gui, Add, Text, x26 y40 w80 h20 ,Password:
   Gui, Add, Text, x26 y60 w80 h20 ,Repeat it:
   Gui, Add, Edit, x116 y20 w140 h20 vmyName, %myName%
   Gui, Add, Edit, x116 y40 w140 h20 vmyPassword +Password, %myPassword%
   Gui, Add, Edit, x116 y60 w140 h20 vmyPassword2 +Password, %myPassword%
   Gui, Add, Button, x100 y87 w86 h27 gTESTDATA +default, Lock
   Gui, Show,center h128 w320, Lock computer
Return


TESTDATA:
   gui,submit
   if (myName == "") {
      msgbox 16,Error,You must write a type or a nickname.
      goto START
   } else if (myPassword <> myPassword2 ) {
      msgbox 16,Error,The passwords do not match.
      goto START
   }
   SetTimer, MoveToForeground, 10
   informationText = %myName% locked the computer using a password. Only %myName% can unlock it (password: %myPassword%).
   goto LOCKED
return




LOCKED:
   gui, 2:color, black
   gui, 2:show, center h2024 w2000
   gui, destroy
   Gui, Font, S8 CBlack, tahoma
   Gui, Add, Text, x16 y10 w550 h40, %informationText%
   Gui, Add, Text, x16 y30 w50 h20 , Password:
   Gui, Add, Edit, x66 y30 w380 h20 vTypedPswd +Password,
   Gui, Add, Button, x452 y30 w101 h23 gVERIFY +default, Enter
   gui, -sysmenu +alwaysontop +WS_EX_TOPMOST -caption
   Gui, Show, center h60 w561, %A_ScriptName%enterPswd
return

VERIFY:
   Gui, Submit
   if (TypedPswd <> myPassword) {
      informationText = Incorrect password.
      tooltip, %TypedPswd% <> %myPassword%
      goto LOCKED
      return
   } else {
      exitapp
   }
return

MoveToForeground:
   WinActivate, %A_ScriptName%
   WinActivate, %A_ScriptName%enterPswd
   IfWinExist ahk_class #32770
      winkill, ahk_class #32770
return

*LCtrl::return
*RCtrl::return
*LAlt::return
*RAlt::return
*LWin::return
*RWin::return
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group