2018-02-01 16:07:44 +00:00
|
|
|
// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
|
2016-11-10 06:34:13 +00:00
|
|
|
// file at the top-level directory of this distribution and at
|
2016-12-10 18:41:08 +00:00
|
|
|
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
|
2016-11-10 06:34:13 +00:00
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
2016-11-05 08:16:26 +00:00
|
|
|
#include "alert_c.h"
|
2016-11-10 10:59:37 +00:00
|
|
|
#include "window.h"
|
2018-08-13 12:10:54 +00:00
|
|
|
#include "win_sys.h"
|
2016-11-05 08:16:26 +00:00
|
|
|
|
2018-03-02 15:08:12 +00:00
|
|
|
int show_alert(const char *title, const char *msg,
|
|
|
|
|
const char *defaultButton, const char *cancelButton){
|
2019-07-20 12:32:43 +00:00
|
|
|
|
2017-05-10 13:04:55 +00:00
|
|
|
int alert = showAlert(title, msg, defaultButton, cancelButton);
|
2016-11-07 10:34:21 +00:00
|
|
|
return alert;
|
2016-11-07 14:36:28 +00:00
|
|
|
}
|
2016-11-10 10:59:37 +00:00
|
|
|
|
2018-08-14 11:18:14 +00:00
|
|
|
intptr scale_x(){
|
|
|
|
|
return scaleX();
|
2018-07-09 14:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-14 11:18:14 +00:00
|
|
|
intptr scale_y(){
|
|
|
|
|
return scaleY();
|
2018-07-09 14:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
bool is_valid(){
|
2017-05-09 13:56:22 +00:00
|
|
|
bool abool = IsValid();
|
2016-11-10 10:59:37 +00:00
|
|
|
return abool;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
// int find_window(char* name){
|
2017-05-09 13:56:22 +00:00
|
|
|
// int z = findwindow(name);
|
2016-11-10 11:03:11 +00:00
|
|
|
// return z;
|
|
|
|
|
// }
|
2016-11-10 10:59:37 +00:00
|
|
|
|
2018-07-29 15:53:54 +00:00
|
|
|
void min_window(uintptr pid, bool state, uintptr isHwnd){
|
|
|
|
|
#if defined(IS_MACOSX)
|
|
|
|
|
// return 0;
|
|
|
|
|
AXUIElementRef axID = AXUIElementCreateApplication(pid);
|
2018-07-29 16:01:10 +00:00
|
|
|
|
2018-07-29 15:53:54 +00:00
|
|
|
AXUIElementSetAttributeValue(axID, kAXMinimizedAttribute,
|
|
|
|
|
state ? kCFBooleanTrue : kCFBooleanFalse);
|
|
|
|
|
#elif defined(USE_X11)
|
|
|
|
|
// Ignore X errors
|
|
|
|
|
XDismissErrors();
|
|
|
|
|
// SetState((Window)pid, STATE_MINIMIZE, state);
|
|
|
|
|
#elif defined(IS_WINDOWS)
|
|
|
|
|
if (isHwnd == 0) {
|
|
|
|
|
HWND hwnd = GetHwndByPId(pid);
|
2018-07-29 16:01:10 +00:00
|
|
|
win_min(hwnd, state);
|
2018-07-29 15:53:54 +00:00
|
|
|
} else {
|
|
|
|
|
win_min((HWND)pid, state);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max_window(uintptr pid, bool state, uintptr isHwnd){
|
|
|
|
|
#if defined(IS_MACOSX)
|
|
|
|
|
// return 0;
|
|
|
|
|
#elif defined(USE_X11)
|
|
|
|
|
XDismissErrors();
|
|
|
|
|
// SetState((Window)pid, STATE_MINIMIZE, false);
|
|
|
|
|
// SetState((Window)pid, STATE_MAXIMIZE, state);
|
|
|
|
|
#elif defined(IS_WINDOWS)
|
|
|
|
|
if (isHwnd == 0) {
|
|
|
|
|
HWND hwnd = GetHwndByPId(pid);
|
|
|
|
|
win_max(hwnd, state);
|
|
|
|
|
} else {
|
|
|
|
|
win_max((HWND)pid, state);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-23 16:06:42 +00:00
|
|
|
void close_window(uintptr pid, uintptr isHwnd){
|
|
|
|
|
close_window_by_PId(pid, isHwnd);
|
2016-11-10 10:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
bool set_handle(uintptr handle){
|
2017-05-09 13:56:22 +00:00
|
|
|
bool hwnd = setHandle(handle);
|
2016-11-28 12:41:15 +00:00
|
|
|
return hwnd;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
uintptr get_handle(){
|
2017-05-09 13:56:22 +00:00
|
|
|
MData mData = GetActive();
|
2018-08-21 17:04:23 +00:00
|
|
|
|
2017-02-06 11:10:10 +00:00
|
|
|
#if defined(IS_MACOSX)
|
|
|
|
|
return (uintptr)mData.CgID;
|
|
|
|
|
#elif defined(USE_X11)
|
|
|
|
|
return (uintptr)mData.XWin;
|
|
|
|
|
#elif defined(IS_WINDOWS)
|
|
|
|
|
return (uintptr)mData.HWnd;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-11 13:14:57 +00:00
|
|
|
uintptr bget_handle(){
|
|
|
|
|
uintptr hwnd = getHandle();
|
|
|
|
|
return hwnd;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
void set_active(const MData win){
|
2016-11-23 12:40:28 +00:00
|
|
|
SetActive(win);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-11 13:07:17 +00:00
|
|
|
void active_PID(uintptr pid, uintptr isHwnd){
|
2018-08-25 13:51:38 +00:00
|
|
|
MData win = set_handle_pid(pid, isHwnd);
|
2017-07-13 14:02:27 +00:00
|
|
|
SetActive(win);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
MData get_active(){
|
2017-05-09 13:56:22 +00:00
|
|
|
MData mdata = GetActive();
|
2016-11-10 10:59:37 +00:00
|
|
|
return mdata;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 16:47:31 +00:00
|
|
|
char* get_title(uintptr pid, uintptr isHwnd){
|
|
|
|
|
char* title = get_title_by_pid(pid, isHwnd);
|
2017-05-10 13:04:55 +00:00
|
|
|
// printf("title::::%s\n", title );
|
2016-11-10 10:59:37 +00:00
|
|
|
return title;
|
|
|
|
|
}
|
2017-01-18 12:34:35 +00:00
|
|
|
|
2017-12-29 11:52:42 +00:00
|
|
|
int32 get_PID(void){
|
2017-05-09 13:56:22 +00:00
|
|
|
int pid = WGetPID();
|
2017-01-18 12:34:35 +00:00
|
|
|
return pid;
|
|
|
|
|
}
|