mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-29 21:43:55 +00:00
Update: Unified pid and xid name, Update godoc, fixed typo
This commit is contained in:
parent
47ca6812fe
commit
e9b5a9251e
@ -53,7 +53,7 @@ Golang
|
|||||||
GCC
|
GCC
|
||||||
```
|
```
|
||||||
|
|
||||||
#### For Mac OS X:
|
#### For MacOS:
|
||||||
|
|
||||||
Xcode Command Line Tools (And Privacy setting: [#277](https://github.com/go-vgo/robotgo/issues/277) )
|
Xcode Command Line Tools (And Privacy setting: [#277](https://github.com/go-vgo/robotgo/issues/277) )
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND GetHwndByPId(DWORD dwProcessId) {
|
HWND GetHwndByPid(DWORD dwProcessId) {
|
||||||
WNDINFO info = {0};
|
WNDINFO info = {0};
|
||||||
info.hWnd = NULL;
|
info.hWnd = NULL;
|
||||||
info.dwPid = dwProcessId;
|
info.dwPid = dwProcessId;
|
||||||
EnumWindows(EnumWindowsProc, (LPARAM)&info);
|
EnumWindows(EnumWindowsProc, (LPARAM)&info);
|
||||||
// printf("%d\n", info.hWnd);
|
|
||||||
return info.hWnd;
|
return info.hWnd;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -28,7 +28,7 @@ func alert() {
|
|||||||
|
|
||||||
func get() {
|
func get() {
|
||||||
// get the current process id
|
// get the current process id
|
||||||
pid := robotgo.GetPID()
|
pid := robotgo.GetPid()
|
||||||
fmt.Println("pid----", pid)
|
fmt.Println("pid----", pid)
|
||||||
|
|
||||||
// get current Window Active
|
// get current Window Active
|
||||||
@ -64,7 +64,7 @@ func findIds() {
|
|||||||
|
|
||||||
fmt.Println("pids...", fpid)
|
fmt.Println("pids...", fpid)
|
||||||
if len(fpid) > 0 {
|
if len(fpid) > 0 {
|
||||||
err = robotgo.ActivePID(fpid[0])
|
err = robotgo.ActivePid(fpid[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ func findIds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func active() {
|
func active() {
|
||||||
robotgo.ActivePID(100)
|
robotgo.ActivePid(100)
|
||||||
// robotgo.Sleep(2)
|
// robotgo.Sleep(2)
|
||||||
robotgo.ActiveName("code")
|
robotgo.ActiveName("code")
|
||||||
robotgo.Sleep(1)
|
robotgo.Sleep(1)
|
||||||
|
@ -192,7 +192,7 @@ void clickMouse(MMMouseButton button){
|
|||||||
toggleMouse(false, button);
|
toggleMouse(false, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special function for sending double clicks, needed for Mac OS X. */
|
/* Special function for sending double clicks, needed for MacOS. */
|
||||||
void doubleClick(MMMouseButton button){
|
void doubleClick(MMMouseButton button){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
/* Double click for Mac. */
|
/* Double click for Mac. */
|
||||||
|
47
robotgo.go
47
robotgo.go
@ -9,20 +9,22 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Package robotgo Go native cross-platform system automation.
|
Package robotgo Go native cross-platform system automation.
|
||||||
|
|
||||||
Please make sure Golang, GCC is installed correctly before installing RobotGo;
|
Please make sure Golang, GCC is installed correctly before installing RobotGo;
|
||||||
|
|
||||||
See Requirements:
|
See Requirements:
|
||||||
|
|
||||||
https://github.com/go-vgo/robotgo#requirements
|
https://github.com/go-vgo/robotgo#requirements
|
||||||
|
|
||||||
Installation:
|
Installation:
|
||||||
|
|
||||||
With Go module support (Go 1.11+), just import:
|
With Go module support (Go 1.11+), just import:
|
||||||
|
|
||||||
import "github.com/go-vgo/robotgo"
|
import "github.com/go-vgo/robotgo"
|
||||||
|
|
||||||
Otherwise, to install the robotgo package, run the command:
|
Otherwise, to install the robotgo package, run the command:
|
||||||
|
|
||||||
go get -u github.com/go-vgo/robotgo
|
go get -u github.com/go-vgo/robotgo
|
||||||
*/
|
*/
|
||||||
package robotgo
|
package robotgo
|
||||||
@ -236,8 +238,8 @@ func getNumDisplays() int {
|
|||||||
return int(C.get_num_displays())
|
return int(C.get_num_displays())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHwndByPId get the hwnd by pid
|
// GetHWNDByPid get the hwnd by pid
|
||||||
func GetHwndByPId(pid int) int {
|
func GetHWNDByPid(pid int) int {
|
||||||
return int(C.get_hwnd_by_pid(C.uintptr(pid)))
|
return int(C.get_hwnd_by_pid(C.uintptr(pid)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,8 +515,9 @@ func MoveMouse(x, y int) {
|
|||||||
// Move move the mouse to (x, y)
|
// Move move the mouse to (x, y)
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
// robotgo.MouseSleep = 100 // 100 millisecond
|
//
|
||||||
// robotgo.Move(10, 10)
|
// robotgo.MouseSleep = 100 // 100 millisecond
|
||||||
|
// robotgo.Move(10, 10)
|
||||||
func Move(x, y int) {
|
func Move(x, y int) {
|
||||||
// if runtime.GOOS == "windows" {
|
// if runtime.GOOS == "windows" {
|
||||||
// f := ScaleF()
|
// f := ScaleF()
|
||||||
@ -560,6 +563,7 @@ func Drag(x, y int, args ...string) {
|
|||||||
// DragSmooth drag the mouse like smooth to (x, y)
|
// DragSmooth drag the mouse like smooth to (x, y)
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.DragSmooth(10, 10)
|
// robotgo.DragSmooth(10, 10)
|
||||||
func DragSmooth(x, y int, args ...interface{}) {
|
func DragSmooth(x, y int, args ...interface{}) {
|
||||||
Toggle("left")
|
Toggle("left")
|
||||||
@ -582,6 +586,7 @@ func MoveMouseSmooth(x, y int, args ...interface{}) bool {
|
|||||||
// robotgo.MoveSmooth(x, y int, low, high float64, mouseDelay int)
|
// robotgo.MoveSmooth(x, y int, low, high float64, mouseDelay int)
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.MoveSmooth(10, 10)
|
// robotgo.MoveSmooth(10, 10)
|
||||||
// robotgo.MoveSmooth(10, 10, 1.0, 2.0)
|
// robotgo.MoveSmooth(10, 10, 1.0, 2.0)
|
||||||
func MoveSmooth(x, y int, args ...interface{}) bool {
|
func MoveSmooth(x, y int, args ...interface{}) bool {
|
||||||
@ -648,7 +653,7 @@ func GetMousePos() (int, int) {
|
|||||||
|
|
||||||
// Deprecated: use the Click(),
|
// Deprecated: use the Click(),
|
||||||
//
|
//
|
||||||
// MouseClick click the mouse
|
// # MouseClick click the mouse
|
||||||
//
|
//
|
||||||
// robotgo.MouseClick(button string, double bool)
|
// robotgo.MouseClick(button string, double bool)
|
||||||
func MouseClick(args ...interface{}) {
|
func MouseClick(args ...interface{}) {
|
||||||
@ -660,7 +665,8 @@ func MouseClick(args ...interface{}) {
|
|||||||
// robotgo.Click(button string, double bool)
|
// robotgo.Click(button string, double bool)
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
// robotgo.Click() // default is left button
|
//
|
||||||
|
// robotgo.Click() // default is left button
|
||||||
// robotgo.Click("right")
|
// robotgo.Click("right")
|
||||||
// robotgo.Click("wheelLeft")
|
// robotgo.Click("wheelLeft")
|
||||||
func Click(args ...interface{}) {
|
func Click(args ...interface{}) {
|
||||||
@ -691,6 +697,7 @@ func Click(args ...interface{}) {
|
|||||||
// robotgo.MoveClick(x, y int, button string, double bool)
|
// robotgo.MoveClick(x, y int, button string, double bool)
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.MouseSleep = 100
|
// robotgo.MouseSleep = 100
|
||||||
// robotgo.MoveClick(10, 10)
|
// robotgo.MoveClick(10, 10)
|
||||||
func MoveClick(x, y int, args ...interface{}) {
|
func MoveClick(x, y int, args ...interface{}) {
|
||||||
@ -709,10 +716,12 @@ func MovesClick(x, y int, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Toggle toggle the mouse, support button:
|
// Toggle toggle the mouse, support button:
|
||||||
// "left", "center", "right",
|
//
|
||||||
// "wheelDown", "wheelUp", "wheelLeft", "wheelRight"
|
// "left", "center", "right",
|
||||||
|
// "wheelDown", "wheelUp", "wheelLeft", "wheelRight"
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.Toggle("left") // default is down
|
// robotgo.Toggle("left") // default is down
|
||||||
// robotgo.Toggle("left", "up")
|
// robotgo.Toggle("left", "up")
|
||||||
func Toggle(key ...string) error {
|
func Toggle(key ...string) error {
|
||||||
@ -749,6 +758,7 @@ func MouseUp(key ...string) error {
|
|||||||
// robotgo.Scroll(x, y, msDelay int)
|
// robotgo.Scroll(x, y, msDelay int)
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.Scroll(10, 10)
|
// robotgo.Scroll(10, 10)
|
||||||
func Scroll(x, y int, args ...int) {
|
func Scroll(x, y int, args ...int) {
|
||||||
var msDelay = 10
|
var msDelay = 10
|
||||||
@ -767,6 +777,7 @@ func Scroll(x, y int, args ...int) {
|
|||||||
// supported: "up", "down", "left", "right"
|
// supported: "up", "down", "left", "right"
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.ScrollMouse(10, "down")
|
// robotgo.ScrollMouse(10, "down")
|
||||||
// robotgo.ScrollMouse(10, "up")
|
// robotgo.ScrollMouse(10, "up")
|
||||||
func ScrollMouse(x int, direction ...string) {
|
func ScrollMouse(x int, direction ...string) {
|
||||||
@ -797,6 +808,7 @@ func ScrollMouse(x int, direction ...string) {
|
|||||||
// robotgo.ScrollSmooth(toy, num, sleep, tox)
|
// robotgo.ScrollSmooth(toy, num, sleep, tox)
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.ScrollSmooth(-10)
|
// robotgo.ScrollSmooth(-10)
|
||||||
// robotgo.ScrollSmooth(-10, 6, 200, -10)
|
// robotgo.ScrollSmooth(-10, 6, 200, -10)
|
||||||
func ScrollSmooth(to int, args ...int) {
|
func ScrollSmooth(to int, args ...int) {
|
||||||
@ -828,6 +840,7 @@ func ScrollSmooth(to int, args ...int) {
|
|||||||
// ScrollRelative scroll mouse with relative
|
// ScrollRelative scroll mouse with relative
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.ScrollRelative(10, 10)
|
// robotgo.ScrollRelative(10, 10)
|
||||||
func ScrollRelative(x, y int, args ...int) {
|
func ScrollRelative(x, y int, args ...int) {
|
||||||
mx, my := MoveArgs(x, y)
|
mx, my := MoveArgs(x, y)
|
||||||
@ -987,7 +1000,7 @@ func GetHandle() int {
|
|||||||
|
|
||||||
// Deprecated: use the GetHandle(),
|
// Deprecated: use the GetHandle(),
|
||||||
//
|
//
|
||||||
// GetBHandle get the window handle, Wno-deprecated
|
// # GetBHandle get the window handle, Wno-deprecated
|
||||||
//
|
//
|
||||||
// This function will be removed in version v1.0.0
|
// This function will be removed in version v1.0.0
|
||||||
func GetBHandle() int {
|
func GetBHandle() int {
|
||||||
@ -1008,6 +1021,7 @@ func cgetTitle(hwnd, isHwnd int32) string {
|
|||||||
// GetTitle get the window title return string
|
// GetTitle get the window title return string
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// fmt.Println(robotgo.GetTitle())
|
// fmt.Println(robotgo.GetTitle())
|
||||||
//
|
//
|
||||||
// ids, _ := robotgo.FindIds()
|
// ids, _ := robotgo.FindIds()
|
||||||
@ -1026,8 +1040,8 @@ func GetTitle(args ...int32) string {
|
|||||||
return internalGetTitle(args[0])
|
return internalGetTitle(args[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPID get the process id return int32
|
// GetPid get the process id return int32
|
||||||
func GetPID() int32 {
|
func GetPid() int32 {
|
||||||
pid := C.get_PID()
|
pid := C.get_PID()
|
||||||
return int32(pid)
|
return int32(pid)
|
||||||
}
|
}
|
||||||
@ -1054,9 +1068,9 @@ func internalActive(pid int32, hwnd int) {
|
|||||||
C.active_PID(C.uintptr(pid), C.uintptr(hwnd))
|
C.active_PID(C.uintptr(pid), C.uintptr(hwnd))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
// var hwnd int
|
// var hwnd int
|
||||||
// if len(args) > 0 {
|
// if len(args) > 0 {
|
||||||
// hwnd = args[0]
|
// hwnd = args[0]
|
||||||
@ -1068,11 +1082,12 @@ func internalActive(pid int32, hwnd int) {
|
|||||||
// ActiveName active the window by name
|
// ActiveName active the window by name
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
// robotgo.ActiveName("chrome")
|
//
|
||||||
|
// robotgo.ActiveName("chrome")
|
||||||
func ActiveName(name string) error {
|
func ActiveName(name string) error {
|
||||||
pids, err := FindIds(name)
|
pids, err := FindIds(name)
|
||||||
if err == nil && len(pids) > 0 {
|
if err == nil && len(pids) > 0 {
|
||||||
return ActivePID(pids[0])
|
return ActivePid(pids[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
@ -18,7 +18,7 @@ package robotgo
|
|||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
// GetMianId get the main display id
|
// GetMainId get the main display id
|
||||||
func GetMainId() int {
|
func GetMainId() int {
|
||||||
return int(C.CGMainDisplayID())
|
return int(C.CGMainDisplayID())
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,15 @@ func internalGetTitle(pid int32, args ...int32) string {
|
|||||||
return gtitle
|
return gtitle
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// ids, _ := robotgo.FindIds()
|
// ids, _ := robotgo.FindIds()
|
||||||
// robotgo.ActivePID(ids[0])
|
// robotgo.ActivePid(ids[0])
|
||||||
func ActivePID(pid int32, args ...int) error {
|
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]
|
||||||
@ -71,6 +72,7 @@ func DisplaysNum() int {
|
|||||||
// If cancel button is not given, only the default button is displayed
|
// If cancel button is not given, only the default button is displayed
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.Alert("hi", "window", "ok", "cancel")
|
// robotgo.Alert("hi", "window", "ok", "cancel")
|
||||||
func Alert(title, msg string, args ...string) bool {
|
func Alert(title, msg string, args ...string) bool {
|
||||||
return showAlert(title, msg, args...)
|
return showAlert(title, msg, args...)
|
||||||
|
@ -57,7 +57,7 @@ func GetMain() win.HWND {
|
|||||||
return win.GetActiveWindow()
|
return win.GetActiveWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMianId get the main display id
|
// GetMainId get the main display id
|
||||||
func GetMainId() int {
|
func GetMainId() int {
|
||||||
return int(GetMain())
|
return int(GetMain())
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func GetBounds(pid int32, args ...int) (int, int, int, int) {
|
|||||||
return internalGetBounds(pid, hwnd)
|
return internalGetBounds(pid, hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
xid, err := GetXId(xu, pid)
|
xid, err := GetXid(xu, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Get Xid from Pid errors is: ", err)
|
log.Println("Get Xid from Pid errors is: ", err)
|
||||||
return 0, 0, 0, 0
|
return 0, 0, 0, 0
|
||||||
@ -51,7 +51,7 @@ func GetClient(pid int32, args ...int) (int, int, int, int) {
|
|||||||
return internalGetClient(pid, hwnd)
|
return internalGetClient(pid, hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
xid, err := GetXId(xu, pid)
|
xid, err := GetXid(xu, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Get Xid from Pid errors is: ", err)
|
log.Println("Get Xid from Pid errors is: ", err)
|
||||||
return 0, 0, 0, 0
|
return 0, 0, 0, 0
|
||||||
@ -68,7 +68,7 @@ func internalGetTitle(pid int32, args ...int32) string {
|
|||||||
return cgetTitle(pid, hwnd)
|
return cgetTitle(pid, hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
xid, err := GetXId(xu, pid)
|
xid, err := GetXid(xu, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Get Xid from Pid errors is: ", err)
|
log.Println("Get Xid from Pid errors is: ", err)
|
||||||
return ""
|
return ""
|
||||||
@ -77,9 +77,9 @@ func internalGetTitle(pid int32, args ...int32) string {
|
|||||||
return cgetTitle(int32(xid), hwnd)
|
return cgetTitle(int32(xid), hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivePIDC 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 ActivePIDC(pid int32, args ...int) error {
|
func ActivePidC(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]
|
||||||
@ -87,7 +87,7 @@ func ActivePIDC(pid int32, args ...int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
xid, err := GetXId(xu, pid)
|
xid, err := GetXid(xu, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Get Xid from Pid errors is: ", err)
|
log.Println("Get Xid from Pid errors is: ", err)
|
||||||
return err
|
return err
|
||||||
@ -97,11 +97,11 @@ func ActivePIDC(pid int32, args ...int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,
|
||||||
// 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) error {
|
func ActivePid(pid int32, args ...int) error {
|
||||||
if xu == nil {
|
if xu == nil {
|
||||||
var err error
|
var err error
|
||||||
xu, err = xgbutil.NewConn()
|
xu, err = xgbutil.NewConn()
|
||||||
@ -133,8 +133,8 @@ func ActivePID(pid int32, args ...int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetXId get the xid return window and error
|
// GetXid get the xid return window and error
|
||||||
func GetXId(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) {
|
func GetXid(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) {
|
||||||
if xu == nil {
|
if xu == nil {
|
||||||
var err error
|
var err error
|
||||||
xu, err = xgbutil.NewConn()
|
xu, err = xgbutil.NewConn()
|
||||||
@ -148,7 +148,7 @@ func GetXId(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) {
|
|||||||
return xid, err
|
return xid, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetXidFromPid get the xide from pid
|
// GetXidFromPid get the xid from pid
|
||||||
func GetXidFromPid(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) {
|
func GetXidFromPid(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) {
|
||||||
windows, err := ewmh.ClientListGet(xu)
|
windows, err := ewmh.ClientListGet(xu)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -214,6 +214,7 @@ func GetMainId() int {
|
|||||||
// If cancel button is not given, only the default button is displayed
|
// If cancel button is not given, only the default button is displayed
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
|
//
|
||||||
// robotgo.Alert("hi", "window", "ok", "cancel")
|
// robotgo.Alert("hi", "window", "ok", "cancel")
|
||||||
func Alert(title, msg string, args ...string) bool {
|
func Alert(title, msg string, args ...string) bool {
|
||||||
defaultBtn, cancelBtn := alertArgs(args...)
|
defaultBtn, cancelBtn := alertArgs(args...)
|
||||||
|
@ -99,7 +99,7 @@ uint32_t get_num_displays() {
|
|||||||
|
|
||||||
uintptr get_hwnd_by_pid(uintptr pid) {
|
uintptr get_hwnd_by_pid(uintptr pid) {
|
||||||
#if defined(IS_WINDOWS)
|
#if defined(IS_WINDOWS)
|
||||||
HWND hwnd = GetHwndByPId(pid);
|
HWND hwnd = GetHwndByPid(pid);
|
||||||
return (uintptr)hwnd;
|
return (uintptr)hwnd;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -24,7 +24,7 @@ void min_window(uintptr pid, bool state, uintptr isHwnd){
|
|||||||
// SetState((Window)pid, STATE_MINIMIZE, state);
|
// SetState((Window)pid, STATE_MINIMIZE, state);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
if (isHwnd == 0) {
|
if (isHwnd == 0) {
|
||||||
HWND hwnd = GetHwndByPId(pid);
|
HWND hwnd = GetHwndByPid(pid);
|
||||||
win_min(hwnd, state);
|
win_min(hwnd, state);
|
||||||
} else {
|
} else {
|
||||||
win_min((HWND)pid, state);
|
win_min((HWND)pid, state);
|
||||||
@ -41,7 +41,7 @@ void max_window(uintptr pid, bool state, uintptr isHwnd){
|
|||||||
// SetState((Window)pid, STATE_MAXIMIZE, state);
|
// SetState((Window)pid, STATE_MAXIMIZE, state);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
if (isHwnd == 0) {
|
if (isHwnd == 0) {
|
||||||
HWND hwnd = GetHwndByPId(pid);
|
HWND hwnd = GetHwndByPid(pid);
|
||||||
win_max(hwnd, state);
|
win_max(hwnd, state);
|
||||||
} else {
|
} else {
|
||||||
win_max((HWND)pid, state);
|
win_max((HWND)pid, state);
|
||||||
|
@ -130,7 +130,7 @@ Bounds get_bounds(uintptr pid, uintptr isHwnd){
|
|||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
if (isHwnd == 0) {
|
if (isHwnd == 0) {
|
||||||
hwnd= GetHwndByPId(pid);
|
hwnd= GetHwndByPid(pid);
|
||||||
} else {
|
} else {
|
||||||
hwnd = (HWND)pid;
|
hwnd = (HWND)pid;
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ Bounds get_client(uintptr pid, uintptr isHwnd) {
|
|||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
if (isHwnd == 0) {
|
if (isHwnd == 0) {
|
||||||
hwnd = GetHwndByPId(pid);
|
hwnd = GetHwndByPid(pid);
|
||||||
} else {
|
} else {
|
||||||
hwnd = (HWND)pid;
|
hwnd = (HWND)pid;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ MData set_handle_pid(uintptr pid, uintptr isHwnd){
|
|||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
// win.HWnd = (HWND)pid; // Handle to a window HWND
|
// win.HWnd = (HWND)pid; // Handle to a window HWND
|
||||||
if (isHwnd == 0) {
|
if (isHwnd == 0) {
|
||||||
win.HWnd = GetHwndByPId(pid);
|
win.HWnd = GetHwndByPid(pid);
|
||||||
} else {
|
} else {
|
||||||
win.HWnd = (HWND)pid;
|
win.HWnd = (HWND)pid;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user