Format some code

This commit is contained in:
vCaesar 2017-05-09 21:56:22 +08:00
parent 52479b6e13
commit 0ebade43f7
6 changed files with 43 additions and 42 deletions

View File

@ -30,15 +30,15 @@
MMPoint aFindBitmap(MMBitmapRef bit_map,MMRect rect){ MMPoint aFindBitmap(MMBitmapRef bit_map,MMRect rect){
// MMRect rect; // MMRect rect;
// rect.size.width=10; // rect.size.width = 10;
// rect.size.height=20; // rect.size.height = 20;
// rect.origin.x=10; // rect.origin.x = 10;
// rect.origin.y=20; // rect.origin.y = 20;
float tolerance = 0.0f; float tolerance = 0.0f;
MMPoint point; MMPoint point;
tolerance=0.5; tolerance = 0.5;
if (findBitmapInRect(bit_map, bit_map, &point, if (findBitmapInRect(bit_map, bit_map, &point,
rect, tolerance) == 0) { rect, tolerance) == 0) {

View File

@ -89,7 +89,7 @@ typedef struct _MEvent MEvent;
// typedef MMBitmap *MMBitmapRef; // typedef MMBitmap *MMBitmapRef;
char *cevent; char *cevent;
// uint16_t *cevent; // uint16_t *cevent;
int cstatus=1; int cstatus = 1;
MEvent mEvent; MEvent mEvent;
void dispatch_proc(iohook_event * const event) { void dispatch_proc(iohook_event * const event) {
@ -125,12 +125,12 @@ void dispatch_proc(iohook_event * const event) {
snprintf(buffer + length, sizeof(buffer) - length, snprintf(buffer + length, sizeof(buffer) - length,
",keycode=%u,rawcode=0x%X", ",keycode=%u,rawcode=0x%X",
event->data.keyboard.keycode, event->data.keyboard.rawcode); event->data.keyboard.keycode, event->data.keyboard.rawcode);
int akeycode=(uint16_t) event->data.keyboard.keycode; int akeycode = (uint16_t) event->data.keyboard.keycode;
// printf("atoi(str)---%d\n", atoi(cevent)); // printf("atoi(str)---%d\n", atoi(cevent));
if (akeycode==atoi(cevent)){ if (akeycode == atoi(cevent)){
int astop=aStop(); int astop = aStop();
// printf("%d\n",astop); // printf("%d\n",astop);
cstatus=0; cstatus = 0;
} }
break; break;
@ -153,9 +153,9 @@ void dispatch_proc(iohook_event * const event) {
#endif #endif
if (strcmp(buf, cevent) == 0){ if (strcmp(buf, cevent) == 0){
int astop=aStop(); int astop = aStop();
// printf("%d\n",astop); // printf("%d\n",astop);
cstatus=0; cstatus = 0;
} }
// return (char*) event->data.keyboard.keychar; // return (char*) event->data.keyboard.keychar;
break; break;
@ -169,30 +169,32 @@ void dispatch_proc(iohook_event * const event) {
",x=%i,y=%i,button=%i,clicks=%i", ",x=%i,y=%i,button=%i,clicks=%i",
event->data.mouse.x, event->data.mouse.y, event->data.mouse.x, event->data.mouse.y,
event->data.mouse.button, event->data.mouse.clicks); event->data.mouse.button, event->data.mouse.clicks);
int abutton=event->data.mouse.button;
int aclicks=event->data.mouse.clicks; int abutton = event->data.mouse.button;
int amouse=-1; int aclicks = event->data.mouse.clicks;
int amouse = -1;
if (strcmp(cevent,"mleft") == 0){ if (strcmp(cevent,"mleft") == 0){
amouse=1; amouse = 1;
} }
if (strcmp(cevent,"mright") == 0){ if (strcmp(cevent,"mright") == 0){
amouse=2; amouse = 2;
} }
if (strcmp(cevent,"wheelDown") == 0){ if (strcmp(cevent,"wheelDown") == 0){
amouse=4; amouse = 4;
} }
if (strcmp(cevent,"wheelUp") == 0){ if (strcmp(cevent,"wheelUp") == 0){
amouse=5; amouse = 5;
} }
if (strcmp(cevent,"wheelLeft") == 0){ if (strcmp(cevent,"wheelLeft") == 0){
amouse=6; amouse = 6;
} }
if (strcmp(cevent,"wheelRight") == 0){ if (strcmp(cevent,"wheelRight") == 0){
amouse=7; amouse = 7;
} }
if (abutton==amouse && aclicks==1){ if (abutton == amouse && aclicks == 1){
int astop=aStop(); int astop = aStop();
cstatus=0; cstatus = 0;
} }
break; break;
@ -213,7 +215,7 @@ void dispatch_proc(iohook_event * const event) {
int aEvent(char *aevent) { int aEvent(char *aevent) {
// (uint16_t *) // (uint16_t *)
cevent=aevent; cevent = aevent;
// Set the logger callback for library output. // Set the logger callback for library output.
hookSetlogger(&loggerProc); hookSetlogger(&loggerProc);

View File

@ -318,10 +318,9 @@ void aTypeString(char *str){
} }
void aTypeStringDelayed(char *str,size_t cpm){ void aTypeStringDelayed(char *str,size_t cpm){
typeStringDelayed(str, cpm); typeStringDelayed(str, cpm);
} }
void aSetKeyboardDelay(size_t val){ void aSetKeyboardDelay(size_t val){
keyboardDelay =val; keyboardDelay = val;
} }

View File

@ -41,8 +41,8 @@ int mouseDelay = 10;
int aMoveMouse(size_t x, size_t y){ int aMoveMouse(size_t x, size_t y){
MMPoint point; MMPoint point;
//int x =103; //int x = 103;
//int y =104; //int y = 104;
point = MMPointMake(x, y); point = MMPointMake(x, y);
moveMouse(point); moveMouse(point);
@ -50,8 +50,8 @@ int aMoveMouse(size_t x, size_t y){
} }
int aDragMouse(size_t x, size_t y){ int aDragMouse(size_t x, size_t y){
// const size_t x=10; // const size_t x = 10;
// const size_t y=20; // const size_t y = 20;
MMMouseButton button = LEFT_BUTTON; MMMouseButton button = LEFT_BUTTON;
MMPoint point; MMPoint point;

View File

@ -44,7 +44,7 @@ char* aGetPixelColor(size_t x, size_t y){
// return 0; // return 0;
char* s=(char*)calloc(100,sizeof(char*)); char* s = (char*)calloc(100,sizeof(char*));
if(s)strcpy(s,hex); if(s)strcpy(s,hex);
return s; return s;
@ -68,7 +68,7 @@ char* aSetXDisplayName(char* name){
char* aGetXDisplayName(){ char* aGetXDisplayName(){
#if defined(USE_X11) #if defined(USE_X11)
const char* display = getXDisplay(); const char* display = getXDisplay();
char* sd=(char*)calloc(100,sizeof(char*)); char* sd = (char*)calloc(100,sizeof(char*));
if(sd)strcpy(sd,display); if(sd)strcpy(sd,display);
return sd; return sd;

View File

@ -13,18 +13,18 @@
int aShowAlert(const char *title, const char *msg, const char *defaultButton, int aShowAlert(const char *title, const char *msg, const char *defaultButton,
const char *cancelButton){ const char *cancelButton){
int alert=showAlert(title,msg,defaultButton,cancelButton); int alert = showAlert(title,msg,defaultButton,cancelButton);
return alert; return alert;
} }
bool aIsValid(){ bool aIsValid(){
bool abool=IsValid(); bool abool = IsValid();
return abool; return abool;
} }
// int aFindwindow(char* name){ // int aFindwindow(char* name){
// int z=findwindow(name); // int z = findwindow(name);
// return z; // return z;
// } // }
@ -33,17 +33,17 @@ void aCloseWindow(void){
} }
bool aSetHandle (uintptr handle){ bool aSetHandle (uintptr handle){
bool hwnd=setHandle(handle); bool hwnd = setHandle(handle);
return hwnd; return hwnd;
} }
uintptr aGetHandle(){ uintptr aGetHandle(){
uintptr hwnd=getHandle(); uintptr hwnd = getHandle();
return hwnd; return hwnd;
} }
uintptr bGetHandle(){ uintptr bGetHandle(){
MData mData=GetActive(); MData mData = GetActive();
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
return (uintptr)mData.CgID; return (uintptr)mData.CgID;
#elif defined(USE_X11) #elif defined(USE_X11)
@ -58,17 +58,17 @@ void aSetActive(const MData win){
} }
MData aGetActive(){ MData aGetActive(){
MData mdata=GetActive(); MData mdata = GetActive();
return mdata; return mdata;
} }
char* aGetTitle(){ char* aGetTitle(){
char* title=GetTitle(); char* title = GetTitle();
// printf("title::::%s\n",title ); // printf("title::::%s\n",title );
return title; return title;
} }
int32 aGetPID(void){ int32 aGetPID(void){
int pid=WGetPID(); int pid = WGetPID();
return pid; return pid;
} }