d3k/msmv.ahk

63 lines
1.3 KiB
AutoHotkey
Raw Normal View History

#SingleInstance, force
2023-02-01 14:41:14 -06:00
CoordMode, Mouse, Screen
2023-02-13 16:20:22 -06:00
waittime := 160000
2023-02-01 14:41:14 -06:00
Switch A_Args[1]
{
Case "on":
Menu, Tray, NoIcon
Goto, Start
Case "off":
ExitApp
}
2023-02-01 14:41:14 -06:00
Menu, Tray, Add, Hide GUI, GuiToggle ; Adds a button to toggle the gui
Menu, Tray, Add, Exit, GuiClose ; Exit button
Menu, Tray, NoStandard ; None of the standard tray buttons
Gui, +AlwaysOnTop +ToolWindow
Gui, Add, Button, x3 y3 w55 h20 gStart +Center, Start
Gui, Add, Button, x3 y3 w55 h20 gStop +Center, Stop
Gui, Show, h28 w60, msmv
2023-02-01 14:41:14 -06:00
GuiControl, Hide, Stop ; Since we want the Start button to show first
Return
Start:
GuiControl, Hide, Start
2023-02-01 14:41:14 -06:00
SetTimer, Msmv, %waittime% ; Checks if the has been input in the last 2 minutes every 30 secs, easier to stop a loop with SetTimer
GuiControl, Show, Stop
Return
Stop:
GuiControl, Hide, Stop
SetTimer, Msmv, off
GuiControl, Show, Start
Return
Msmv:
2023-02-01 14:41:14 -06:00
If (A_TimeIdle > waittime) ; https://www.autohotkey.com/docs/Variables.htm#User_Idle_Time
{
Random, x,, %A_ScreenWidth%
Random, y,, %A_ScreenHeight%
MouseMove %x%, %y%
}
Return
GuiToggle:
If !nogui
{
Gui, Hide
Menu, Tray, Check, Hide GUI
nogui := True
}
Else
{
Menu, Tray, uncheck, Hide GUI
nogui := False
Gui, Show
}
Return
GuiClose:
GuiEscape:
2023-02-01 14:41:14 -06:00
ExitApp ; Closes the app when escape or the exit button is pressed