update error return and print

This commit is contained in:
vcaesar 2020-10-27 10:46:17 -04:00
parent b537cf4a3e
commit fb2d6f2720
2 changed files with 8 additions and 10 deletions

View File

@ -28,13 +28,12 @@ func GetBounds(pid int32, args ...int) (int, int, int, int) {
var hwnd int var hwnd int
if len(args) > 0 { if len(args) > 0 {
hwnd = args[0] hwnd = args[0]
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("GetXid from Pid errors is: ", err) log.Println("Get Xid from Pid errors is: ", err)
return 0, 0, 0, 0 return 0, 0, 0, 0
} }
@ -46,13 +45,12 @@ func internalGetTitle(pid int32, args ...int32) string {
var hwnd int32 var hwnd int32
if len(args) > 0 { if len(args) > 0 {
hwnd = args[0] hwnd = args[0]
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("GetXid from Pid errors is: ", err) log.Println("Get Xid from Pid errors is: ", err)
return "" return ""
} }
@ -61,22 +59,22 @@ func internalGetTitle(pid int32, args ...int32) string {
// 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) { 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]
internalActive(pid, hwnd) internalActive(pid, hwnd)
return return nil
} }
xid, err := GetXId(xu, pid) xid, err := GetXId(xu, pid)
if err != nil { if err != nil {
log.Println("GetXid from Pid errors is: ", err) log.Println("Get Xid from Pid errors is: ", err)
return return err
} }
internalActive(int32(xid), hwnd) internalActive(int32(xid), hwnd)
return nil
} }
// ActivePID active the window by PID, // ActivePID active the window by PID,

View File

@ -85,7 +85,7 @@ void set_handle_pid_mData(uintptr pid, uintptr isHwnd){
bool IsValid(){ bool IsValid(){
initWindow(initHandle); initWindow(initHandle);
if (!IsAxEnabled(true)) { if (!IsAxEnabled(true)) {
printf("%s\n", "Window:Accessibility API is disabled!\n" printf("%s\n", "Window: Accessibility API is disabled!\n"
"Failed to enable access for assistive devices."); "Failed to enable access for assistive devices.");
} }
MData actdata = GetActive(); MData actdata = GetActive();