2019-03-13 23:57:03 +00:00
package main
import (
2021-08-19 19:01:27 +00:00
"github.com/go-vgo/robotgo"
2019-03-28 19:52:25 +00:00
log "github.com/sirupsen/logrus"
2019-03-13 23:57:03 +00:00
"github.com/getlantern/systray"
2019-03-28 00:40:22 +00:00
"github.com/prashantgupta24/automatic-mouse-mover/assets/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 )
2021-08-19 19:01:27 +00:00
about := systray . AddMenuItem ( "About AMM" , "Information about the app" )
systray . AddSeparator ( )
2019-03-13 23:57:03 +00:00
ammStart := systray . AddMenuItem ( "Start" , "start the app" )
2019-03-20 19:44:51 +00:00
ammStop := systray . AddMenuItem ( "Stop" , "stop the app" )
2019-03-28 19:52:25 +00:00
ammStop . Disable ( )
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 ( )
2021-08-19 19:01:27 +00:00
mouseMover . Start ( )
ammStart . Disable ( )
ammStop . Enable ( )
2019-03-13 23:57:03 +00:00
for {
select {
case <- ammStart . ClickedCh :
2019-03-28 19:52:25 +00:00
log . Infof ( "starting the app" )
2019-03-20 19:44:51 +00:00
mouseMover . Start ( )
2019-03-28 19:52:25 +00:00
ammStart . Disable ( )
ammStop . Enable ( )
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-28 19:52:25 +00:00
log . Infof ( "stopping the app" )
ammStart . Enable ( )
ammStop . Disable ( )
2019-03-20 19:44:51 +00:00
mouseMover . Quit ( )
2019-03-13 23:57:03 +00:00
case <- mQuit . ClickedCh :
2019-03-28 19:52:25 +00:00
log . Infof ( "Requesting quit" )
2019-03-20 19:44:51 +00:00
mouseMover . Quit ( )
2019-03-13 23:57:03 +00:00
systray . Quit ( )
return
2021-08-19 19:01:27 +00:00
case <- about . ClickedCh :
log . Infof ( "Requesting about" )
2022-10-04 04:54:10 +00:00
robotgo . ShowAlert ( "Automatic-mouse-mover app v1.2.0" , "Developed by Prashant Gupta. \n\nMore info at: https://github.com/prashantgupta24/automatic-mouse-mover" )
2019-03-13 23:57:03 +00:00
}
}
} ( )
}
func onExit ( ) {
// clean up here
2019-03-28 19:52:25 +00:00
log . Infof ( "Finished quitting" )
2019-03-13 23:57:03 +00:00
}