Tuesday, January 13, 2009

Lock Windows + Turnoff Monitor

At work place I have two Desktop and one laptop so whenever i step out from my desk I have to lock and turnoff monitors for there machine, basically 3x2=6 manual step. below is autoit code to lock and turnoff monitor
;Turnoff Monitor
Opt("WinTitleMatchMode", 4)
$WM_SYSCOMMAND = 274
$SC_MONITORPOWER = 61808
$POWEROFF=2
$hwnd = WinGetHandle('classname=Progman')
DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hwnd, 'int', $WM_SYSCOMMAND, 'int', $SC_MONITORPOWER, 'int', $POWEROFF)

; Lock workstation
ShellExecute(@SystemDir &"\rundll32.exe", "user32.dll, LockWorkStation")

Now I use to run this script on all my 3 machines in one go using psexec and my work is done in one step.

No comments: