 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Bkid
Joined: 26 Sep 2005 Posts: 44 Location: Hephzibah, GA
|
Posted: Mon Jun 04, 2007 6:16 am Post subject: TimeIdle with my lock program&password change after comp |
|
|
I got bored, so I decided to make this. This is for people who have Windows XP Home, since I think this is automatically done in XP Pro. Anyway, I have 2 problems:
1) How do I implement TimeIdle so that this program does not lock up the controls UNTIL it reaches the idle time. (Maybe there's a better way to go about this instead of locking up all of the controls...)
and
2) If I were to compile this and give it to people to use, how should I code it to where they can change the password if necessary?
Here's the code:
| Code: | #NoTrayIcon
#SingleInstance force
lock:
Gui, Add, Picture, x-4 y0 w470 h110 , %A_WorkingDir%\splash.jpg
Gui, Add, Text, x26 y120 w220 h20 , This computer is in use and has been locked.
Gui, Add, Text, x26 y150 w430 h30 , Only Documents and Settings\%A_UserName% (Real Name) or an administrator can unlock this computer.
Gui, Add, Text, x95 y220 w50 h20, Password:
Gui, Add, Edit, x155 y217 w210 h20 vPassword Password*
Gui, Add, Button, x+193 y+10 default, OK
Gui, Show, x280 y240 H300 W466, Unlock Computer
return
Tab::return
LButton::return
RButton::return
Up::return
Down::return
Left::return
Right::return
ButtonOK:
Gui, Submit
if (Password = "password") ;or change the password to whatever you want.
{
exitapp
}
else
{
MsgBox,64,,Incorrect Password., 3
reload
}
return |
PS: If you happen to change the password and can't remember it, you can get around the lock by ctrl+alt+delete, using the numpad to navigate, and ending the autohotkey.exe process with the delete key.
EDIT: The picture needed for the program is here: http://img61.imageshack.us/img61/9990/splashep6.jpg , and is supposed to be named splash.jpg (and put in the working directory). _________________ --Bkid-- |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Mon Jun 04, 2007 6:40 am Post subject: |
|
|
incomplete, but a good starting point. Search Hash MD% to see what that part is about, and how to store the right thing in your ini file
| Code: |
#NoTrayIcon
#SingleInstance force
Settimer, checktime, 5000
;put two inireads here - instead of my to fake variables
timeoutminutes = 15
passwordhash = [something]
;setup gui once only
Gui, Add, Picture, x-4 y0 w470 h110 , %A_WorkingDir%\splash.jpg
Gui, Add, Text, x26 y120 w220 h20 , This computer is in use and has been locked.
Gui, Add, Text, x26 y150 w430 h30 , Only Documents and Settings\%A_UserName% (Real Name) or an administrator can unlock this computer.
Gui, Add, Text, x95 y220 w50 h20, Password:
Gui, Add, Edit, x155 y217 w210 h20 vPassword Password*
Gui, Add, Button, x+193 y+10 default, OK
return
checktime:
timeout := timeoutminutes * 60 * 1000 ;15 minutes
If (A_TimeIdlePhysical>timeout)
gosub lock
return
lock:
Gui, Show, x280 y240 H300 W466, Unlock Computer
return
Tab::return
LButton::return
RButton::return
Up::return
Down::return
Left::return
Right::return
ButtonOK:
Gui, Submit
PasswordHash := Hash(Password, StrLen(Password))
if (PasswordHash = savedPasswordHash)
{
Settimer, checktime, 5000
;something here to disable the key blocking... didn't have time to write it
;hotkey, Tab, Off ;, etc.
}
else
{
MsgBox,64,,Incorrect Password., 3
Gui, Show, x280 y240 H300 W466, Unlock Computer
}
return
Hash(ByRef sData, nLen, SID = 3) ; SID: 3 for MD5, 4 for SHA
{
DllCall("advapi32\CryptAcquireContextA", "UintP", hProv, "Uint", 0, "Uint", 0, "Uint", 1, "Uint", 0xF0000000)
DllCall("advapi32\CryptCreateHash", "Uint", hProv, "Uint", 0x8000|0|SID , "Uint", 0, "Uint", 0, "UintP", hHash)
DllCall("advapi32\CryptHashData", "Uint", hHash, "Uint", &sData, "Uint", nLen, "Uint", 0)
DllCall("advapi32\CryptGetHashParam", "Uint", hHash, "Uint", 2, "Uint", 0, "UintP", nSize, "Uint", 0)
VarSetCapacity(HashVal, nSize, 0)
DllCall("advapi32\CryptGetHashParam", "Uint", hHash, "Uint", 2, "Uint", &HashVal, "UintP", nSize, "Uint", 0)
DllCall("advapi32\CryptDestroyHash", "Uint", hHash)
DllCall("advapi32\CryptReleaseContext", "Uint", hProv, "Uint", 0)
SetFormat, Integer, H
Loop, %nSize%
{
nValue := *(&HashVal + A_Index - 1)
StringReplace, nValue, nValue, 0x, % (nValue < 16 ? 0 :)
sHash .= nValue
}
Return sHash
}
|
*untested _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|