Upgrade to AHK v2 #3

Open
david wants to merge 35 commits from tier2 into master
Showing only changes of commit a54571f6cd - Show all commits
+50 -35
View File
@@ -1,50 +1,65 @@
#Requires AutoHotkey v2.0 ; v2 only #Requires AutoHotkey v2 ; v2 only
#SingleInstance force #SingleInstance force
CoordMode("Mouse", "Screen") CoordMode("Mouse", "Screen")
waittime := 5000 waittime := 10000
ogcStop := 13
global nogui := False
Switch A_Args for i in A_Args
{ {
Case "on": if (i = "on")
Goto(Start) {
Case "off": A_IconHidden := 1
ExitApp() Start(1,2,3)
default: }
for x in A_Args { else if (i = "off")
MsgBox(x) {
ExitApp()
}
else
{
MsgBox (i)
} }
} }
myGui := Gui()
A_TrayMenu.Delete() ; None of the standard tray buttons 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("Hide GUI", GuiToggle) ; Adds a button to toggle the gui
A_TrayMenu.Add("Exit", ExtMen) ; Exit button A_TrayMenu.Add("Exit", ExtMen) ; Exit button
myGui := Gui()
myGui.Opt("+AlwaysOnTop +ToolWindow") myGui.Opt("+AlwaysOnTop +ToolWindow")
ogcButtonStart := myGui.Add("Button", "x3 y3 w55 h20 +Center", "Start") ButtonStart := myGui.Add("Button", "x3 y3 w55 h20 +Center", "Start")
ogcButtonStart.OnEvent("Click", Start.Bind("Normal")) ButtonStart.OnEvent("Click", Start.Bind("Normal"))
ogcButtonStop := myGui.Add("Button", "x3 y3 w55 h20 +Center Hidden", "Stop") ButtonStop := myGui.Add("Button", "x3 y3 w55 h20 +Center Hidden", "Stop")
ogcButtonStop.OnEvent("Click", Stop.Bind("Normal")) ButtonStop.OnEvent("Click", Stop.Bind("Normal"))
myGui.Title := "msmv" myGui.Title := "msmv"
myGui.Show("h28 w60") If (A_IconHidden = false)
{
myGui.Show("h28 w60")
}
Start(A_GuiEvent, GuiCtrlObj, Info, *)
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 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 If (A_IconHidden = false)
{
ButtonStart.Visible := false
ButtonStop.Visible := true
}
} }
Stop(A_GuiEvent, GuiCtrlObj, Info, *) Stop(A_GuiEvent, GuiCtrlObj, Info)
{ {
ogcButtonStop.Visible := false
SetTimer(Msmv,0) SetTimer(Msmv,0)
ogcButtonStart.Visible := true If (A_IconHidden = false)
{
ButtonStop.Visible := false
ButtonStart.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
{ {
@@ -54,24 +69,24 @@ Msmv()
} }
} }
GuiToggle(){ GuiToggle(ItemName, ItemPos, MenuObj)
{
global global
If !nogui If (WinExist("msmv"))
{ {
myGui.Hide() myGui.Destroy()
A_TrayMenu.Check("1&") MenuObj.Check(ItemName)
nogui := True
} }
Else Else
{ {
A_TrayMenu.Uncheck("1&") MenuObj.Uncheck(ItemName)
nogui := False myGui.Restore()
myGui.Show()
} }
Return
} }
; exit option from tray menu ; exit option from tray menu
ExtMen(A_ThisMenuItem, A_ThisMenuItemPos, MyMenu) ExtMen(*)
{ {
ExitApp() ExitApp()
} }