Skip to content

Commit

Permalink
example:wowjump add flash window option.
Browse files Browse the repository at this point in the history
  • Loading branch information
whtiehack committed Feb 20, 2020
1 parent c0c0aec commit 05cff87
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
30 changes: 20 additions & 10 deletions examples/wowjump/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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)
}
12 changes: 12 additions & 0 deletions examples/wowjump/logout.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"github.com/whtiehack/wingui/winapi"
"log"
"math/rand"
"strconv"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 3 additions & 1 deletion examples/wowjump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions examples/wowjump/resource.h.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified examples/wowjump/ui.syso
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/wowjump/ui/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
#define IDE_ENTER_TIME 40005
#define IDS_WINGUI 40006
#define IDB_CHANGECHAR 40007
#define IDB_LOGOUT_FLASH 40008


1 change: 1 addition & 0 deletions examples/wowjump/ui/ui.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down

0 comments on commit 05cff87

Please sign in to comment.