mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
update linux default func use
This commit is contained in:
parent
2a6299df59
commit
f0c84a23d3
@ -4,11 +4,12 @@ package robotgo
|
|||||||
|
|
||||||
// ActivePID active the window by PID,
|
// ActivePID active the window by PID,
|
||||||
// If args[0] > 0 on the Windows platform via a window handle to active
|
// If args[0] > 0 on the Windows platform via a window handle to active
|
||||||
func ActivePID(pid int32, args ...int) {
|
func ActivePID(pid int32, args ...int) error {
|
||||||
var hwnd int
|
var hwnd int
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
hwnd = args[0]
|
hwnd = args[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
internalActive(pid, hwnd)
|
internalActive(pid, hwnd)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package robotgo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/BurntSushi/xgb/xproto"
|
"github.com/BurntSushi/xgb/xproto"
|
||||||
"github.com/BurntSushi/xgbutil"
|
"github.com/BurntSushi/xgbutil"
|
||||||
@ -12,9 +13,9 @@ import (
|
|||||||
|
|
||||||
var xu *xgbutil.XUtil
|
var xu *xgbutil.XUtil
|
||||||
|
|
||||||
// ActivePID active the window by PID,
|
// ActivePIDC active the window by PID,
|
||||||
// If args[0] > 0 on the unix platform via a xid to active
|
// If args[0] > 0 on the unix platform via a xid to active
|
||||||
func ActivePID(pid int32, args ...int) {
|
func ActivePIDC(pid int32, args ...int) {
|
||||||
var hwnd int
|
var hwnd int
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
hwnd = args[0]
|
hwnd = args[0]
|
||||||
@ -23,16 +24,26 @@ func ActivePID(pid int32, args ...int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if xu == nil {
|
||||||
|
var err error
|
||||||
|
xu, err = xgbutil.NewConn()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("xgbutil.NewConn errors is: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xid, err := getXidFromPid(xu, pid)
|
xid, err := getXidFromPid(xu, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("getXidFromPid errors is: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
internalActive(int32(xid), hwnd)
|
internalActive(int32(xid), hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivePIDXgb makes the window of the PID the active window
|
// ActivePID makes the window of the PID the active window
|
||||||
func ActivePIDXgb(pid int32) error {
|
func ActivePID(pid int32) error {
|
||||||
if xu == nil {
|
if xu == nil {
|
||||||
var err error
|
var err error
|
||||||
xu, err = xgbutil.NewConn()
|
xu, err = xgbutil.NewConn()
|
||||||
|
Loading…
Reference in New Issue
Block a user