Make My Mouse Twerk

MattDaddyRamos

New Member
Joined
Sep 11, 2013
Messages
45
Hi All,

I know there are several thread about this topic but all of them are above my experience and I need someone to dumb it down for me. I am trying to write a macro in an Excel workbook that makes my mouse move to prevent my laptop from timing out. I know about the settings to do so, but I am looking for an Excel macro for a specific reason.

Here is what I need, and please forgive me if I sound elementary with this. Just humor me.

  1. I have Excel 2007, I know how to record a macro while I am doing the steps, but what are the steps to write (or paste) a macro without having to record the steps?
  2. I need someone to write the macro without any extra words or blanks for me to fill in. I just want to copy & paste please.
  3. I need it to make the mouse curser move enough to "reset the time out timer thingy".
  4. I need it to repeat every minute and automatically stop (so that it can time out) after X (adjustable amount of time) or X number of times (minutes), whichever is easiest for you.
  5. Name it, word it, build it however, just tell me how to make it work on my sheet and dont leave anything for me to do other than copy & paste PLEASE.

I've given this 3+ hours of trial and error and used the threads on several message boards but I can't seem to get it to work perfectly & keep getting errors. I am a newby at VBA so please explain what is being done so that I may learn from your wisdom.

Thanks in advance for bringing this script down to the toddler level for me. :) And for your patience in doing so. I WILL get this [eventually]!

Matt
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
If you have a timeout routine already, can you not extend that. Seems to me you would be running two timers, one for the close and one for the mouse. I would stick an X on the page that you know where to place it, and tell the timer if (cell)=X then reset timer during the timer cycle, then when you want to give the book out, just delete the X
 
Upvote 0
If you have a timeout routine already, can you not extend that. Seems to me you would be running two timers, one for the close and one for the mouse. I would stick an X on the page that you know where to place it, and tell the timer if (cell)=X then reset timer during the timer cycle, then when you want to give the book out, just delete the X

I dig that idea, problem is that I don't know where to put that or what to write. Matt = Novice
 
Upvote 0
post your timer code between tags, and tell us which sheet might have an x placed on it, in which cell :)
 
Upvote 0
post your timer code between tags, and tell us which sheet might have an x placed on it, in which cell :)

If I understood you right, the "X" would be in Cell O4 and this is what I have as the VB script:

' Routine to set cursor position
Sub Set_Cursor_Pos()
' Looping routine that positions the cursor
Dim x As Long
For x = 1 To 480 Step 20
SetCursorPos x, x
Application.Wait DateAdd("s", 1, Now)
Next x
End Sub

Private dtmNext As Date
' Stop moving cursor
Sub Stop_Cursor()
Application.OnTime Now + TimeValue("00:00:01"), "Set_Cursor_Pos", False
End Sub
 
Upvote 0
something like this

Code:
' Routine to set cursor position
Sub Set_Cursor_Pos()
If Sheets("YOURSHEETNAMEHERE").Range("O4") = "X" Then Exit Sub
' Looping routine that positions the cursor
Dim x As Long
For x = 1 To 480 Step 20
SetCursorPos x, x
Application.Wait DateAdd("s", 1, Now)
Next x
End Sub

Private dtmNext As Date
' Stop moving cursor
Sub Stop_Cursor()
If Sheets("YOURSHEETNAMEHERE").Range("O4") = "X" Then
Application.OnTime Now + TimeValue("00:05:00"), "Set_Cursor_Pos", False
Exit Sub
End If
Application.OnTime Now + TimeValue("00:00:01"), "Set_Cursor_Pos", False
End Sub
 
Upvote 0
something like this

Code:
' Routine to set cursor position
Sub Set_Cursor_Pos()
If Sheets("YOURSHEETNAMEHERE").Range("O4") = "X" Then Exit Sub
' Looping routine that positions the cursor
Dim x As Long
For x = 1 To 480 Step 20
SetCursorPos x, x
Application.Wait DateAdd("s", 1, Now)
Next x
End Sub

Private dtmNext As Date
' Stop moving cursor
Sub Stop_Cursor()
If Sheets("YOURSHEETNAMEHERE").Range("O4") = "X" Then
Application.OnTime Now + TimeValue("00:05:00"), "Set_Cursor_Pos", False
Exit Sub
End If
Application.OnTime Now + TimeValue("00:00:01"), "Set_Cursor_Pos", False
End Sub

It's running (I think) but the mouse pointer is not moving. Plus I would prefer to set it so that it stops running after X minutes or loops of the Macro as opposed to having to manually type and delete an X. Any thoughts? Can we make the cursor move slower so I can see it move to be sure it is working? Sorry to be so needy.
 
Upvote 0
I thought the inital idea was to stop the laptop timing out, hence adding the X until you were ready to let the programme run normally
 
Upvote 0
I thought the inital idea was to stop the laptop timing out, hence adding the X until you were ready to let the programme run normally

Yes, it is to prevent laptop from timing out but the end user wants it to stop running after say 20-30 minutes so that the laptop timeout can occur. Essentially, she is trying delay the laptop timeout so that her status on IM shows available for 20-30 minutes after she has stepped away.
 
Upvote 0

Forum statistics

Threads
1,215,262
Messages
6,123,953
Members
449,135
Latest member
jcschafer209

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