I have actually implemented this in a similar manner to The3rdIcon. Use his answer to get the framework, and I can provide details. Note that the unlocker program he links doesn't work for Windows 7 and up, but this trick will. For my particular case I used a bluetooth device attached to my workstation for proximity detection but you can do whatever is applicable. Here are the actual details.
Since the PCs I'm working with are behind a firewall, I'm using AutoRemote's Chrome extension redirect which works very well.
Tasker Bluetooth Near profile
Notes: Ignore the %WorkHint bit, it's for something else. This profile does require that you be paired to the device, but not connected. It isn't terribly responsive (for battery saving reasons) but will detect near/far within a few minutes. Additionally I use a couple other profiles that can trigger an unlock so that it's more responsive but this should get you started. My example sends to an AutoRemote channel (Work) so that it can lock/unlock 2 computers for me.
Profile: BT Work Near (166)
State: BT Near [ Name:yourbluetoothdevice Address:* Major Device Class:Audio / Video Standard Devices:On Low-Energy (LE) Devices:Off Unpaired Devices:Off Toggle BlueTooth:Off ]
Enter: Anon (167)
A1: Variable Set [ Name:%WorkHint To:true Do Maths:Off Append:Off ]
A2: AutoRemote Message [ Configuration:Recipient: Group
Message: Unlock
Channel: Work Package:com.joaomgcd.autoremote Name:AutoRemote Message Timeout (Seconds):200 ]
Exit: Anon (168)
A1: Variable Clear [ Name:%WorkHint Pattern Matching:Off ]
A2: AutoRemote Message [ Configuration:Recipient: Group
Message: Lock
Channel: Work Package:com.joaomgcd.autoremote Name:AutoRemote Message Timeout (Seconds):200 ]
EventGhost Lock Macro
Notes: These use a little trick to accomplish lock/unlock. It essentially disconnects from the console session and later reconnects to it for the unlock. It still displays the CTRL-ALT-DEL screen and someone seeking to use the PC would actually have to log in. Note that the reconnect trick will not work if you use the EventGhost lock workstation action or an actual WIN-L lock.
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1700">
<Macro Name="Lock Workstation" id="6" Expanded="True">
<Event Name="AutoRemote.Message.Lock" />
<Action>
System.Execute(u'c:\\windows\\system32\\tsdiscon.exe', u'', 0, False, 2, u'', False, True, u'', False, False, False)
</Action>
</Macro>
</EventGhost>
EventGhost Unlock Macro
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1700">
<Macro Name="Unlock Workstation" id="9" Enabled="False" Expanded="True">
<Event Name="AutoRemote.Message.Unlock" />
<Action>
System.Execute(u'C:\\Windows\\System32\\tscon.exe', u'1 /dest:console /password:yourpassword', 0, False, 2, u'', False, True, u'', False, True, False)
</Action>
</Macro>
</EventGhost>
I do use a couple other macros to send a notification to my phone when the PCs are locked or unlocked either automatically or manually. I can post those as well if there is any interest.