Script Runs When NO Mouse Movement
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Script Runs When NO Mouse Movement
Hi, how do I make a script that runs a program or another script when there is no mouse movement after 5 minutes?
Re: Script Runs When NO Mouse Movement
Code: Select all
#Persistent
#InstallMouseHook
SetTimer, IdleCheck, 1000
return
IdleCheck:
if (A_TimeIdleMouse > 300000)
run notepad.exe
return
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Script Runs When NO Mouse Movement
hi there. can you please explain installmousehook. I dont really get it in the tutorialsboiler wrote: ↑25 Jun 2020, 10:46Code: Select all
#Persistent #InstallMouseHook SetTimer, IdleCheck, 1000 return IdleCheck: if (A_TimeIdleMouse > 300000) run notepad.exe return
Re: Script Runs When NO Mouse Movement
It’s what’s needed for AHK to monitor mouse clicks and stuff, but since it takes a lot of memory, it doesn’t install it unless you have a mouse button as a hotkey or something. In this case, A_TimeIdleMouse won’t actually represent the idle time of the mouse unless the mouse hook is installed.
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Script Runs When NO Mouse Movement
Also, what does the 1000 mean in "SetTimer, IdleCheck, 1000"?boiler wrote: ↑25 Jun 2020, 11:21It’s what’s needed for AHK to monitor mouse clicks and stuff, but since it takes a lot of memory, it doesn’t install it unless you have a mouse button as a hotkey or something. In this case, A_TimeIdleMouse won’t actually represent the idle time of the mouse unless the mouse hook is installed.
Re: Script Runs When NO Mouse Movement
It means that it runs that subroutine every 1000 ms, which is 1 second.
In general, it is helpful in learning AHK to look up commands and see what the parameters mean. You can click on SetTimer in the posted script, and it will open that page in the documentation.
In general, it is helpful in learning AHK to look up commands and see what the parameters mean. You can click on SetTimer in the posted script, and it will open that page in the documentation.
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Script Runs When NO Mouse Movement
Your script keeps looping, when the 5 min mark is reached, it keeps popping out many notepad.exe. I had to move the mouse to stop it, but then after the 5 min IDLE, it keeps doing the same thing.boiler wrote: ↑25 Jun 2020, 10:46Code: Select all
#Persistent #InstallMouseHook SetTimer, IdleCheck, 1000 return IdleCheck: if (A_TimeIdleMouse > 300000) run notepad.exe return
Last edited by yabab33299 on 25 Jun 2020, 20:22, edited 1 time in total.
Re: Script Runs When NO Mouse Movement
Code: Select all
#Persistent
#InstallMouseHook
SetTimer, IdleCheck, 1000
return
IdleCheck:
if (A_TimeIdleMouse > 300000) {
run notepad.exe
ExitApp
}
return
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Script Runs When NO Mouse Movement
This script exits out. Can you please be so kind to customize the script to be persistent throughout, and the script restarts the countdown to 5 min IDLE when the mouse is moved. Thankyou very much.boiler wrote: ↑25 Jun 2020, 20:22Code: Select all
#Persistent #InstallMouseHook SetTimer, IdleCheck, 1000 return IdleCheck: if (A_TimeIdleMouse > 300000) { run notepad.exe ExitApp } return
Re: Script Runs When NO Mouse Movement
It automatically starts the 5 minute count again when the mouse is moved. What do do you want it to do after it runs the program? Not run it again if it is already open even if another 5 minutes of inactivity occurs? That would be this:
Code: Select all
#Persistent
#InstallMouseHook
SetTimer, IdleCheck, 1000
return
IdleCheck:
if (A_TimeIdleMouse > 300000) && !WinExist("ahk_exe notepad.exe")
run notepad.exe
return
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Script Runs When NO Mouse Movement
Right-click on the script file in file explorer and select "Create shortcut" from the menu. Then move or copy that shortcut file (not the original file) into your Windows Startup folder, which should be C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.
Re: Script Runs When NO Mouse Movement
Or, if you need your script/program to start earlier in the boot process (for example, to run Process Monitor to watch login events), use 'run as TaskMan'. It's a registry location that runs a value (executable) assigned to a Taskman entry in the context of WINLOGON, i.e. even before Explorer waits for the Service Control Manager to initialise. You need to create the 'Taskman' entry because it's not there by default.
So, if - for arguments sake - I wanted to run WordPad early in the boot process, I could set it using a REG file or AutoHotkey to write the required registry entry/value pair:
So, if - for arguments sake - I wanted to run WordPad early in the boot process, I could set it using a REG file or AutoHotkey to write the required registry entry/value pair:
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Taskman"="C:\\Windows\\write.exe"