diff --git a/examples/wowjump/config.go b/examples/wowjump/config.go index 6bf5757..a39b255 100644 --- a/examples/wowjump/config.go +++ b/examples/wowjump/config.go @@ -6,6 +6,7 @@ import ( "github.com/whtiehack/wingui" "io/ioutil" "log" + "os" "strconv" "syscall" ) @@ -29,7 +30,8 @@ var config = &Config{ } func init() { - file, err := ioutil.ReadFile("wowjump_config.txt") + configDir, _ := os.UserConfigDir() + file, err := ioutil.ReadFile(configDir + "/wowjump/wowjump_config.txt") if err != nil { return } @@ -48,7 +50,8 @@ func (c *Config) Save() { config.InputTime, _ = strconv.Atoi(c.editInputTime.Text()) config.CharWaitTime, _ = strconv.Atoi(c.editCharWaitTime.Text()) file, _ := json.MarshalIndent(c, "", " ") - ioutil.WriteFile("wowjump_config.txt", file, 777) + configDir, _ := os.UserConfigDir() + ioutil.WriteFile(configDir+"/wowjump/wowjump_config.txt", file, 777) } func (c *Config) InitVal() { diff --git a/examples/wowjump/control.go b/examples/wowjump/control.go new file mode 100644 index 0000000..18ba40a --- /dev/null +++ b/examples/wowjump/control.go @@ -0,0 +1,33 @@ +package main + +import "log" + +func process() { + defer func() { + err := recover() + log.Println("process end??", err) + if err != nil { + go process() + } + }() + var selfLogout = make([]*Logout, 0, 10) + for { + mux.Lock() + if !running || logouts == nil || len(logouts) == 0 { + mux.Unlock() + sleep(1000) + continue + } + selfLogout = make([]*Logout, len(logouts)) + copy(selfLogout, logouts) + mux.Unlock() + for _, logout := range selfLogout { + // 处理逻辑 + if !logout.IsValid() { + continue + } + logout.Update() + } + randomSleep(5000, 2500) + } +} diff --git a/examples/wowjump/main.go b/examples/wowjump/main.go index bfd1f6d..f568399 100644 --- a/examples/wowjump/main.go +++ b/examples/wowjump/main.go @@ -31,6 +31,8 @@ func init() { win.MessageBox(0, &syscall.StringToUTF16("进程已经开启了,不可以多开")[0], nil, 0) os.Exit(-1) } + // control + go process() } var btn *wingui.Button @@ -102,7 +104,7 @@ func btnClick() { } out.SetText("") log.Printf("找到 %d 个 WOW窗口\n", len(logouts)) - text = "关闭" + text = "停止" //str := skillKey.Text() //config.SkillKey = str //randomSkill.ParseSkillKey(str)