fix: find console window
This commit is contained in:
parent
e0fddf6b59
commit
d0b7427efd
1 changed files with 33 additions and 15 deletions
48
vvin.go
48
vvin.go
|
@ -48,30 +48,48 @@ func (c *globalCmd) Before() error {
|
|||
}
|
||||
|
||||
an := ancestors()
|
||||
t := strings.ToLower(c.Target)
|
||||
|
||||
for _, w := range wins {
|
||||
ancestor := false
|
||||
if c.Target == "" {
|
||||
loopConsole:
|
||||
for _, p := range an {
|
||||
if w.PID == p {
|
||||
ancestor = true
|
||||
break
|
||||
for _, w := range wins {
|
||||
if w.PID == p {
|
||||
if c.Debug {
|
||||
rog.Printf("win: %#v", w)
|
||||
}
|
||||
|
||||
c.targetHandle = w.Handle
|
||||
break loopConsole
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
t := strings.ToLower(c.Target)
|
||||
|
||||
if c.Debug {
|
||||
rog.Printf("win: %#v (ancestor? %v)", w, ancestor)
|
||||
}
|
||||
if t != "" && !ancestor {
|
||||
wt := strings.ToLower(w.Title)
|
||||
for _, w := range wins {
|
||||
ancestor := false
|
||||
for _, p := range an {
|
||||
if w.PID == p {
|
||||
ancestor = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if strings.Contains(wt, t) {
|
||||
if c.Debug {
|
||||
rog.Printf("win: %#v (ancestor? %v)", w, ancestor)
|
||||
}
|
||||
|
||||
if t != "" && !ancestor {
|
||||
wt := strings.ToLower(w.Title)
|
||||
|
||||
if strings.Contains(wt, t) {
|
||||
c.targetHandle = w.Handle
|
||||
break
|
||||
}
|
||||
} else if t == "" && ancestor {
|
||||
c.targetHandle = w.Handle
|
||||
break
|
||||
}
|
||||
} else if t == "" && ancestor {
|
||||
c.targetHandle = w.Handle
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue