Merge pull request #27 from prashantgupta24/enhancements1

Enhancements1
This commit is contained in:
Prashant Gupta 2021-08-19 13:53:24 -07:00 committed by GitHub
commit 3a9acd3666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"github.com/go-vgo/robotgo"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/getlantern/systray" "github.com/getlantern/systray"
@ -15,6 +16,8 @@ func main() {
func onReady() { func onReady() {
go func() { go func() {
systray.SetIcon(icon.Data) systray.SetIcon(icon.Data)
about := systray.AddMenuItem("About AMM", "Information about the app")
systray.AddSeparator()
ammStart := systray.AddMenuItem("Start", "start the app") ammStart := systray.AddMenuItem("Start", "start the app")
ammStop := systray.AddMenuItem("Stop", "stop the app") ammStop := systray.AddMenuItem("Stop", "stop the app")
ammStop.Disable() ammStop.Disable()
@ -23,6 +26,9 @@ func onReady() {
// Sets the icon of a menu item. Only available on Mac. // Sets the icon of a menu item. Only available on Mac.
//mQuit.SetIcon(icon.Data) //mQuit.SetIcon(icon.Data)
mouseMover := mousemover.GetInstance() mouseMover := mousemover.GetInstance()
mouseMover.Start()
ammStart.Disable()
ammStop.Enable()
for { for {
select { select {
case <-ammStart.ClickedCh: case <-ammStart.ClickedCh:
@ -43,6 +49,10 @@ func onReady() {
mouseMover.Quit() mouseMover.Quit()
systray.Quit() systray.Quit()
return return
case <-about.ClickedCh:
log.Infof("Requesting about")
robotgo.ShowAlert("Automatic-mouse-mover app", "Developed by Prashant Gupta. \n\nMore info at: https://github.com/prashantgupta24/automatic-mouse-mover")
} }
} }

View File

@ -71,7 +71,7 @@ func (m *MouseMover) run(heartbeatCh chan *tracker.Heartbeat, activityTracker *t
msg := fmt.Sprintf("Mouse pointer cannot be moved at %v. Last moved at %v. Happened %v times. See README for details.", msg := fmt.Sprintf("Mouse pointer cannot be moved at %v. Last moved at %v. Happened %v times. See README for details.",
time.Now(), state.getLastMouseMovedTime(), state.getDidNotMoveCount()) time.Now(), state.getLastMouseMovedTime(), state.getDidNotMoveCount())
logger.Errorf(msg) logger.Errorf(msg)
if state.getDidNotMoveCount() >= 3 { if state.getDidNotMoveCount() >= 10 {
go func() { go func() {
robotgo.ShowAlert("Error with Automatic Mouse Mover", msg) robotgo.ShowAlert("Error with Automatic Mouse Mover", msg)
}() }()