mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
Add Getpid
This commit is contained in:
parent
cb6aa1075e
commit
bbc0c8e2a7
@ -777,3 +777,9 @@ func GetTitle() string {
|
|||||||
// Println("title...", gtittle)
|
// Println("title...", gtittle)
|
||||||
return gtittle
|
return gtittle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetPID Get the process id
|
||||||
|
func GetPID() int {
|
||||||
|
pid := C.aGetPID()
|
||||||
|
return int(pid)
|
||||||
|
}
|
||||||
|
@ -57,3 +57,8 @@ char* aGetTitle(){
|
|||||||
// printf("title::::%s\n",title );
|
// printf("title::::%s\n",title );
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 aGetPID(void){
|
||||||
|
int pid=WGetPID();
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
@ -867,3 +867,39 @@ char *GetTitle(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 WGetPID(void){
|
||||||
|
// Check window validity
|
||||||
|
if (!IsValid()) return 0;
|
||||||
|
|
||||||
|
#if defined(IS_MACOSX)
|
||||||
|
|
||||||
|
pid_t pid = 0;
|
||||||
|
// Attempt to retrieve the window pid
|
||||||
|
if (AXUIElementGetPid(mData.AxID, &pid)
|
||||||
|
== kAXErrorSuccess) return pid;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#elif defined(USE_X11)
|
||||||
|
|
||||||
|
// Ignore X errors
|
||||||
|
XDismissErrors();
|
||||||
|
|
||||||
|
// Get the window PID
|
||||||
|
long* result = (long*)
|
||||||
|
GetWindowProperty(mData, WM_PID,NULL);
|
||||||
|
|
||||||
|
// Check result and convert it
|
||||||
|
if (result == NULL) return 0;
|
||||||
|
int32 pid = (int32) *result;
|
||||||
|
XFree (result); return pid;
|
||||||
|
|
||||||
|
#elif defined(IS_WINDOWS)
|
||||||
|
|
||||||
|
DWORD id = 0;
|
||||||
|
GetWindowThreadProcessId (mData.HWnd, &id);
|
||||||
|
return id;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user