Add systray
This commit is contained in:
13
main.go
13
main.go
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
// _ "embed"
|
||||
"fyne.io/systray"
|
||||
hook "github.com/robotn/gohook"
|
||||
)
|
||||
@@ -17,6 +18,8 @@ var (
|
||||
GetForegroundWindow = us32.MustFindProc("GetForegroundWindow")
|
||||
)
|
||||
|
||||
// //go:embed duck2.jpg
|
||||
//var icon []byte
|
||||
var Error *log.Logger
|
||||
var Warning *log.Logger
|
||||
|
||||
@@ -44,7 +47,7 @@ const (
|
||||
)
|
||||
|
||||
func main() {
|
||||
systray.Run(onReady, onExit)
|
||||
systray.Run(onReady, nil)
|
||||
keyEvents := make(chan *hook.Event, 4096)
|
||||
hook.Register(hook.KeyDown, []string{}, func(e hook.Event) {
|
||||
keyEvents <- &e
|
||||
@@ -92,11 +95,13 @@ func main() {
|
||||
}
|
||||
|
||||
func onReady() {
|
||||
systray.SetIcon(icon.Data)
|
||||
// Icons no workey... idk why...
|
||||
// systray error: unable to set icon: The operation completed successfully.
|
||||
//systray.SetIcon(icon)
|
||||
systray.SetTitle("Awesome App")
|
||||
systray.SetTooltip("Pretty awesome超级棒")
|
||||
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
|
||||
//mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
|
||||
|
||||
// Sets the icon of a menu item. Only available on Mac and Windows.
|
||||
mQuit.SetIcon(icon.Data)
|
||||
//mQuit.SetIcon(icon)
|
||||
}
|
||||
|
Reference in New Issue
Block a user