mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
add set_hand_pid and add return
This commit is contained in:
parent
873e9d30dc
commit
1bb08731d1
@ -10,7 +10,6 @@
|
||||
|
||||
#include "alert_c.h"
|
||||
#include "window.h"
|
||||
#include "win32.h"
|
||||
#include "win_sys.h"
|
||||
|
||||
int show_alert(const char *title, const char *msg,
|
||||
@ -87,6 +86,7 @@ bool set_handle(uintptr handle){
|
||||
|
||||
uintptr get_handle(){
|
||||
MData mData = GetActive();
|
||||
|
||||
#if defined(IS_MACOSX)
|
||||
return (uintptr)mData.CgID;
|
||||
#elif defined(USE_X11)
|
||||
@ -106,21 +106,7 @@ void set_active(const MData win){
|
||||
}
|
||||
|
||||
void active_PID(uintptr pid, uintptr isHwnd){
|
||||
MData win;
|
||||
#if defined(IS_MACOSX)
|
||||
// Handle to a AXUIElementRef
|
||||
win.AxID = AXUIElementCreateApplication(pid);
|
||||
#elif defined(USE_X11)
|
||||
win.XWin = (Window)pid; // Handle to an X11 window
|
||||
#elif defined(IS_WINDOWS)
|
||||
// win.HWnd = (HWND)pid; // Handle to a window HWND
|
||||
if (isHwnd == 0) {
|
||||
win.HWnd = GetHwndByPId(pid);
|
||||
} else {
|
||||
win.HWnd = (HWND)pid;
|
||||
}
|
||||
#endif
|
||||
|
||||
MData win = set_hand_pid(pid, isHwnd);
|
||||
SetActive(win);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
// #include <stdlib.h>
|
||||
#include "process.h"
|
||||
#include "pub.h"
|
||||
#include "win32.h"
|
||||
|
||||
bool setHandle(uintptr handle);
|
||||
bool IsValid();
|
||||
@ -47,6 +48,26 @@ void initWindow(uintptr handle){
|
||||
setHandle(handle);
|
||||
}
|
||||
|
||||
MData set_hand_pid(uintptr pid, uintptr isHwnd){
|
||||
MData win;
|
||||
|
||||
#if defined(IS_MACOSX)
|
||||
// Handle to a AXUIElementRef
|
||||
win.AxID = AXUIElementCreateApplication(pid);
|
||||
#elif defined(USE_X11)
|
||||
win.XWin = (Window)pid; // Handle to an X11 window
|
||||
#elif defined(IS_WINDOWS)
|
||||
// win.HWnd = (HWND)pid; // Handle to a window HWND
|
||||
if (isHwnd == 0) {
|
||||
win.HWnd = GetHwndByPId(pid);
|
||||
} else {
|
||||
win.HWnd = (HWND)pid;
|
||||
}
|
||||
#endif
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
bool IsValid(){
|
||||
initWindow(initHandle);
|
||||
if (!IsAxEnabled(true)) {
|
||||
@ -550,31 +571,18 @@ void CloseWin(void){
|
||||
}
|
||||
|
||||
char* get_main_title(){
|
||||
get_title_by_hand(mData);
|
||||
return get_title_by_hand(mData);
|
||||
}
|
||||
|
||||
char* get_title_by_pid(uintptr pid, uintptr isHwnd){
|
||||
MData win;
|
||||
|
||||
#if defined(IS_MACOSX)
|
||||
win.AxID = AXUIElementCreateApplication(pid);
|
||||
#elif defined(USE_X11)
|
||||
win.XWin = (Window)pid;
|
||||
#elif defined(IS_WINDOWS)
|
||||
if (isHwnd == 0) {
|
||||
win.HWnd = GetHwndByPId(pid);
|
||||
} else {
|
||||
win.HWnd = (HWND)pid;
|
||||
}
|
||||
#endif
|
||||
|
||||
get_title_by_hand(win);
|
||||
MData win = set_hand_pid(pid, isHwnd);
|
||||
return get_title_by_hand(win);
|
||||
}
|
||||
|
||||
char* get_title_by_hand(MData m_data){
|
||||
// Check if the window is valid
|
||||
if (!IsValid()) {return "IsValid failed.";}
|
||||
|
||||
|
||||
#if defined(IS_MACOSX)
|
||||
|
||||
CFStringRef data = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user