mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-17 13:33:55 +00:00
Compare commits
9 Commits
ed6fabf715
...
4273e546ba
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4273e546ba | ||
![]() |
217d6cf1f1 | ||
![]() |
75fd24ea0a | ||
![]() |
bed6776ca2 | ||
![]() |
1923d7bb48 | ||
![]() |
ead43d062e | ||
![]() |
3258566802 | ||
![]() |
932a918e44 | ||
![]() |
3f4b0f9872 |
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module github.com/go-vgo/robotgo
|
module github.com/aohanhongzhi/robotgo
|
||||||
|
|
||||||
go 1.22
|
go 1.22
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ package robotgo
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
@ -366,11 +367,14 @@ func CaptureGo(args ...int) Bitmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CaptureImg capture the screen and return image.Image
|
// CaptureImg capture the screen and return image.Image
|
||||||
func CaptureImg(args ...int) image.Image {
|
func CaptureImg(args ...int) (image.Image, error) {
|
||||||
bit := CaptureScreen(args...)
|
bit := CaptureScreen(args...)
|
||||||
|
if bit == nil {
|
||||||
|
return nil, errors.New("capture error")
|
||||||
|
}
|
||||||
defer FreeBitmap(bit)
|
defer FreeBitmap(bit)
|
||||||
|
|
||||||
return ToImage(bit)
|
return ToImage(bit), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FreeBitmap free and dealloc the C bitmap
|
// FreeBitmap free and dealloc the C bitmap
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
package robotgo
|
package robotgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
"github.com/kbinani/screenshot"
|
"github.com/kbinani/screenshot"
|
||||||
@ -53,9 +54,9 @@ func Capture(args ...int) (*image.RGBA, error) {
|
|||||||
|
|
||||||
// SaveCapture capture screen and save the screenshot to image
|
// SaveCapture capture screen and save the screenshot to image
|
||||||
func SaveCapture(path string, args ...int) error {
|
func SaveCapture(path string, args ...int) error {
|
||||||
img, err := Capture(args...)
|
img := CaptureImg(args...)
|
||||||
if err != nil {
|
if img == nil {
|
||||||
return err
|
return errors.New("Capture image not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
return Save(img, path)
|
return Save(img, path)
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "../base/pubs.h"
|
#include "../base/pubs.h"
|
||||||
#include "../base/rgb.h"
|
#include "../base/rgb.h"
|
||||||
#include "screengrab_c.h"
|
#include "screengrab_c.h"
|
||||||
#include "screen_c.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void padHex(MMRGBHex color, char* hex) {
|
void padHex(MMRGBHex color, char* hex) {
|
||||||
|
@ -4,9 +4,70 @@
|
|||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xresource.h>
|
||||||
// #include "../base/xdisplay_c.h"
|
// #include "../base/xdisplay_c.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
intptr scaleX();
|
||||||
|
|
||||||
|
double sys_scale(int32_t display_id) {
|
||||||
|
#if defined(IS_MACOSX)
|
||||||
|
CGDirectDisplayID displayID = (CGDirectDisplayID) display_id;
|
||||||
|
if (displayID == -1) {
|
||||||
|
displayID = CGMainDisplayID();
|
||||||
|
}
|
||||||
|
|
||||||
|
CGDisplayModeRef modeRef = CGDisplayCopyDisplayMode(displayID);
|
||||||
|
double pixelWidth = CGDisplayModeGetPixelWidth(modeRef);
|
||||||
|
double targetWidth = CGDisplayModeGetWidth(modeRef);
|
||||||
|
|
||||||
|
return pixelWidth / targetWidth;
|
||||||
|
#elif defined(USE_X11)
|
||||||
|
Display *dpy = XOpenDisplay(NULL);
|
||||||
|
|
||||||
|
int scr = 0; /* Screen number */
|
||||||
|
double xres = ((((double) DisplayWidth(dpy, scr)) * 25.4) /
|
||||||
|
((double) DisplayWidthMM(dpy, scr)));
|
||||||
|
|
||||||
|
char *rms = XResourceManagerString(dpy);
|
||||||
|
if (rms) {
|
||||||
|
XrmDatabase db = XrmGetStringDatabase(rms);
|
||||||
|
if (db) {
|
||||||
|
XrmValue value;
|
||||||
|
char *type = NULL;
|
||||||
|
|
||||||
|
if (XrmGetResource(db, "Xft.dpi", "String", &type, &value)) {
|
||||||
|
if (value.addr) {
|
||||||
|
xres = atof(value.addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XrmDestroyDatabase(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XCloseDisplay (dpy);
|
||||||
|
|
||||||
|
return xres / 96.0;
|
||||||
|
#elif defined(IS_WINDOWS)
|
||||||
|
double s = scaleX() / 96.0;
|
||||||
|
return s;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
intptr scaleX(){
|
||||||
|
#if defined(IS_MACOSX)
|
||||||
|
return 0;
|
||||||
|
#elif defined(USE_X11)
|
||||||
|
return 0;
|
||||||
|
#elif defined(IS_WINDOWS)
|
||||||
|
// Get desktop dc
|
||||||
|
HDC desktopDc = GetDC(NULL);
|
||||||
|
// Get native resolution
|
||||||
|
intptr horizontalDPI = GetDeviceCaps(desktopDc, LOGPIXELSX);
|
||||||
|
return horizontalDPI;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
MMSizeInt32 getMainDisplaySize(void) {
|
MMSizeInt32 getMainDisplaySize(void) {
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
CGDirectDisplayID displayID = CGMainDisplayID();
|
CGDirectDisplayID displayID = CGMainDisplayID();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "screen_c.h"
|
||||||
|
|
||||||
#if defined(IS_MACOSX) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4
|
#if defined(IS_MACOSX) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4
|
||||||
static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) {
|
static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) {
|
||||||
@ -39,9 +40,12 @@
|
|||||||
|
|
||||||
SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:target excludingWindows:@[]];
|
SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:target excludingWindows:@[]];
|
||||||
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
|
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
|
||||||
|
config.queueDepth = 5;
|
||||||
config.sourceRect = diIntersectDisplayLocal;
|
config.sourceRect = diIntersectDisplayLocal;
|
||||||
config.width = diIntersectDisplayLocal.size.width;
|
config.width = diIntersectDisplayLocal.size.width * sys_scale(id);
|
||||||
config.height = diIntersectDisplayLocal.size.height;
|
config.height = diIntersectDisplayLocal.size.height * sys_scale(id);
|
||||||
|
config.scalesToFit = false;
|
||||||
|
config.captureResolution = 1;
|
||||||
|
|
||||||
[SCScreenshotManager captureImageWithFilter:filter
|
[SCScreenshotManager captureImageWithFilter:filter
|
||||||
configuration:config
|
configuration:config
|
||||||
|
@ -55,11 +55,11 @@ uintptr get_handle(){
|
|||||||
|
|
||||||
uintptr b_get_handle() {
|
uintptr b_get_handle() {
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
return (uintptr)mData.CgID;
|
return (uintptr)pub_mData.CgID;
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
return (uintptr)mData.XWin;
|
return (uintptr)pub_mData.XWin;
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
return (uintptr)mData.HWnd;
|
return (uintptr)pub_mData.HWnd;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ struct _MData{
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _MData MData;
|
typedef struct _MData MData;
|
||||||
MData mData;
|
MData pub_mData;
|
||||||
|
|
||||||
struct _Bounds {
|
struct _Bounds {
|
||||||
int32_t X; // Top left X coordinate
|
int32_t X; // Top left X coordinate
|
||||||
|
@ -8,70 +8,11 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#if defined(USE_X11)
|
// #if defined(USE_X11)
|
||||||
#include <X11/Xresource.h>
|
// #include <X11/Xresource.h>
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
Bounds get_client(uintptr pid, int8_t isPid);
|
Bounds get_client(uintptr pid, int8_t isPid);
|
||||||
intptr scaleX();
|
|
||||||
|
|
||||||
double sys_scale(int32_t display_id) {
|
|
||||||
#if defined(IS_MACOSX)
|
|
||||||
CGDirectDisplayID displayID = (CGDirectDisplayID) display_id;
|
|
||||||
if (displayID == -1) {
|
|
||||||
displayID = CGMainDisplayID();
|
|
||||||
}
|
|
||||||
|
|
||||||
CGDisplayModeRef modeRef = CGDisplayCopyDisplayMode(displayID);
|
|
||||||
double pixelWidth = CGDisplayModeGetPixelWidth(modeRef);
|
|
||||||
double targetWidth = CGDisplayModeGetWidth(modeRef);
|
|
||||||
|
|
||||||
return pixelWidth / targetWidth;
|
|
||||||
#elif defined(USE_X11)
|
|
||||||
Display *dpy = XOpenDisplay(NULL);
|
|
||||||
|
|
||||||
int scr = 0; /* Screen number */
|
|
||||||
double xres = ((((double) DisplayWidth(dpy, scr)) * 25.4) /
|
|
||||||
((double) DisplayWidthMM(dpy, scr)));
|
|
||||||
|
|
||||||
char *rms = XResourceManagerString(dpy);
|
|
||||||
if (rms) {
|
|
||||||
XrmDatabase db = XrmGetStringDatabase(rms);
|
|
||||||
if (db) {
|
|
||||||
XrmValue value;
|
|
||||||
char *type = NULL;
|
|
||||||
|
|
||||||
if (XrmGetResource(db, "Xft.dpi", "String", &type, &value)) {
|
|
||||||
if (value.addr) {
|
|
||||||
xres = atof(value.addr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
XrmDestroyDatabase(db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XCloseDisplay (dpy);
|
|
||||||
|
|
||||||
return xres / 96.0;
|
|
||||||
#elif defined(IS_WINDOWS)
|
|
||||||
double s = scaleX() / 96.0;
|
|
||||||
return s;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
intptr scaleX(){
|
|
||||||
#if defined(IS_MACOSX)
|
|
||||||
return 0;
|
|
||||||
#elif defined(USE_X11)
|
|
||||||
return 0;
|
|
||||||
#elif defined(IS_WINDOWS)
|
|
||||||
// Get desktop dc
|
|
||||||
HDC desktopDc = GetDC(NULL);
|
|
||||||
// Get native resolution
|
|
||||||
intptr horizontalDPI = GetDeviceCaps(desktopDc, LOGPIXELSX);
|
|
||||||
return horizontalDPI;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Bounds get_bounds(uintptr pid, int8_t isPid){
|
Bounds get_bounds(uintptr pid, int8_t isPid){
|
||||||
// Check if the window is valid
|
// Check if the window is valid
|
||||||
|
@ -24,8 +24,8 @@ uintptr initHandle = 0;
|
|||||||
|
|
||||||
void initWindow(uintptr handle){
|
void initWindow(uintptr handle){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
mData.CgID = 0;
|
pub_mData.CgID = 0;
|
||||||
mData.AxID = 0;
|
pub_mData.AxID = 0;
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
Display *rDisplay = XOpenDisplay(NULL);
|
Display *rDisplay = XOpenDisplay(NULL);
|
||||||
// If atoms loaded
|
// If atoms loaded
|
||||||
@ -34,10 +34,10 @@ void initWindow(uintptr handle){
|
|||||||
if (rDisplay != NULL) {LoadAtoms();}
|
if (rDisplay != NULL) {LoadAtoms();}
|
||||||
}
|
}
|
||||||
|
|
||||||
mData.XWin = 0;
|
pub_mData.XWin = 0;
|
||||||
XCloseDisplay(rDisplay);
|
XCloseDisplay(rDisplay);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
mData.HWnd = 0;
|
pub_mData.HWnd = 0;
|
||||||
#endif
|
#endif
|
||||||
setHandle(handle);
|
setHandle(handle);
|
||||||
}
|
}
|
||||||
@ -67,33 +67,33 @@ MData set_handle_pid(uintptr pid, int8_t isPid){
|
|||||||
|
|
||||||
void set_handle_pid_mData(uintptr pid, int8_t isPid){
|
void set_handle_pid_mData(uintptr pid, int8_t isPid){
|
||||||
MData win = set_handle_pid(pid, isPid);
|
MData win = set_handle_pid(pid, isPid);
|
||||||
mData = win;
|
pub_mData = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid() {
|
bool is_valid() {
|
||||||
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! "
|
||||||
"Failed to enable access for assistive devices.");
|
"Failed to enable access for assistive devices. \n");
|
||||||
}
|
}
|
||||||
MData actdata = get_active();
|
MData actdata = get_active();
|
||||||
|
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
mData.CgID = actdata.CgID;
|
pub_mData.CgID = actdata.CgID;
|
||||||
mData.AxID = actdata.AxID;
|
pub_mData.AxID = actdata.AxID;
|
||||||
if (mData.CgID == 0 || mData.AxID == 0) { return false; }
|
if (pub_mData.CgID == 0 || pub_mData.AxID == 0) { return false; }
|
||||||
|
|
||||||
CFTypeRef r = NULL;
|
CFTypeRef r = NULL;
|
||||||
// Attempt to get the window role
|
// Attempt to get the window role
|
||||||
if (AXUIElementCopyAttributeValue(mData.AxID, kAXRoleAttribute, &r) == kAXErrorSuccess && r){
|
if (AXUIElementCopyAttributeValue(pub_mData.AxID, kAXRoleAttribute, &r) == kAXErrorSuccess && r){
|
||||||
CFRelease(r);
|
CFRelease(r);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
mData.XWin = actdata.XWin;
|
pub_mData.XWin = actdata.XWin;
|
||||||
if (mData.XWin == 0) { return false; }
|
if (pub_mData.XWin == 0) { return false; }
|
||||||
|
|
||||||
Display *rDisplay = XOpenDisplay(NULL);
|
Display *rDisplay = XOpenDisplay(NULL);
|
||||||
// Check for a valid X-Window display
|
// Check for a valid X-Window display
|
||||||
@ -103,7 +103,7 @@ bool is_valid() {
|
|||||||
XDismissErrors();
|
XDismissErrors();
|
||||||
|
|
||||||
// Get the window PID property
|
// Get the window PID property
|
||||||
void* result = GetWindowProperty(mData, WM_PID,NULL);
|
void* result = GetWindowProperty(pub_mData, WM_PID,NULL);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
XCloseDisplay(rDisplay);
|
XCloseDisplay(rDisplay);
|
||||||
return false;
|
return false;
|
||||||
@ -115,12 +115,12 @@ bool is_valid() {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
mData.HWnd = actdata.HWnd;
|
pub_mData.HWnd = actdata.HWnd;
|
||||||
if (mData.HWnd == 0) {
|
if (pub_mData.HWnd == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IsWindow(mData.HWnd) != 0;
|
return IsWindow(pub_mData.HWnd) != 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,13 +175,13 @@ bool IsAxEnabled(bool options){
|
|||||||
bool setHandle(uintptr handle){
|
bool setHandle(uintptr handle){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
// Release the AX element
|
// Release the AX element
|
||||||
if (mData.AxID != NULL) {
|
if (pub_mData.AxID != NULL) {
|
||||||
CFRelease(mData.AxID);
|
CFRelease(pub_mData.AxID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset both values
|
// Reset both values
|
||||||
mData.CgID = 0;
|
pub_mData.CgID = 0;
|
||||||
mData.AxID = 0;
|
pub_mData.AxID = 0;
|
||||||
|
|
||||||
if (handle == 0) {
|
if (handle == 0) {
|
||||||
// return 0;
|
// return 0;
|
||||||
@ -192,8 +192,8 @@ bool setHandle(uintptr handle){
|
|||||||
CGWindowID cgID = (CGWindowID)handle;
|
CGWindowID cgID = (CGWindowID)handle;
|
||||||
AXUIElementRef axID = GetUIElement(cgID);
|
AXUIElementRef axID = GetUIElement(cgID);
|
||||||
if (axID != NULL){
|
if (axID != NULL){
|
||||||
mData.CgID = cgID;
|
pub_mData.CgID = cgID;
|
||||||
mData.AxID = axID;
|
pub_mData.AxID = axID;
|
||||||
// return 0;
|
// return 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ bool setHandle(uintptr handle){
|
|||||||
// return 1;
|
// return 1;
|
||||||
return false;
|
return false;
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
mData.XWin = (Window)handle;
|
pub_mData.XWin = (Window)handle;
|
||||||
if (handle == 0) {
|
if (handle == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -210,10 +210,10 @@ bool setHandle(uintptr handle){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mData.XWin = 0;
|
pub_mData.XWin = 0;
|
||||||
return false;
|
return false;
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
mData.HWnd = (HWND)handle;
|
pub_mData.HWnd = (HWND)handle;
|
||||||
if (handle == 0) {
|
if (handle == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ bool setHandle(uintptr handle){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mData.HWnd = 0;
|
pub_mData.HWnd = 0;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ bool IsTopMost(void){
|
|||||||
// XDismissErrors ();
|
// XDismissErrors ();
|
||||||
// return GetState (mData.XWin, STATE_TOPMOST);
|
// return GetState (mData.XWin, STATE_TOPMOST);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
return (GetWindowLongPtr(mData.HWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
|
return (GetWindowLongPtr(pub_mData.HWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ bool IsMinimized(void){
|
|||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
CFBooleanRef data = NULL;
|
CFBooleanRef data = NULL;
|
||||||
// Determine whether the window is minimized
|
// Determine whether the window is minimized
|
||||||
if (AXUIElementCopyAttributeValue(mData.AxID, kAXMinimizedAttribute,
|
if (AXUIElementCopyAttributeValue(pub_mData.AxID, kAXMinimizedAttribute,
|
||||||
(CFTypeRef*) &data) == kAXErrorSuccess && data != NULL) {
|
(CFTypeRef*) &data) == kAXErrorSuccess && data != NULL) {
|
||||||
// Convert resulting data into a bool
|
// Convert resulting data into a bool
|
||||||
bool result = CFBooleanGetValue(data);
|
bool result = CFBooleanGetValue(data);
|
||||||
@ -261,7 +261,7 @@ bool IsMinimized(void){
|
|||||||
// XDismissErrors();
|
// XDismissErrors();
|
||||||
// return GetState(mData.XWin, STATE_MINIMIZE);
|
// return GetState(mData.XWin, STATE_MINIMIZE);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
return (GetWindowLongPtr(mData.HWnd, GWL_STYLE) & WS_MINIMIZE) != 0;
|
return (GetWindowLongPtr(pub_mData.HWnd, GWL_STYLE) & WS_MINIMIZE) != 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ bool IsMaximized(void){
|
|||||||
// XDismissErrors();
|
// XDismissErrors();
|
||||||
// return GetState(mData.XWin, STATE_MAXIMIZE);
|
// return GetState(mData.XWin, STATE_MAXIMIZE);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
return (GetWindowLongPtr(mData.HWnd, GWL_STYLE) & WS_MAXIMIZE) != 0;
|
return (GetWindowLongPtr(pub_mData.HWnd, GWL_STYLE) & WS_MAXIMIZE) != 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,9 +453,9 @@ void SetTopMost(bool state){
|
|||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
// Ignore X errors
|
// Ignore X errors
|
||||||
// XDismissErrors();
|
// XDismissErrors();
|
||||||
// SetState(mData.XWin, STATE_TOPMOST, state);
|
// SetState(pub_mData.XWin, STATE_TOPMOST, state);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
SetWindowPos(mData.HWnd, state ? HWND_TOPMOST : HWND_NOTOPMOST,
|
SetWindowPos(pub_mData.HWnd, state ? HWND_TOPMOST : HWND_NOTOPMOST,
|
||||||
0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -464,7 +464,7 @@ void close_main_window () {
|
|||||||
// Check if the window is valid
|
// Check if the window is valid
|
||||||
if (!is_valid()) { return; }
|
if (!is_valid()) { return; }
|
||||||
|
|
||||||
close_window_by_Id(mData);
|
close_window_by_Id(pub_mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_window_by_PId(uintptr pid, int8_t isPid){
|
void close_window_by_PId(uintptr pid, int8_t isPid){
|
||||||
@ -502,7 +502,7 @@ char* get_main_title(){
|
|||||||
// Check if the window is valid
|
// Check if the window is valid
|
||||||
if (!is_valid()) { return "is_valid failed."; }
|
if (!is_valid()) { return "is_valid failed."; }
|
||||||
|
|
||||||
return get_title_by_hand(mData);
|
return get_title_by_hand(pub_mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* get_title_by_pid(uintptr pid, int8_t isPid){
|
char* get_title_by_pid(uintptr pid, int8_t isPid){
|
||||||
@ -591,7 +591,7 @@ int32_t get_PID(void) {
|
|||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
// Attempt to retrieve the window pid
|
// Attempt to retrieve the window pid
|
||||||
if (AXUIElementGetPid(mData.AxID, &pid)== kAXErrorSuccess) {
|
if (AXUIElementGetPid(pub_mData.AxID, &pid)== kAXErrorSuccess) {
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -600,7 +600,7 @@ int32_t get_PID(void) {
|
|||||||
XDismissErrors();
|
XDismissErrors();
|
||||||
|
|
||||||
// Get the window PID
|
// Get the window PID
|
||||||
long* result = (long*)GetWindowProperty(mData, WM_PID,NULL);
|
long* result = (long*)GetWindowProperty(pub_mData, WM_PID,NULL);
|
||||||
// Check result and convert it
|
// Check result and convert it
|
||||||
if (result == NULL) { return 0; }
|
if (result == NULL) { return 0; }
|
||||||
|
|
||||||
@ -609,7 +609,7 @@ int32_t get_PID(void) {
|
|||||||
return pid;
|
return pid;
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
DWORD id = 0;
|
DWORD id = 0;
|
||||||
GetWindowThreadProcessId(mData.HWnd, &id);
|
GetWindowThreadProcessId(pub_mData.HWnd, &id);
|
||||||
return id;
|
return id;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user