NoSleep for Mac

Hello, I have some code that was written for my windows machine, it basically keeps my machine awake and my teams active pressing a random key every so often for a particular amount of time. However, this code was written in .VBS and does not work on my new macbook. I am looking to see if someone can help me re-write this code or has some of their own I can use.

Dim objShell, lngMinutes, boolValid

Set objShell = CreateObject("WScript.Shell")

lngMinutes = InputBox("How long you want to keep your system awake?" & Replace(Space(5), " ", vbNewLine) & "Enter minutes:", "Awake Duration") 'we are replacing 5 spaces with new lines

If lngMinutes = vbEmpty Then 'If the user opts to cancel the process

'Do nothing

Else

On Error Resume Next
Err.Clear
boolValid = False
lngMinutes = CLng(lngMinutes)
If Err.Number = 0 Then 'input is numeric
	If lngMinutes > 0 Then 'input is greater than zero
		For i = 1 To lngMinutes
			WScript.Sleep 60000 '60 seconds
			objShell.SendKeys "{SCROLLLOCK 2}"
		Next
		boolValid = True
		MsgBox "Forced awake time over. Back to normal routine.", vbOKOnly+vbInformation, "Task Completed"
	End If
End If
On Error Goto 0
If boolValid = False Then
	MsgBox "Incorrect input, script won't run" & vbNewLine & "You can only enter a numeric value greater than zero", vbOKOnly+vbCritical, "Task Failed"
End If

End If

Set objShell = Nothing Wscript.Quit 0

Replies

You haven't said why you want to do this, but here are some suggestions System Preferences/Battery, set the machine to not sleep and not send the display to sleep 'man pmset' favorite search engine - "Caffeine macOS"