Files
d3k/msmv.ahk
T

92 lines
1.6 KiB
AutoHotkey
Raw Normal View History

2026-08-28 12:29:53 -05:00
#Requires AutoHotkey v2 ; v2 only
2026-06-17 12:09:10 -05:00
#SingleInstance force
CoordMode("Mouse", "Screen")
2023-07-14 10:27:33 -05:00
2026-08-28 12:29:53 -05:00
waittime := 10000
2023-07-14 10:27:33 -05:00
2026-08-28 12:29:53 -05:00
for i in A_Args
2023-07-14 10:27:33 -05:00
{
2026-08-28 12:29:53 -05:00
if (i = "on")
{
A_IconHidden := 1
Start(1,2,3)
}
else if (i = "off")
{
ExitApp()
}
else
{
MsgBox (i)
2026-06-17 12:09:10 -05:00
}
2023-07-14 10:27:33 -05:00
}
2026-08-28 12:29:53 -05:00
2026-06-17 12:09:10 -05:00
A_TrayMenu.Delete() ; None of the standard tray buttons
2026-08-28 12:29:53 -05:00
A_TrayMenu.Add("Hide GUI", GuiToggle) ; Adds a button to toggle the gui
2026-06-17 12:09:10 -05:00
A_TrayMenu.Add("Exit", ExtMen) ; Exit button
2026-08-28 12:29:53 -05:00
myGui := Gui()
2026-06-17 12:09:10 -05:00
myGui.Opt("+AlwaysOnTop +ToolWindow")
2026-08-28 12:29:53 -05:00
ButtonStart := myGui.Add("Button", "x3 y3 w55 h20 +Center", "Start")
ButtonStart.OnEvent("Click", Start.Bind("Normal"))
ButtonStop := myGui.Add("Button", "x3 y3 w55 h20 +Center Hidden", "Stop")
ButtonStop.OnEvent("Click", Stop.Bind("Normal"))
2026-06-17 12:09:10 -05:00
myGui.Title := "msmv"
2026-08-28 12:29:53 -05:00
If (A_IconHidden = false)
{
myGui.Show("h28 w60")
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:29:53 -05:00
Start(A_GuiEvent, GuiCtrlObj, Info)
2026-06-17 12:09:10 -05: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
2026-08-28 12:29:53 -05:00
If (A_IconHidden = false)
{
ButtonStart.Visible := false
ButtonStop.Visible := true
}
2026-06-17 12:09:10 -05:00
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:29:53 -05:00
Stop(A_GuiEvent, GuiCtrlObj, Info)
2026-06-17 12:09:10 -05:00
{
SetTimer(Msmv,0)
2026-08-28 12:29:53 -05:00
If (A_IconHidden = false)
{
ButtonStop.Visible := false
ButtonStart.Visible := true
}
2026-06-17 12:09:10 -05:00
}
2023-07-14 10:27:33 -05:00
2026-08-28 12:29:53 -05:00
Msmv(*)
2026-06-17 12:09:10 -05:00
{
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-08-28 12:29:53 -05:00
GuiToggle(ItemName, ItemPos, MenuObj)
{
2026-06-17 12:09:10 -05:00
global
2026-08-28 12:29:53 -05:00
If (WinExist("msmv"))
2023-07-14 10:27:33 -05:00
{
2026-08-28 12:29:53 -05:00
myGui.Destroy()
MenuObj.Check(ItemName)
2023-07-14 10:27:33 -05:00
}
Else
{
2026-08-28 12:29:53 -05:00
MenuObj.Uncheck(ItemName)
myGui.Restore()
2023-07-14 10:27:33 -05:00
}
2026-08-28 12:29:53 -05:00
Return
2026-06-17 12:09:10 -05:00
}
2026-06-17 12:09:10 -05:00
; exit option from tray menu
2026-08-28 12:29:53 -05:00
ExtMen(*)
2026-06-17 12:09:10 -05:00
{
ExitApp()
}