Toggle function for my Mouse Mover Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
grossermanitu
Posts: 18
Joined: 29 Mar 2016, 10:49

Toggle function for my Mouse Mover Script

Post by grossermanitu » 17 May 2021, 06:58

Hello everyone,
I'm using a mouseover script (found it in the forum and added a textbox) so that my laptop doesn't go into sleeping mode too fast (30 seconds and I'm alone in my home office).

I'm using this script that I activate by shortcut and it deactivates by click on the textbox. Is there a way to implement a toggle function, so that I don't have to search for the little textbox on my big screen? Currently, I don't know how to do that :headwall:

Code: Select all

#NumpadMult:: ;Activate Screensaver delay
IfWinExist, %id%
  {
  WinActivate, %id%
  winWaitActive, %id%
  send, {return}
  }
Else

SetTimer, MM, 3000
MsgBox, 0,, Back to work? 
IfMsgBox OK
    SetTimer, MM, Off
return
 
MM:
If direction := !direction
MouseMove, 0, 200,, R
else
MouseMove, 0, -200,, R

return


Rohwedder
Posts: 7626
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Toggle function for my Mouse Mover Script

Post by Rohwedder » 17 May 2021, 09:28

Hallo,
perhaps:

Code: Select all

#NumpadMult:: ;Activate Screensaver delay
IF MM ;Timer is active
{
	SoundBeep, 1000, 20
	SetTimer, MM, Off
	MM := False
	Return
}
IfWinExist, %id%
{
	WinActivate, %id%
	winWaitActive, %id%
	send, {return}
}
Else
{
	SoundBeep, 4000, 20
	SetTimer, MM, 3000
	MM := True
}
return
MM:
If direction := !direction
	MouseMove, 0, 200,, R
else
	MouseMove, 0, -200,, R
return
grossermanitu
Posts: 18
Joined: 29 Mar 2016, 10:49

Re: Toggle function for my Mouse Mover Script

Post by grossermanitu » 18 May 2021, 04:51

Thanks Rohwedder. It works like charm.

Is it possible to integrate a message box that indicates that the Script is running and closes after pushed "ok" or the the toggle button?
Rohwedder
Posts: 7626
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Toggle function for my Mouse Mover Script

Post by Rohwedder » 18 May 2021, 06:41

Then perhaps:

Code: Select all

#NumpadMult:: ;Activate Screensaver delay
IF MM ;Timer is active
{
	SetTimer, MM, Off
	MM := False
	Return
}
IfWinExist, %id%
{
	WinActivate, %id%
	winWaitActive, %id%
	send, {return}
}
Else
	SetTimer, MM, 100
	MM := True
Return
MM:
MsgBox, 0,, Back to work?, 3
IfMsgBox OK
	Goto, #NumpadMult
If direction := !direction
	MouseMove, 0, 200,, R
else
	MouseMove, 0, -200,, R
return
grossermanitu
Posts: 18
Joined: 29 Mar 2016, 10:49

Re: Toggle function for my Mouse Mover Script

Post by grossermanitu » 18 May 2021, 07:25

Excellent Rohwedder! :bravo:

I even learned something.
Thank you very much. :dance:
Post Reply

Return to “Ask for Help (v1)”