Files
d3k/msmv.ahk
T

77 lines
1.6 KiB
AutoHotkey
Raw Normal View History

2026-06-17 12:09:10 -05:00
#Requires AutoHotkey v2.0 ; v2 only
#SingleInstance force
CoordMode("Mouse", "Screen")
2023-07-14 10:27:33 -05:00
2026-06-17 12:09:10 -05:00
waittime := 5000
ogcStop := 13
global nogui := False
2023-07-14 10:27:33 -05:00
2026-06-17 12:09:10 -05:00
Switch A_Args
2023-07-14 10:27:33 -05:00
{
Case "on":
2026-06-17 12:09:10 -05:00
Goto(Start)
2023-07-14 10:27:33 -05:00
Case "off":
2026-06-17 12:09:10 -05:00
ExitApp()
default:
for x in A_Args {
MsgBox(x)
}
}
myGui := Gui()
A_TrayMenu.Delete() ; None of the standard tray buttons
A_TrayMenu.Add("Hide GUI", GuiToggle()) ; Adds a button to toggle the gui
A_TrayMenu.Add("Exit", ExtMen) ; Exit button
myGui.Opt("+AlwaysOnTop +ToolWindow")
ogcButtonStart := myGui.Add("Button", "x3 y3 w55 h20 +Center", "Start")
ogcButtonStart.OnEvent("Click", Start.Bind("Normal"))
ogcButtonStop := myGui.Add("Button", "x3 y3 w55 h20 +Center Hidden", "Stop")
ogcButtonStop.OnEvent("Click", Stop.Bind("Normal"))
myGui.Title := "msmv"
myGui.Show("h28 w60")
Start(A_GuiEvent, GuiCtrlObj, Info, *)
{
ogcButtonStart.Visible := false
SetTimer(Msmv,waittime) ; Checks if the has been input in the last 2 minutes every 30 secs, easier to stop a loop with SetTimer
ogcButtonStop.Visible := true
}
Stop(A_GuiEvent, GuiCtrlObj, Info, *)
{
ogcButtonStop.Visible := false
SetTimer(Msmv,0)
ogcButtonStart.Visible := true
2023-07-14 10:27:33 -05:00
}
2026-06-17 12:09:10 -05:00
Msmv()
{
If (A_TimeIdle > waittime) ; https://www.autohotkey.com/docs/Variables.htm#User_Idle_Time
2023-07-14 10:27:33 -05:00
{
2026-06-17 12:09:10 -05:00
x := Random(, A_ScreenWidth)
y := Random(, A_ScreenHeight)
MouseMove(x, y)
2023-07-14 10:27:33 -05:00
}
2026-06-17 12:09:10 -05:00
}
2023-07-14 10:27:33 -05:00
2026-06-17 12:09:10 -05:00
GuiToggle(){
global
2023-07-14 10:27:33 -05:00
If !nogui
{
2026-06-17 12:09:10 -05:00
myGui.Hide()
A_TrayMenu.Check("1&")
2023-07-14 10:27:33 -05:00
nogui := True
}
Else
{
2026-06-17 12:09:10 -05:00
A_TrayMenu.Uncheck("1&")
2023-07-14 10:27:33 -05:00
nogui := False
2026-06-17 12:09:10 -05:00
myGui.Show()
2023-07-14 10:27:33 -05:00
}
2026-06-17 12:09:10 -05:00
}
2026-06-17 12:09:10 -05:00
; exit option from tray menu
ExtMen(A_ThisMenuItem, A_ThisMenuItemPos, MyMenu)
{
ExitApp()
}