how would i write a macro that makes a key stroke every minute?

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
846
Office Version
  1. 2013
Platform
  1. Windows
I dont really know how to write macros else I'd do it myself. Essentially I just want to keep my mouse or keyboard busy for 10 mins. Doesn't have to be continuously busy, just some activity once every minute or so, even if it's just choosing a different cell in a spreadsheet. Would someone be able to help me with this? Would really appreciate it!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
you don't need excel to to do this
create a blank text file on desktop

insert
Dim objResult
Set objshell = WScript.CreateObject("WScript.Shell")
Do While True
objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
Wscript.Sleep (31400)
Loop

save the file as idle.vbs

double click and it will run as long as you have scripting

you can buy a plug in hardware key for lots of money to make a jiggle

the sleep time is in 100ths of a second and it toggles NUMLOCK on then off
 
Upvote 0
Solution
Thanks so much! I'll give this a shot.

What do you mean by as long as you have scripting?

Also what's a plug in hardware key?

If at some point I'd like to change this from numlock to something else - maybe pressing enter, or pressing 'x' and then backspace, how would I do that?

Is there a way to make this stop after a certain time period?
 
Upvote 0
numlock is safest, if you use x you will be creating a character

there are hardware solutions to an automatic screen saver set for when no keyboard activity, this is simple and free
 
Upvote 0
apparently i'm supposed to click on Mark as Solution next to your post but I can't find the button. Am I missing something?
 
Upvote 0
apparently i'm supposed to click on Mark as Solution next to your post but I can't find the button. Am I missing something?
you don't actually need to click, but at the right side of each post their is a tick, which if you click the tick mark will show on the forium, that is the solution that best answers your question / need
 
Upvote 0
you don't need excel to to do this
create a blank text file on desktop

insert
Dim objResult
Set objshell = WScript.CreateObject("WScript.Shell")
Do While True
objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
Wscript.Sleep (31400)
Loop

save the file as idle.vbs

double click and it will run as long as you have scripting

you can buy a plug in hardware key for lots of money to make a jiggle

the sleep time is in 100ths of a second and it toggles NUMLOCK on then off
Thank you for the script. I have two questions:
1. how do I know if program is running? I cant find it anywhere
2. How do I stop it?
 
Upvote 0

Forum statistics

Threads
1,224,943
Messages
6,181,915
Members
453,071
Latest member
Gizmo2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top