mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-30 22:13:54 +00:00
Fixed CI build and test
This commit is contained in:
parent
28fd0b9af6
commit
cc2d0198ea
46
base/snprintf.h
Normal file
46
base/snprintf.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef _PORTABLE_SNPRINTF_H_
|
||||
#define _PORTABLE_SNPRINTF_H_
|
||||
|
||||
#define PORTABLE_SNPRINTF_VERSION_MAJOR 2
|
||||
#define PORTABLE_SNPRINTF_VERSION_MINOR 2
|
||||
|
||||
#include "os.h"
|
||||
#if defined(IS_MACOSX)
|
||||
#define HAVE_SNPRINTF
|
||||
#else
|
||||
#define HAVE_SNPRINTF
|
||||
#define PREFER_PORTABLE_SNPRINTF
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
#include <stdio.h>
|
||||
#else
|
||||
extern int snprintf(char *, size_t, const char *, /*args*/ ...);
|
||||
extern int vsnprintf(char *, size_t, const char *, va_list);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SNPRINTF) && defined(PREFER_PORTABLE_SNPRINTF)
|
||||
extern int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...);
|
||||
extern int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap);
|
||||
#define snprintf portable_snprintf
|
||||
#define vsnprintf portable_vsnprintf
|
||||
#endif
|
||||
|
||||
extern int asprintf (char **ptr, const char *fmt, /*args*/ ...);
|
||||
extern int vasprintf (char **ptr, const char *fmt, va_list ap);
|
||||
extern int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...);
|
||||
extern int vasnprintf(char **ptr, size_t str_m, const char *fmt, va_list ap);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
1019
base/snprintf_c.h
Normal file
1019
base/snprintf_c.h
Normal file
File diff suppressed because it is too large
Load Diff
74
test/main.go
74
test/main.go
@ -1,74 +0,0 @@
|
||||
// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
|
||||
//
|
||||
// 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.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/go-vgo/robotgo"
|
||||
)
|
||||
|
||||
func aRobotgo() {
|
||||
abool := robotgo.ShowAlert("test", "robotgo")
|
||||
if abool {
|
||||
fmt.Println("ok@@@", "ok")
|
||||
}
|
||||
|
||||
x, y := robotgo.GetMousePos()
|
||||
fmt.Println("pos:", x, y)
|
||||
|
||||
robotgo.Move(x, y)
|
||||
robotgo.Move(100, 200)
|
||||
|
||||
robotgo.Toggle("left")
|
||||
robotgo.Toggle("left", "up")
|
||||
|
||||
for i := 0; i < 1080; i += 1000 {
|
||||
fmt.Println(i)
|
||||
robotgo.Move(800, i)
|
||||
}
|
||||
|
||||
fmt.Println(robotgo.GetPixelColor(x, y))
|
||||
|
||||
color := robotgo.GetPixelColor(100, 200)
|
||||
fmt.Println("color@@@", color)
|
||||
|
||||
robotgo.TypeStr("Hello World")
|
||||
// robotgo.KeyTap("a", "control")
|
||||
robotgo.KeyTap("f1", "control")
|
||||
// robotgo.KeyTap("enter")
|
||||
// robotgo.KeyToggle("enter", "down")
|
||||
robotgo.TypeStr("en")
|
||||
|
||||
abitmap := robotgo.CaptureScreen()
|
||||
fmt.Println("all...", abitmap)
|
||||
|
||||
bitmap := robotgo.CaptureScreen(10, 20, 30, 40)
|
||||
fmt.Println("...", bitmap)
|
||||
|
||||
fx, fy := robotgo.FindBitmap(bitmap)
|
||||
fmt.Println("FindBitmap------", fx, fy)
|
||||
|
||||
robotgo.SaveBitmap(bitmap, "test.png", 1)
|
||||
|
||||
var bitmapTest robotgo.Bitmap
|
||||
bitTest := robotgo.OpenBitmap("test.png")
|
||||
bitmapTest = robotgo.ToBitmap(bitTest)
|
||||
fmt.Println("...type", reflect.TypeOf(bitTest), reflect.TypeOf(bitmapTest))
|
||||
|
||||
// robotgo.MouseClick()
|
||||
robotgo.Scroll(0, 10)
|
||||
}
|
||||
|
||||
func main() {
|
||||
aRobotgo()
|
||||
}
|
@ -73,6 +73,7 @@ int showAlert(const char *title, const char *msg, const char *defaultButton,
|
||||
|
||||
if (defaultButton == NULL) defaultButton = "OK";
|
||||
|
||||
// snprintf.h
|
||||
if (cancelButton == NULL) {
|
||||
asprintf(&buttonList, "%s:2", defaultButton);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user