mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Update x11 alert() code and remove ScaleY()
This commit is contained in:
parent
8defbda0cd
commit
bafa051f92
@ -422,13 +422,6 @@ func ScaleX() int {
|
|||||||
return int(C.scale_x())
|
return int(C.scale_x())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use the ScaledF(),
|
|
||||||
//
|
|
||||||
// ScaleY get primary display vertical DPI scale factor, drop
|
|
||||||
func ScaleY() int {
|
|
||||||
return int(C.scale_y())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: use the ScaledF(),
|
// Deprecated: use the ScaledF(),
|
||||||
//
|
//
|
||||||
// Scale get the screen scale (only windows old), drop
|
// Scale get the screen scale (only windows old), drop
|
||||||
@ -1254,7 +1247,6 @@ func showAlert(title, msg string, args ...string) bool {
|
|||||||
func IsValid() bool {
|
func IsValid() bool {
|
||||||
abool := C.is_valid()
|
abool := C.is_valid()
|
||||||
gbool := bool(abool)
|
gbool := bool(abool)
|
||||||
// fmt.Println("bool---------", gbool)
|
|
||||||
return gbool
|
return gbool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,12 @@ func DisplaysNum() int {
|
|||||||
func Alert(title, msg string, args ...string) bool {
|
func Alert(title, msg string, args ...string) bool {
|
||||||
defaultBtn, cancelBtn := alertArgs(args...)
|
defaultBtn, cancelBtn := alertArgs(args...)
|
||||||
c := `xmessage -center ` + msg +
|
c := `xmessage -center ` + msg +
|
||||||
` -title ` + title + ` -buttons ` + defaultBtn + ":0," + cancelBtn + ":1" + ` -default Ok`
|
` -title ` + title + ` -buttons ` + defaultBtn + ":0,"
|
||||||
|
if cancleBtn != "" {
|
||||||
|
c += cancelBtn + ":1"
|
||||||
|
}
|
||||||
|
c += ` -default ` + defaultBtn
|
||||||
|
|
||||||
out, err := Run(c)
|
out, err := Run(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Alert: ", err, ". ", string(out))
|
fmt.Println("Alert: ", err, ". ", string(out))
|
||||||
|
@ -14,29 +14,18 @@
|
|||||||
|
|
||||||
int show_alert(const char *title, const char *msg,
|
int show_alert(const char *title, const char *msg,
|
||||||
const char *defaultButton, const char *cancelButton){
|
const char *defaultButton, const char *cancelButton){
|
||||||
|
|
||||||
int alert = showAlert(title, msg, defaultButton, cancelButton);
|
return showAlert(title, msg, defaultButton, cancelButton);
|
||||||
return alert;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr scale_x(){
|
intptr scale_x(){
|
||||||
return scaleX();
|
return scaleX();
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr scale_y(){
|
|
||||||
return scaleY();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_valid(){
|
bool is_valid(){
|
||||||
bool abool = IsValid();
|
return IsValid();
|
||||||
return abool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int find_window(char* name){
|
|
||||||
// int z = findwindow(name);
|
|
||||||
// return z;
|
|
||||||
// }
|
|
||||||
|
|
||||||
void min_window(uintptr pid, bool state, uintptr isHwnd){
|
void min_window(uintptr pid, bool state, uintptr isHwnd){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
// return 0;
|
// return 0;
|
||||||
@ -80,8 +69,7 @@ void close_window(uintptr pid, uintptr isHwnd){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool set_handle(uintptr handle){
|
bool set_handle(uintptr handle){
|
||||||
bool hwnd = setHandle(handle);
|
return setHandle(handle);
|
||||||
return hwnd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr get_handle(){
|
uintptr get_handle(){
|
||||||
@ -96,9 +84,19 @@ uintptr get_handle(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// uint32 uintptr
|
||||||
|
uintptr getHandle() {
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
|
||||||
uintptr bget_handle(){
|
uintptr bget_handle(){
|
||||||
uintptr hwnd = getHandle();
|
return getHandle();
|
||||||
return hwnd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_active(const MData win){
|
void set_active(const MData win){
|
||||||
|
@ -76,18 +76,6 @@ intptr scaleX(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr scaleY(){
|
|
||||||
#if defined(IS_MACOSX)
|
|
||||||
return 0;
|
|
||||||
#elif defined(USE_X11)
|
|
||||||
return 0;
|
|
||||||
#elif defined(IS_WINDOWS)
|
|
||||||
HDC desktopDc = GetDC(NULL);
|
|
||||||
intptr verticalDPI = GetDeviceCaps(desktopDc, LOGPIXELSY);
|
|
||||||
return verticalDPI;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Bounds get_bounds(uintptr pid, uintptr isHwnd){
|
Bounds get_bounds(uintptr pid, uintptr isHwnd){
|
||||||
// Check if the window is valid
|
// Check if the window is valid
|
||||||
Bounds bounds;
|
Bounds bounds;
|
||||||
|
@ -74,7 +74,7 @@ void set_handle_pid_mData(uintptr pid, uintptr isHwnd){
|
|||||||
mData = win;
|
mData = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValid(){
|
bool IsValid() {
|
||||||
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!\n"
|
||||||
@ -232,17 +232,6 @@ bool setHandle(uintptr handle){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// uint32 uintptr
|
|
||||||
uintptr getHandle() {
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsTopMost(void){
|
bool IsTopMost(void){
|
||||||
// Check the window validity
|
// Check the window validity
|
||||||
if (!IsValid()) {return false;}
|
if (!IsValid()) {return false;}
|
||||||
|
Loading…
Reference in New Issue
Block a user