This YouTube pause was inspired by Curt Jaimungal. It will ask you if you’re still awake. If you don’t move the mouse / click a key, it will pause the YouTube video. I refactored it a little and renamed it to be a bit more eye-catching thus “AreYouDead”
Are You Dead? Use this script to auto-timeout unless you do something

The key idea of the video is to use AutoHotkey to create a script that prevents falling asleep while watching YouTube videos by pausing them when there is no activity.
- 00:00 👨💻 Isaiah’s script pauses YouTube videos when the mouse is not moved, preventing falling asleep while watching.
- The speaker discusses a script created by Isaiah to pause YouTube videos when the mouse is not moved for a set amount of time, solving the issue of falling asleep while watching videos.
- 01:07 🚨 Resolved issue with sleep timer and leap timer in script by breaking down timer into one-second chunks and using variable to track desired time.
- The speaker encountered an issue with a script involving a sleep timer and a leap timer, but resolved it by breaking down the timer into one-second chunks and using a variable to track the desired time.
- Always have a way to exit an infinite loop.
- 03:00 ⏰ A 30-minute timer with a GUI that pauses the video if there’s no activity, and an advanced input hook for user input.
- The speaker sets a 30-minute timer that sleeps for one second intervals and after the timer ends, a GUI appears indicating that the video will be paused if there is no activity, followed by a loop that lasts for one minute or less.
- The input hook is a more advanced version of the input command that waits for user input.
- 04:54 💤 The code checks if the user is asleep by monitoring mouse position and keyboard input.
- The code checks if the user is asleep by comparing the position of the mouse and waiting for keyboard input.
- 06:22 📝 The speaker shows how to pause a YouTube video after one minute using the F12 key and waiting for a banner to appear.
- Be careful with infinite loops and have a way to exit them, as demonstrated in the script for activating a window and sending a key.
- The speaker demonstrates how to pause a YouTube video after one minute using the F12 key and waiting for a banner to appear.
- 08:32 💤 Adjusting sleep time to speed up program due to impatience.
- The speaker is adjusting the sleep time of a program to make it run faster due to their impatience.
- 10:11 💤 Use the run command to schedule a shutdown or hibernate action with a timer and confirm the person is asleep before performing the action.
- The video should start after a brief pause and if it’s already running, it should be paused instead.
- You can use the run command with the shutdown command to schedule a shutdown or hibernate action with a timer, and confirm the person is asleep before performing the action.
- 12:20 💻 Use AutoHotkey to customize your computer’s functions, prevent it from locking, and improve your productivity.
- You can use the power profession library to set different states for your computer, including suspend and hibernate, and quickly verify if someone is asleep or not.
- The input hook function can replace the sleep function with a weight function for a one-second delay and also captures mouse movement.
- Prevent your computer from locking by performing a small movement before it happens.
- The speaker explains how to modify a function or call a different function to create a program that suits your needs using AutoHotkey, and recommends reaching out for consulting services to level up your skills.
hey everyone sokurt and i’m going to put a link to his channel like i said his channel’s on like deep thought stuff it’s amazing buthe he had this thing which actually i think it’s probably somewhat common things that people want to like be watching something on youtube and fall asleep but have the video paused after a set at a time and so he was working on a script doing a loop and and just working through it and asked if we had an ideas and soIsaias and i were chatting and he actually i had a different
approach but he came up and he was like why don’t we just you know look for the last time the mouse was moved and you know hey if the mouse is moved hopefully someone’s awakening this like me and you’re snoring and your hand is on the thing yeah so and then he was just walking me through what he built here so let’s take a look at this yeah so basicallyhere’s the deal what we have here isthe issue that he was experiencing and probably i should show the original maybe i should show the
original so you could see what the issue was and what is it that i made to solve itit was he showed us a specific script that he was doing with the timer right so he had a toggle here had a sleep timer and then he was doing this leap 30 times 60 times sorry times 1060. so that means 30well he was actually doing it there the other way around which is 30 seconds times 60 so that means like you know he was trying to do 30 minutes right right yeah yeah yeah yeah it was being it was 60 times 1000 right so it doesn’t matter in the end buthis
issue was that as soon as this leap timer was going into effect this this script was locked and he was like okay so i don’t want it to continue playing and so on but then as soon as the sleep timer goes on like i cannot do anything yeah and you and i we coveredin a different video something very similar and mymy recommendation was whenever you have these very big timers just make it into chunks of one second each and that’s exactly what i’m doing here so first of allmy maini just set up a variable here to
keep track of how many minutes i want the loop to actuallythis is kind of like the timer i want a 30 minute timer or probably a one minute timer it doesn’t matter this is my toggle it’s going to be toggled and now this is the funny thing i’m going to go into an infinite loop now whenever you have an infinite loop the first thing you have to do is have a way to go out of that loop and our case is going to be a toggle and in some other cases that i’m going to show you laterit could be kind of like a limit how
many times you want that to happen before you break but the first thing whenever you have an infinite loop is have a way to go out of there if you don’t have it you’re gonna enter you know an infinite loop now after that we are actually checking foryoutube and now we start with what i was talking about so in this case i’m going to multiply the minutes that i put here maybe 30.
multiply it by 60 which is 60 seconds each minute would be 60 seconds and for each of those i’m gonna sleep for one second so that’s where i’m gonna start with a 30 minute timer here which also obeys the toggle so if i press the toggle it would also break out of the loop okayand again i am making the sleeps 1 000 milliseconds that means one second long so in in case that i want to do any other stuff down here i will be able to my script is not going to be locked for 30 minutes you know what i mean
it’s just going to be locked for one second now after the 30 minutes passed i’m going to show a little gui saying like hey if there’s no activity then the video will be paused and in there i’m just gonna go ahead and enter a specific loop now this loop here what i’m gonna do is that i’m going tofor i don’t know one minute or less it’s just because it takes a little time for you to just move the mouse or press a key on the keyboard i’m going to set this up to 30 or something like
that but i was playing with this guy here i don’t know if you have tried this the input have you ever tried with a before beforei think when i was debugging something you know looking for pressing a key or something yeah yeah so yeah maybe maybe in this caseit is the same as the input command i don’t know if you know that one so the input command just waits for you to type something well the input hook actually does something similar but it is a little bit more advanced that’s what’s going on i was
just playing a little bit with itin in this case the first thing is that i want to make sure that i’m gonna start with the assumption that he’s asleep right so that’s the first thing i’m gonnamake sure that ithink that he’s asleep now i have my weight of breaking out of my loop there are certain situations here in which i’m gonna just explain for a second and now here’s the part that i just checked for you know if the user is alive i think there’s another way of doing this but
this is kind of like the manual way first i grab my position of the mouse right now and second of all later on i’m gonna grab the position again and then compare the two if they’re exactly the same then the mouse haven’t moved and that means that you know you haven’t done anything and probably you’re not in the computer that’s one way of checking the second way is by waiting for keyboard input so if you press anything on the keyboard it will also count as input that’s my second part here that if there
is anything in that variable that’s another way for me to know that you’re not asleep so those are the this is my if statement up here this is my check and after i do that i will do it several times probably you know 60 times because it’s one time one second each time and after that i would destroy the gui and if you are asleep so if you never actually pressed your keyboard or move your mouse then i will go ahead and pause youtube that’s myum look right here and again whenever you enter an infinite loop in
this case this is another one which is kind of like always be careful with these guys i’m checking if the windows the window that has youtube is not active if it is not active i will go ahead and try to activate it and usually i will try to do that until the window is active but what happens if my script never activates the window right for whatever reason i don’t know whatever reason then just try that 10 times and then just break right and again when i go out of that loop i do not assume that the window is active i will
check again if the window is active then go ahead and send the key if not don’t do thatso so again keep always this in mind whenever you have a loop and if that loop is an infinite loop it’s not a specific amount of times have a way to go out of there you’re going to regret it if you don’tbut that’s it that’s that’s the little script we just go ahead and run it again this is a keyboard let’s go ahead and stop this for a second let me make it one minute let’s just go ahead and rerun
it now i’m going to go ahead and go to youtube for a secondit doesn’t matter what i put in there i’m gonna have it pause for the second and now i’m gonna press the f12 key after one minute so at 41 more or lessi should get a banner at the bottom that says that you know there hasn’t been any you knowthat that the video will be paused in the meantime so i’m just gonna wait a little bit longerand let me see as soon as that banner shows up that’s the cool thing i could just move the mouse and it will
go away and it will just wait for the next minute or if i press my keyboardit would also just disappear and continue with the next one now i’m that’s one of the things that i hate aboutwaiting for stuff like this is that i feel like it should have done it already let’s see where we are yeah we are here let’s break right here let’s see if it breaks so it is actually doing the sleep many minutes one times oh there it is yeah there should be so if i go ahead and it’s just like my patience is not that much
so oh i don’t know if you noticed the banner was down there for a second yeah and then as soon as i moved the mouse it just went away right now it should be on the loop again right so my patience is not enough right just one minute and i was still like okay hello you know why don’t you why don’t you just change the instead of time 60 do it times 10you mean oh yeah yeah yeah sure and then that way it’ll besix seconds so so yeah it should be kind of like quicker yeah let’s just go ahead and
because i understand i mean i was gonna say i could just pause the video for a bit so people aren’t waiting for it yeah no it is okay it doesn’t matter in any case the only thing is thatthere is my there is my as soon as i move the mouse it goes away rightnow let’s wait a little bit more let me just press something on the keyboard this is exactly what you want because yeah you’re like no i still i’m there okay but so i press something on my keyboard so in this type i i press something on
the keyboard and now i’m gonna just leave it i’m just gonna and you will see how the video should actually start so now it’s gonna wait a little bithere it’s just waiting right and it should go away and then start the video that’s my there it is in general if the video is actually running what it should do is actually pause the video so yeah it would do the opposite of whatever he’s doing and again this is a toggle so i could just go ahead andand press the back to your code please just say you know if you wanted
to do something else like hibernate you know or shut down right sure so i’d say is yeah we could just go ahead and you’re changing the name of that the the pause youtube to to be something broader but it doesn’t matter right in this case we’re pausing it but right but in any case it could be anything like perform action probably like shut down hibernate pc if you want and and for those who don’t know how to do that you could actually use the run command with the shutdown shutdown minus so you could use the minus t in
there yeah f is a timer on it as well right yeah the shutdown you can have a timer for that so i i have kind of like in mysnippetlibrary here i have this piece of code that is exactly like that it just it has a little gui whatever you put in there gets passed to the shutdown command with whatever type whatever time you have so you can have one hour you know and schedule it and it would schedule your shutdown in one hour so yeah you could actually just use the run command like thisright here and it would be the same
right so you could perform any action you want afteryou confirm that the person is actually asleep so basically this is a very simple script we were justplaying a little bit aboutwith it and yeah you could go ahead andoh there’s anAuto one yeah that’sso that’s another way of doing it yeah another one for suspender hibernate right i have Hotkeys assigned to those so i i got rid of theHotkey butyeah so you have the power oh okay yeah so this is one of the the locallibraries that you could actually
call the power profession and this is the the one that allows you to set different states for the computer you can actually suspend it that’s a sleep and one for hibernate and i think you should be able to put another one in here i think there’s three of them i will check on that later but i haven’t used it that muchbut there you go this is a very quickway for you to verify that somebody is asleep or not that like just get the position andi was using a sleep in here instead of this but i noticed that the
weight function for the input hook i could put a timer on it like a timeout and the timeout would be one second so i had kind of like a sleep 1000 in here between the two mouse positions but i just noticed that with the weight with the weight function i could have my one second delay so it’s the same and actually yeah and this and this input hook also captures the mouse movement that’s the reason why if you move the mouse it actually does not wait the full second it just goes ahead andverifies that you just um
have performed something so another great use of thisi i know my friend dr cook heyou know he has computers from his he’s a professor right yeah he has computers from school and they are forced that after x amount of time without movement it will lock the screen you know it comes up auto lock and they have the crazy passwords so you could do this too just before it happens to say like hey it’s about to lock you know do you want to watch right like that that could be a wicked easy thing to apply right right and then then you just or
maybe you could just but we had it we had to move the mouse they moved the mouse exactly that’s what i was gonna say like you could do a little yeah exactly it doesn’t have to be a very big movement it’s just a little jig and that’s it and you could prevent the look like that but yeah that’s that’sthose are the ways that we could do it i just changed the timer so now it’s going to be one minute for this one and 30 minutes for that one so it’s gonna give you at least one minute
for you to move the mouse or press a key and it’s going to give you 30 minutes between each break and again if you press f12 again it would just stop the loop so if you are not watching videos you can just press it and go out and do whatever you want and whenever you’re watching videos then you just turn it on again so yeah or or and obviously it’s easy to adapt this to be some other program or something that on what to to do but yeah so long so long as you change this function to whatever you want either either
eithe-Automator.
com and we offer consulting services where we will help educate you and work with you to level you up to me it’s best ways that you can start learning AutoHotkey and make really significant jumps is having someone assess where you are and then kind of nudge you a little bit higher and higher and get your code worked on by someone who’s been doing it for a long time