92 lines
1.6 KiB
AutoHotkey
92 lines
1.6 KiB
AutoHotkey
#Requires AutoHotkey v2 ; v2 only
|
|
#SingleInstance force
|
|
CoordMode("Mouse", "Screen")
|
|
|
|
waittime := 10000
|
|
|
|
for i in A_Args
|
|
{
|
|
if (i = "on")
|
|
{
|
|
A_IconHidden := 1
|
|
Start(1,2,3)
|
|
}
|
|
else if (i = "off")
|
|
{
|
|
ExitApp()
|
|
}
|
|
else
|
|
{
|
|
MsgBox (i)
|
|
}
|
|
}
|
|
|
|
|
|
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 := Gui()
|
|
myGui.Opt("+AlwaysOnTop +ToolWindow")
|
|
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"))
|
|
myGui.Title := "msmv"
|
|
If (A_IconHidden = false)
|
|
{
|
|
myGui.Show("h28 w60")
|
|
}
|
|
|
|
|
|
Start(A_GuiEvent, GuiCtrlObj, Info)
|
|
{
|
|
SetTimer(Msmv,waittime) ; Checks if the has been input in the last 2 minutes every 30 secs, easier to stop a loop with SetTimer
|
|
If (A_IconHidden = false)
|
|
{
|
|
ButtonStart.Visible := false
|
|
ButtonStop.Visible := true
|
|
}
|
|
}
|
|
|
|
Stop(A_GuiEvent, GuiCtrlObj, Info)
|
|
{
|
|
SetTimer(Msmv,0)
|
|
If (A_IconHidden = false)
|
|
{
|
|
ButtonStop.Visible := false
|
|
ButtonStart.Visible := true
|
|
}
|
|
}
|
|
|
|
Msmv(*)
|
|
{
|
|
If (A_TimeIdle > waittime) ; https://www.autohotkey.com/docs/Variables.htm#User_Idle_Time
|
|
{
|
|
x := Random(, A_ScreenWidth)
|
|
y := Random(, A_ScreenHeight)
|
|
MouseMove(x, y)
|
|
}
|
|
}
|
|
|
|
GuiToggle(ItemName, ItemPos, MenuObj)
|
|
{
|
|
global
|
|
If (WinExist("msmv"))
|
|
{
|
|
myGui.Destroy()
|
|
MenuObj.Check(ItemName)
|
|
}
|
|
Else
|
|
{
|
|
MenuObj.Uncheck(ItemName)
|
|
myGui.Restore()
|
|
}
|
|
Return
|
|
}
|
|
|
|
; exit option from tray menu
|
|
ExtMen(*)
|
|
{
|
|
ExitApp()
|
|
} |