;LockWorkstation ;By jgpaiva ;date: January 2007 ;Function: Locks the workstation after a predifined amount of time #singleinstance,force #installmousehook #installkeybdhook ScriptName = LockWorkstation ScriptVersion = 1.02 ScriptUrl = http://www.donationcoder.com/Forums/bb/index.php?topic=6709.0 ScriptSugest = wong LockTime = 4 AutoLockDisableTime := 60 ExceptionList = Lock_Warning := True show_traytip := True lockenable := true Gosub,readini Menu, Tray,tip,%ScriptName% V%ScriptVersion% Menu, Tray, Add, About,AboutHelp Menu, Tray, Add, Lock Now, LockDirectly Menu, Tray, Add, Auto-Lock,AutoLock Menu, Tray, Add, Exit, exit Menu, Tray, Default, About Menu, Tray, NoStandard Menu, Tray, Check, Auto-Lock FileInstall,Cody.png,Cody.png FileInstall,LockWorkstation.wav,LockWorkstation.wav FileInstall,LockWorkstation2.ico,LockWorkstation2.ico ;icon got from silk icon set (www.famfamfam.com) IfExist, %Scriptname%.ico Menu, Tray, Icon,%ScriptName%.ico IfExist %Scriptname%.exe Menu, Tray, Icon,%ScriptName%.exe SetTimer,Lock,20000 return #l:: critical,on If not LockEnable GoSub,AutoLock run,rundll32.exe user32.dll`, LockWorkStation critical,off return exit: exitapp Lock: If (A_TimeIdlePhysical > Locktime * 60 * 1000) If LockEnable { if Lock_Warning { if show_traytip traytip,Locking in 5 seconds!,LockWorkstation is going to lock the computer in 5 seconds if you don't touch anything,6,1 SoundPLay,LockWorkstation.wav,wait loop,20 { If (A_TimeIdlePhysical < Locktime * 60 * 1000) { traytip, return } sleep,200 } } WinGetClass,winclass,A if Winclass in %ExceptionList% return run,rundll32.exe user32.dll`, LockWorkStation } return LockDirectly: run,rundll32.exe user32.dll`, LockWorkStation return AutoLock: critical,on If LockEnable { LockEnable:=False Menu, tray, Uncheck, Auto-Lock sometemptimer := AutoLockDisableTime * 60 * 1000 settimer,AutoLock,%sometemptimer% Menu,Tray,Icon,LockWorkstation2.ico } else { LockEnable:=True Menu, tray, Check, Auto-lock settimer,AutoLock,off Menu,Tray,Icon,LockWorkstation2.ico IfExist, %Scriptname%.ico Menu, Tray, Icon,%ScriptName%.ico else IfExist %Scriptname%.exe Menu, Tray, Icon,%ScriptName%.exe } critical,off return ;******************************************************************about / help AboutHelp: Gui,destroy IfExist, %Scriptname%.ico Gui, add, Picture, x15 y35 w30 h30,%Scriptname%.ico else IfExist %Scriptname%.exe Gui, add, picture, x15 y35 w30 h30, %Scriptname%.exe Gui, font, bold s10 Gui, add, text, x65 y45, %Scriptname% v%ScriptVersion% by jgpaiva`n Gui, Font, Gui, Font, s10 Gui, Add ,Text,x15 y95 w410 ,This is a small script for better automatic locking of the computer. This program locks the computer after %LockTime% minutes and when it's disabled, it waits %AutoLockDisableTime% minutes and then enables itself again. There's also an exceptions list which will make it not lock when one of those apps is the active window. Also, before it locks the station, it can make a noise, to give you 5 seconds to move something in order for it not to lock. Most of this can be configured through the ini file. Gui, Add ,Text,X15 Y220,It was suggested by %ScriptSugest% at DonationCoder.com forums, `nin the following thread: Gui, Font,CBlue Underline Gui, Add ,Text,X15 Y255 GPost,%ScriptUrl% Gui, Font Gui, Font, s10 Gui, Add ,Text, y280 X15,`nPlease visit us at: Gui, Font,CBlue Underline s10 Gui, Add ,Text, y313 X15 GMainSite,http://www.donationcoder.com/ Gui, Font IfExist,Cody.png Gui, Add ,Picture, Y290 X280,Cody.png Gui, Add ,Button,y350 x15 gdonateAuthor w116 h30,Donate to the &Author Gui, Font, s9 Gui, Add ,Text,y400 x15 h10,If you like this program please make a donation to help further development. Gui,Show return ;******************************************************************ini i/o ReadIni: IniVersion = 1 IfExist,%A_ScriptName%.ini { IniRead,IniVersion,%A_ScriptName%.ini,IniSettings,IniVersion,1 IniRead,LockTime ,%A_ScriptName%.ini,options,Locktime,Error IniRead,AutoLockDisableTime,%A_ScriptName%.ini,options,AutoLockDisableTime,Error IniRead,ExceptionList ,%A_ScriptName%.ini,options,ExceptionList ,Error IniRead,Lock_Warning ,%A_ScriptName%.ini,options,Lock_Warning ,Error IniRead,Show_Traytip ,%A_ScriptName%.ini,options,Show_Traytip ,Error If (LockTime = "Error" OR AutoLockDisableTime= "Error" OR ExceptionList = "Error" OR Lock_Warning = "Error" OR Show_Traytip = "Error") { MsgBox,There was an error reading the .ini file.`nThe script will be restarted, and the ini file will be deleted. FileDelete,%A_ScriptName%.ini Reload sleep 20000 } } else { GoSub, AboutHelp GoSub,WriteIni } return WriteIni: IfNotExist,%A_ScriptName%.ini FileAppend, ,%A_ScriptName%.ini #commentflag // FileAppend, ( ;LockTime represents the time in minutes before the system is locked. Can be non-integer numbers ;AutoLockDisableTime represents the time that the script will wait before it enables itself after being disabled by the user. Can be non-integer numbers ;ExceptionList is a comma-separated list of window classes which, when active, wil make the script not lock. ;Lock_Warning indicates if the script should send a warning before locking the workstation. 1 represents YES and 0 represents NO ;Show_Traytip is a boolean that indicates if the script should show a traytip before locking. (only makes sense if Lock_Warning = 1). ;Ignore IniSettings options. ),%A_ScriptName%.ini #commentflag ; IniWrite,%LockTime% ,%A_ScriptName%.ini,options,LockTime IniWrite,%AutoLockDisableTime%,%A_ScriptName%.ini,options, AutoLockDisableTime IniWrite,%ExceptionList% ,%A_ScriptName%.ini,options,ExceptionList IniWrite,%Lock_Warning% ,%A_ScriptName%.ini,options,Lock_Warning IniWrite,%Show_Traytip% ,%A_ScriptName%.ini,options,Show_Traytip IniWrite,%IniVersion% ,%A_ScriptName%.ini,IniSettings,iniversion Return ;***********gui labels Post: Run,%ScriptUrl% GoSub,GuiCLOSE return MainSite: Run,http://www.donationcoder.com/ GoSub,Guiclose return DonateSite: Run,http://www.donationcoder.com/Donate/index.html GoSub,Guiclose return DonateAuthor: Run,https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=jgpaiva`%40gmail`%2ecom&item_name`=donate`%20to`%20jgpaiva&item_number`=donationcoder`%2ecom&no_shipping=1&cn=Please`%20drop`%20me`%20a`%20line`%20`%3aD&tax`=0¤cy_code=EUR&bn=PP`%2dDonationsBF&charset=UTF`%2d8 GoSub,Guiclose return GuiClose: buttonok: gui,destroy return