Lock keyboard and mouse while playing youtube in windows 10?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
guaordiola
Posts: 1
Joined: 02 Jul 2022, 20:57

Lock keyboard and mouse while playing youtube in windows 10?

Post by guaordiola » 02 Jul 2022, 20:59

Is this possible? How? I keep getting distracted in youtube. So I thought if the mouse and keyboard gets locked, I'd be more focused. I just need "space" and "arrow" keys unlocked and i'd be good.

Rohwedder
Posts: 7550
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Lock keyboard and mouse while playing youtube in windows 10?

Post by Rohwedder » 03 Jul 2022, 03:09

Hallo,
only "space" and "arrow" keys unlocked is inconvenient.
Escape minimizes Youtube and thus deactivates the lock:

Code: Select all

SetTitleMatchMode, 2
Hotkey, IfWinActive, YouTube
For all, LF in [[0x1FF,"sc{:X}"],[0xFF,"vk{:X}"]]
	Loop,% LF.1
		IF (""<Key:=GetKeyName(Format(LF.2, A_Index)))
		And !InStr("{Escape}{Space}{Left}{Right}{Up}{Down}", "{" Key "}")
			Hotkey, *%Key%, :X:Y
#IfWinActive, YouTube
~*Esc::WinMinimize, A
:X:Y::Return
#If

Post Reply

Return to “Ask for Help (v1)”