update to AHK v2
This commit is contained in:
@@ -1,63 +1,77 @@
|
|||||||
#SingleInstance, force
|
#Requires AutoHotkey v2.0 ; v2 only
|
||||||
CoordMode, Mouse, Screen
|
#SingleInstance force
|
||||||
|
CoordMode("Mouse", "Screen")
|
||||||
|
|
||||||
waittime := 120000
|
waittime := 5000
|
||||||
|
ogcStop := 13
|
||||||
|
global nogui := False
|
||||||
|
|
||||||
Switch A_Args[1]
|
Switch A_Args
|
||||||
{
|
{
|
||||||
Case "on":
|
Case "on":
|
||||||
Menu, Tray, NoIcon
|
Goto(Start)
|
||||||
Goto, Start
|
|
||||||
Case "off":
|
Case "off":
|
||||||
ExitApp
|
ExitApp()
|
||||||
|
default:
|
||||||
|
for x in A_Args {
|
||||||
|
MsgBox(x)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu, Tray, Add, Hide GUI, GuiToggle ; Adds a button to toggle the gui
|
myGui := Gui()
|
||||||
Menu, Tray, Add, Exit, GuiClose ; Exit button
|
A_TrayMenu.Delete() ; None of the standard tray buttons
|
||||||
Menu, Tray, NoStandard ; None of the standard tray buttons
|
A_TrayMenu.Add("Hide GUI", GuiToggle()) ; Adds a button to toggle the gui
|
||||||
Gui, +AlwaysOnTop +ToolWindow
|
A_TrayMenu.Add("Exit", ExtMen) ; Exit button
|
||||||
Gui, Add, Button, x3 y3 w55 h20 gStart +Center, Start
|
myGui.Opt("+AlwaysOnTop +ToolWindow")
|
||||||
Gui, Add, Button, x3 y3 w55 h20 gStop +Center, Stop
|
ogcButtonStart := myGui.Add("Button", "x3 y3 w55 h20 +Center", "Start")
|
||||||
Gui, Show, h28 w60, msmv
|
ogcButtonStart.OnEvent("Click", Start.Bind("Normal"))
|
||||||
GuiControl, Hide, Stop ; Since we want the Start button to show first
|
ogcButtonStop := myGui.Add("Button", "x3 y3 w55 h20 +Center Hidden", "Stop")
|
||||||
Return
|
ogcButtonStop.OnEvent("Click", Stop.Bind("Normal"))
|
||||||
|
myGui.Title := "msmv"
|
||||||
|
myGui.Show("h28 w60")
|
||||||
|
|
||||||
Start:
|
Start(A_GuiEvent, GuiCtrlObj, Info, *)
|
||||||
GuiControl, Hide, Start
|
{
|
||||||
SetTimer, Msmv, %waittime% ; Checks if the has been input in the last 2 minutes every 30 secs, easier to stop a loop with SetTimer
|
ogcButtonStart.Visible := false
|
||||||
GuiControl, Show, Stop
|
SetTimer(Msmv,waittime) ; Checks if the has been input in the last 2 minutes every 30 secs, easier to stop a loop with SetTimer
|
||||||
Return
|
ogcButtonStop.Visible := true
|
||||||
|
}
|
||||||
|
|
||||||
Stop:
|
Stop(A_GuiEvent, GuiCtrlObj, Info, *)
|
||||||
GuiControl, Hide, Stop
|
{
|
||||||
SetTimer, Msmv, off
|
ogcButtonStop.Visible := false
|
||||||
GuiControl, Show, Start
|
SetTimer(Msmv,0)
|
||||||
Return
|
ogcButtonStart.Visible := true
|
||||||
|
}
|
||||||
|
|
||||||
Msmv:
|
Msmv()
|
||||||
If (A_TimeIdle > waittime) ; https://www.autohotkey.com/docs/Variables.htm#User_Idle_Time
|
{
|
||||||
|
If (A_TimeIdle > waittime) ; https://www.autohotkey.com/docs/Variables.htm#User_Idle_Time
|
||||||
{
|
{
|
||||||
Random, x,, %A_ScreenWidth%
|
x := Random(, A_ScreenWidth)
|
||||||
Random, y,, %A_ScreenHeight%
|
y := Random(, A_ScreenHeight)
|
||||||
MouseMove %x%, %y%
|
MouseMove(x, y)
|
||||||
}
|
}
|
||||||
Return
|
}
|
||||||
|
|
||||||
GuiToggle:
|
GuiToggle(){
|
||||||
|
global
|
||||||
If !nogui
|
If !nogui
|
||||||
{
|
{
|
||||||
Gui, Hide
|
myGui.Hide()
|
||||||
Menu, Tray, Check, Hide GUI
|
A_TrayMenu.Check("1&")
|
||||||
nogui := True
|
nogui := True
|
||||||
}
|
}
|
||||||
Else
|
Else
|
||||||
{
|
{
|
||||||
Menu, Tray, uncheck, Hide GUI
|
A_TrayMenu.Uncheck("1&")
|
||||||
nogui := False
|
nogui := False
|
||||||
Gui, Show
|
myGui.Show()
|
||||||
}
|
}
|
||||||
Return
|
}
|
||||||
|
|
||||||
GuiClose:
|
; exit option from tray menu
|
||||||
GuiEscape:
|
ExtMen(A_ThisMenuItem, A_ThisMenuItemPos, MyMenu)
|
||||||
ExitApp ; Closes the app when escape or the exit button is pressed
|
{
|
||||||
|
ExitApp()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user