2019-03-13 23:57:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/getlantern/systray"
|
|
|
|
"github.com/getlantern/systray/example/icon"
|
2019-03-20 19:44:51 +00:00
|
|
|
"github.com/prashantgupta24/automatic-mouse-mover/pkg/mousemover"
|
2019-03-13 23:57:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
systray.Run(onReady, onExit)
|
|
|
|
}
|
|
|
|
|
|
|
|
func onReady() {
|
|
|
|
go func() {
|
|
|
|
systray.SetIcon(icon.Data)
|
|
|
|
systray.SetTitle("AMM")
|
|
|
|
ammStart := systray.AddMenuItem("Start", "start the app")
|
2019-03-20 19:44:51 +00:00
|
|
|
ammStop := systray.AddMenuItem("Stop", "stop the app")
|
2019-03-13 23:57:03 +00:00
|
|
|
systray.AddSeparator()
|
|
|
|
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
|
|
|
|
// Sets the icon of a menu item. Only available on Mac.
|
|
|
|
//mQuit.SetIcon(icon.Data)
|
2019-03-20 19:44:51 +00:00
|
|
|
mouseMover := mousemover.GetInstance()
|
2019-03-13 23:57:03 +00:00
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-ammStart.ClickedCh:
|
|
|
|
fmt.Println("starting the app")
|
2019-03-20 19:44:51 +00:00
|
|
|
mouseMover.Start()
|
2019-03-13 23:57:03 +00:00
|
|
|
//notify.SendMessage("starting the app")
|
|
|
|
|
2019-03-20 19:44:51 +00:00
|
|
|
case <-ammStop.ClickedCh:
|
2019-03-22 22:56:20 +00:00
|
|
|
fmt.Println("stopping the app")
|
2019-03-20 19:44:51 +00:00
|
|
|
mouseMover.Quit()
|
2019-03-13 23:57:03 +00:00
|
|
|
|
|
|
|
case <-mQuit.ClickedCh:
|
|
|
|
fmt.Println("Requesting quit")
|
2019-03-20 19:44:51 +00:00
|
|
|
mouseMover.Quit()
|
2019-03-13 23:57:03 +00:00
|
|
|
systray.Quit()
|
|
|
|
fmt.Println("Finished quitting")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
func onExit() {
|
|
|
|
// clean up here
|
|
|
|
fmt.Println("exiting")
|
|
|
|
|
|
|
|
}
|