From 05cff87e9cff5c13d3bada32c97f9b0febdb77e9 Mon Sep 17 00:00:00 2001 From: whitehack Date: Thu, 20 Feb 2020 23:41:19 +0800 Subject: [PATCH] example:wowjump add flash window option. --- examples/wowjump/config.go | 30 ++++++++++++++++++++---------- examples/wowjump/logout.go | 12 ++++++++++++ examples/wowjump/main.go | 4 +++- examples/wowjump/resource.h.go | 2 ++ examples/wowjump/ui.syso | Bin 11828 -> 11868 bytes examples/wowjump/ui/resource.h | 3 +++ examples/wowjump/ui/ui.rc | 1 + 7 files changed, 41 insertions(+), 11 deletions(-) diff --git a/examples/wowjump/config.go b/examples/wowjump/config.go index cd1ca5b..9447718 100644 --- a/examples/wowjump/config.go +++ b/examples/wowjump/config.go @@ -13,16 +13,19 @@ import ( // Config is program config. type Config struct { - NormalTime int - InputTime int - CharWaitTime int - EnterTime int - ChangeChar bool - editEnterTime *wingui.Edit `json:"-"` - editNormaltime *wingui.Edit `json:"-"` - editInputTime *wingui.Edit `json:"-"` - editCharWaitTime *wingui.Edit `json:"-"` - btnCheckChangeChar *wingui.Button `json:"-"` + NormalTime int + InputTime int + CharWaitTime int + EnterTime int + ChangeChar bool + LogoutFlash bool + editEnterTime *wingui.Edit `json:"-"` + editNormaltime *wingui.Edit `json:"-"` + editInputTime *wingui.Edit `json:"-"` + editCharWaitTime *wingui.Edit `json:"-"` + btnCheckChangeChar *wingui.Button `json:"-"` + btnCheckLogoutFlash *wingui.Button `json:"-"` + flashHwnd win.HWND `json:"-"` } var config = &Config{ @@ -56,6 +59,7 @@ func (c *Config) Save() { config.InputTime, _ = strconv.Atoi(c.editInputTime.Text()) config.CharWaitTime, _ = strconv.Atoi(c.editCharWaitTime.Text()) config.ChangeChar = c.btnCheckChangeChar.GetCheck() == win.BST_CHECKED + config.LogoutFlash = c.btnCheckLogoutFlash.GetCheck() == win.BST_CHECKED file, _ := json.MarshalIndent(c, "", " ") configDir := os.Getenv("AppData") os.Mkdir(configDir+"/wowjump", 0777) @@ -73,6 +77,11 @@ func (c *Config) InitVal() { state = win.BST_CHECKED } c.btnCheckChangeChar.SetCheck(state) + state = win.BST_UNCHECKED + if config.LogoutFlash { + state = win.BST_CHECKED + } + c.btnCheckLogoutFlash.SetCheck(state) } //EditEnable enable edits. @@ -82,4 +91,5 @@ func (c *Config) EditEnable(enable bool) { c.editInputTime.SetEnabled(enable) c.editCharWaitTime.SetEnabled(enable) c.btnCheckChangeChar.SetEnabled(enable) + c.btnCheckLogoutFlash.SetEnabled(enable) } diff --git a/examples/wowjump/logout.go b/examples/wowjump/logout.go index 83023e8..59d63b7 100644 --- a/examples/wowjump/logout.go +++ b/examples/wowjump/logout.go @@ -1,6 +1,7 @@ package main import ( + "github.com/whtiehack/wingui/winapi" "log" "math/rand" "strconv" @@ -59,8 +60,19 @@ func (l *Logout) normal() { } } +func (l *Logout) checkFlashWindow() { + if !config.LogoutFlash { + return + } + log.Println("准备小退。。闪烁窗口..") + for i := 0; i < 10; i++ { + winapi.FlashWindow(config.flashHwnd, i%1+1) + sleep(500) + } +} func (l *Logout) input() { if l.subTime == 0 { + l.checkFlashWindow() if !l.TryGetWindow() { randomSleep(1111, 1111) } diff --git a/examples/wowjump/main.go b/examples/wowjump/main.go index 06f387d..1d6424c 100644 --- a/examples/wowjump/main.go +++ b/examples/wowjump/main.go @@ -60,8 +60,10 @@ func main() { config.editInputTime = wingui.NewEdit(IDE_INPUT_TIME) config.editCharWaitTime = wingui.NewEdit(IDE_CHAR_WAIT_TIME) config.btnCheckChangeChar = wingui.NewButton(IDB_CHANGECHAR) + config.btnCheckLogoutFlash = wingui.NewButton(IDB_LOGOUT_FLASH) _ = dlg.BindWidgets(editLog, btn, config.editNormaltime, config.editEnterTime, - config.editInputTime, config.editCharWaitTime, config.btnCheckChangeChar) + config.editInputTime, config.editCharWaitTime, config.btnCheckChangeChar, config.btnCheckLogoutFlash) + config.flashHwnd = dlg.Handle() config.InitVal() go stat.Stat("/main", "wowjump-main") dlg.Show() diff --git a/examples/wowjump/resource.h.go b/examples/wowjump/resource.h.go index 492b33e..09ac9d7 100644 --- a/examples/wowjump/resource.h.go +++ b/examples/wowjump/resource.h.go @@ -23,4 +23,6 @@ const ( IDS_WINGUI = 40006 // IDB_CHANGECHAR const uintptr IDB_CHANGECHAR = 40007 + // IDB_LOGOUT_FLASH const uintptr + IDB_LOGOUT_FLASH = 40008 ) diff --git a/examples/wowjump/ui.syso b/examples/wowjump/ui.syso index f858c2d681692320b2ddf6e3bc98e9291b11d48e..66832e5ba9ed4ec751be85e4a219b95b7e45de37 100644 GIT binary patch delta 132 zcmdlIb0>x~rHzpR1l%TaN^{-NWni!Yazykt>UlBhZeRvWfr$%RKw$)z;RTQ%gT(jP zyp(ajDx=`$RP}mh6`;ldkYpOeJq8a34hD}o|Nl2I@W(Jr@C}+?^*H#|)Pn_^A83Uz F0{{$p9JK%d delta 95 zcmcZ;vn7TzrHzpR1mq@iN^@<{Wni!Ya^C1})bnE0ZDR&Yfr%Ab3=AR&F2eyJKL&}f Wuz4xtepN<+&8h13%$s?%1DF9Bs1L*d diff --git a/examples/wowjump/ui/resource.h b/examples/wowjump/ui/resource.h index f028d90..1275eff 100644 --- a/examples/wowjump/ui/resource.h +++ b/examples/wowjump/ui/resource.h @@ -12,3 +12,6 @@ #define IDE_ENTER_TIME 40005 #define IDS_WINGUI 40006 #define IDB_CHANGECHAR 40007 +#define IDB_LOGOUT_FLASH 40008 + + diff --git a/examples/wowjump/ui/ui.rc b/examples/wowjump/ui/ui.rc index 353354b..73404e2 100644 --- a/examples/wowjump/ui/ui.rc +++ b/examples/wowjump/ui/ui.rc @@ -36,6 +36,7 @@ FONT 8, "Ms Shell Dlg" EDITTEXT IDE_INPUT_TIME, 217, 187, 40, 12, ES_AUTOHSCROLL | ES_NUMBER, WS_EX_RIGHT EDITTEXT IDE_CHAR_WAIT_TIME, 77, 203, 40, 12, ES_AUTOHSCROLL | ES_NUMBER, WS_EX_RIGHT EDITTEXT IDE_ENTER_TIME, 217, 203, 40, 12, ES_AUTOHSCROLL | ES_NUMBER, WS_EX_RIGHT + AUTOCHECKBOX "Сǰ˸", IDB_LOGOUT_FLASH, 102, 222, 72, 8, 0, WS_EX_LEFT }