mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
add close window example and add set handle by pid func
This commit is contained in:
parent
1d7f43f3c8
commit
a6799263b5
@ -69,6 +69,7 @@ func window() {
|
|||||||
// hwnd := robotgo.GetHWND()
|
// hwnd := robotgo.GetHWND()
|
||||||
robotgo.MinWindow(fpid[0])
|
robotgo.MinWindow(fpid[0])
|
||||||
robotgo.MaxWindow(fpid[0])
|
robotgo.MaxWindow(fpid[0])
|
||||||
|
robotgo.CloseWindow(fpid[0])
|
||||||
|
|
||||||
robotgo.Kill(fpid[0])
|
robotgo.Kill(fpid[0])
|
||||||
}
|
}
|
||||||
|
10
robotgo.go
10
robotgo.go
@ -1381,6 +1381,16 @@ func SetHandle(hwnd int) {
|
|||||||
C.set_handle(chwnd)
|
C.set_handle(chwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetHandlePid set the window handle by pid
|
||||||
|
func SetHandlePid(pid int32, args ...int32) C.MData {
|
||||||
|
var isHwnd int32
|
||||||
|
if len(args) > 0 {
|
||||||
|
isHwnd = args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return C.set_handle_pid(C.uintptr(pid), C.uintptr(isHwnd))
|
||||||
|
}
|
||||||
|
|
||||||
// GetHandle get the window handle
|
// GetHandle get the window handle
|
||||||
func GetHandle() int {
|
func GetHandle() int {
|
||||||
hwnd := C.get_handle()
|
hwnd := C.get_handle()
|
||||||
|
@ -106,7 +106,7 @@ void set_active(const MData win){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void active_PID(uintptr pid, uintptr isHwnd){
|
void active_PID(uintptr pid, uintptr isHwnd){
|
||||||
MData win = set_hand_pid(pid, isHwnd);
|
MData win = set_handle_pid(pid, isHwnd);
|
||||||
SetActive(win);
|
SetActive(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ void initWindow(uintptr handle){
|
|||||||
setHandle(handle);
|
setHandle(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
MData set_hand_pid(uintptr pid, uintptr isHwnd){
|
MData set_handle_pid(uintptr pid, uintptr isHwnd){
|
||||||
MData win;
|
MData win;
|
||||||
|
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
@ -547,7 +547,7 @@ void close_main_window (){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void close_window_by_PId(uintptr pid, uintptr isHwnd){
|
void close_window_by_PId(uintptr pid, uintptr isHwnd){
|
||||||
MData win = set_hand_pid(pid, isHwnd);
|
MData win = set_handle_pid(pid, isHwnd);
|
||||||
close_window_by_Id(win);
|
close_window_by_Id(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +592,7 @@ char* get_main_title(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
char* get_title_by_pid(uintptr pid, uintptr isHwnd){
|
char* get_title_by_pid(uintptr pid, uintptr isHwnd){
|
||||||
MData win = set_hand_pid(pid, isHwnd);
|
MData win = set_handle_pid(pid, isHwnd);
|
||||||
return get_title_by_hand(win);
|
return get_title_by_hand(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user