lock on alt+ctrl+del + overlay the screen

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
InGearX
Posts: 54
Joined: 14 Oct 2016, 15:53

lock on alt+ctrl+del + overlay the screen

Post by InGearX » 18 Jan 2022, 20:18

I love the script

I've modified it a bit to have a 5 minute default activation

I'd love to add prevention from pressing Alt+Ctrl+Del - maybe on detection on a press of ANY of those keys - it would lock the PC?

what's the best way to add this?

can run this:

Code: Select all


DllCall("LockWorkStation")

;or

Run, "rundll32.exe user32.dll,LockWorkStation" 

;or

Send, {LWin down}
Send, L
Send, {LWin up}
AND I'd love to show a black screen ON ALL the monitors - that possible?

OR add a gray transparent overlay or an image that would stretch on all the screens or etc ...

when lock is engaged - it would remind me that it is locked and maybe show some useful information...

OR at LEAST show ANY non intrusive indicator that it is activated ...

yes I know this isn't perfect ... but this to prevent my gf from playing with the PC if I forget to lock it
and I don't want it to lock every 5 minutes - cause it takes time to re-enter the pass
and I like seeing what ever I had on the screen, but it's locked ...
this is so quick - one key and done

current pass is "abc", try it ... you can kill it with Alt+Ctrl+Del for now :)

what other cool features could be added to it?

Code: Select all

;*******************************************
; --------------- Lock.ahk ------------------
; Locks keyboard and mouse input upon hotkey (win alt l), 
; unlock with password
;
; Timer for locking the computer at idle,
; turned off at default
;
; KST 2012
; original https://www.autohotkey.com/board/topic/63975-cool-screen-lock-usb-is-the-key-try-to-crack/
;
; other https://www.autohotkey.com/board/topic/79318-lock-the-computer/
;*******************************************



#NoEnv ; Avoids checking empty variables to see if they are environment variables

;Tray Menu
	
	Menu, Tray, Icon,shell32.dll,48    ; systray icon is a padlock
	
	Menu, TRAY, NoStandard
	
	Menu, TRAY, Add, Lock (Win Alt l), start_lock
	Menu, TRAY, Add, Set Timer, set_timer
	Menu, Tray, Add
	Menu, Tray, Add, Exit, lock_exit
	Menu, Tray, default, Lock (Win Alt l)
	Time = 5
	SetTimer, UpdateIdleState, 5000
	return

return

	
	
set_timer:		;GUI for setting the time (min) at idle until locking
				;if time = 0 no timer will be set
	Gui, Add, Text,, Idle time until lock (in min)
	Gui, Add, Edit ,  ym  
	Gui, Add, UpDown, vTime Range0-500, -1
	Gui, Add, Button, default ym, OK  
		
	Gui, Show,, Time until lock
	return  

	GuiClose:
	ButtonOK:
		Gui, Submit  
		Gui, Destroy
			
		if (Time < 1)	
			{
			SetTimer, UpdateIdleState, Off
			}
		else
			{
			SetTimer, UpdateIdleState, 5000
			}
	
return



UpdateIdleState:	;check if idle every 5 seconds
	Timems := Time*60*1000
	
	if (A_TimeIdlePhysical > Timems)
		{
		gosub, start_lock
		}
return

lock_exit:						
	ExitApp
return
	

start_lock:						;turn on lock
#!l::
	BlockKeyboardInputs("On")
	BlockMouseClicks("On")
	BlockInput MouseMove
return
	
ResetBlock()					;turn off lock
{ 
	BlockKeyboardInputs("Off")
	BlockMouseClicks("Off")
	BlockInput MouseMoveOff
	return
}    

  
BlockKeyboardInputs(state = "On")
{
   static keys, pass
   keys=Space,Enter,Tab,Esc,BackSpace,Del,Ins,Home,End,PgDn,PgUp,Up,Down,Left,Right,CtrlBreak,ScrollLock,PrintScreen,CapsLock,Pause,AppsKey,LWin,RWin,Control,Alt,Shift,LCtrl,RCtrl,LShift,RShift,LAlt,RAlt,NumLock,Numpad0,Numpad1,Numpad2,Numpad3,Numpad4,Numpad5,Numpad6,Numpad7,Numpad8,Numpad9,NumpadDot,NumpadDiv,NumpadMult,NumpadAdd,NumpadSub,NumpadEnter,NumpadIns,NumpadEnd,NumpadDown,NumpadPgDn,NumpadLeft,NumpadClear,NumpadRight,NumpadHome,NumpadUp,NumpadPgUp,NumpadDel,Media_Next,Media_Play_Pause,Media_Prev,Media_Stop,Volume_Down,Volume_Up,Volume_Mute,Browser_Back,Browser_Favorites,Browser_Home,Browser_Refresh,Browser_Search,Browser_Stop,Launch_App1,Launch_App2,Launch_Mail,Launch_Media,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,1,2,3,4,5,6,7,8,9,0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,ä,ü,ö,å,ø,æ,²,&,é,",',(,-,è,_,ç,à,),=,$,£,ù,*,~,#,{,[,|,``,\,^,@,],},;,:,!,?,.,/,§,<,>,vkBC
	
	pass = abc 				;PASSWORD
	
	passcounter := 0
	
   Loop,Parse,keys, `,
      Hotkey, *%A_LoopField%, passcheck, %state% UseErrorLevel
   
    Return

		passcheck:			
			StringReplace, CurrentChar, A_ThisHotkey, *			; remove the leading "*" in the Hotkey variable
			
			StringMid, PassChar, pass, passcounter+1, 1			;get the effective character from pass
						
			if (CurrentChar = PassChar)							;check if the pass character equals the pressed key
				{
				passcounter++									;if yes, next character from the password gets effective
				if (passcounter = StrLen(pass))					;if all characters did match, stop the lock			
					{
					ResetBlock()
					return
					}
							
				} 
			else
				{
				passcounter := 0								;if one character didn't match, the first character gets effective again
				 
				}
						
			Return
			
		
		
}


BlockMouseClicks(state = "On")
{
   static keys="RButton,LButton,MButton,WheelUp,WheelDown"
   Loop,Parse,keys, `,
      Hotkey, *%A_LoopField%, MouseDummyLabel, %state% UseErrorLevel
   Return

		MouseDummyLabel:		; hotkeys need a label, so give them one that do nothing
			Return
}

Last edited by InGearX on 18 Jan 2022, 20:35, edited 7 times in total.

InGearX
Posts: 54
Joined: 14 Oct 2016, 15:53

Re: lock on alt+ctrl+del + overlay the screen

Post by InGearX » 18 Jan 2022, 20:19

works on my Win 10

Post Reply

Return to “Ask for Help (v1)”