jsjl_for_ubuntu12.04
2016-03-13 18:03
543 查看
1、
VC++代码:
2、
VC++代码:
#include <stdio.h> #include <windows.h> #include <wchar.h> void MoveMouseZ(int _iX, int _iY); HWND FindSubBtn01(HWND _hWndParent, char *pcSubWndText); void PrintLocalTime(); void main() { Sleep(1000 * 10); PrintLocalTime(); printf("\t 程序开始\n"); char *pcParentWndText = "加速精灵 v2.6"; char *pcSubBtnText = "连 接"; bool bBtnConn = false; // 指示 "连 接"按钮 是否为可点击的状态 int iCounter = 0; int iCounterMoveMouse = 0; while (1) { iCounterMoveMouse ++; if (iCounterMoveMouse >= 5) { //* MoveMouseZ(0, 0); MoveMouseZ(500, 300); //*/ iCounterMoveMouse = 0; } /* HWND hWndParent = ::FindWindowA(NULL, pcParentWndText); if (hWndParent == 0) { PrintLocalTime(); printf("\t Window \"%s\" is not found .\n", pcParentWndText); } else { HWND hBtnLianJie = FindSubBtn01(hWndParent, pcSubBtnText); if (hBtnLianJie == 0) { PrintLocalTime(); printf("\t Sub Button \"%s\" is not found .\n", pcSubBtnText); } else { bool bEnabled = ::IsWindowEnabled(hBtnLianJie); if (bEnabled) { PrintLocalTime(); printf("\t 连接断开,即将尝试重新连接\n"); bBtnConn = true; iCounter = 0; // 模拟 button click事件 // http://blog.sina.com.cn/s/blog_6414c87b0101892x.html LONG idBtn = GetWindowLong(hBtnLianJie, GWL_ID); ::SendMessageA(hWndParent, WM_COMMAND, MAKEWPARAM(idBtn, BN_CLICKED), (LPARAM)hBtnLianJie); } else { if (bBtnConn) iCounter ++; // 连续监测15次,"连 接"按钮都是不可点击的状态,则说明 貌似已经连上去了。 if (iCounter > 15) { PrintLocalTime(); printf("\t 貌似 已经重新连接成功\n"); bBtnConn = false; iCounter = 0; } } } } //*/ ::Sleep(1000); } system("pause"); } // 找窗口"加速精灵 v2.6"下的,窗口标题为"连 接"的按钮 - 方式(1) HWND FindSubBtn01(HWND _hWndParent, char *pcSubWndText) { HWND hWndLianJie = ::FindWindowExA(_hWndParent, NULL, "Button", pcSubWndText); //printf("FindSubBtn01 : 0x%08X\n", hWndLianJie); return hWndLianJie; } HWND g_hWndLianJie = 0; BOOL CALLBACK EnumChildProc(HWND _hWndChild, LPARAM _lParam) { char bufText[512] = {0}; ::GetWindowTextA(_hWndChild, bufText, sizeof(bufText)); //printf("\t%s\n", bufText); if (0 == strcmp((char*)_lParam, bufText)) { //printf("\t\t==\n"); g_hWndLianJie = _hWndChild; return false; } return true; } // 找窗口"加速精灵 v2.6"下的,窗口标题为"连 接"的按钮 - 方式(2) HWND FindSubBtn02(HWND _hWndParent, char *pcSubWndText) { EnumChildWindows(_hWndParent, EnumChildProc, (LPARAM)pcSubWndText); return g_hWndLianJie; } void MoveMouseZ(int _iX, int _iY) { // 新的 坐标点 (_iX, _iY) // 屏幕分辨率 int iX = 1366; int iY = 768; // 乘数(为什么要乘以这个?暂时不知...) int iZ = 65536; //Sleep(2000); ::mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, 0, 0, 0, 0); //Sleep(1000); ::mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, _iX * iZ / iX, _iY * iZ / iY, 0, 0); } void PrintLocalTime() { //获取当地的时间。 SYSTEMTIME stLocal; ::GetLocalTime(&stLocal); //显示时间的间隔。 printf("%04u%02u%02u %02u:%02u:%02u:%u \n", stLocal.wYear, stLocal.wMonth, stLocal.wDay, stLocal.wHour, stLocal.wMinute, stLocal.wSecond, stLocal.wMilliseconds); }
2、
相关文章推荐
- [置顶] extjs mvc分层代码
- js基础回顾-对象数组篇
- JavaScript实现样式表的简单切换
- JS基础
- 浅谈javascript函数节流
- js 正在表达式 总结
- 使用javascript为网页增加夜间模式
- 深入理解javascript之this
- JSON与XML的区别比较(转)
- Angular Js 控制器
- Json数据格式全解析
- 实验说明JSP中include指令和include动作指令的区别
- javaScript标题栏滚动
- js面向对象总结(一)
- angular js的坑
- 汤姆大叔6道javascript思考题
- JavaScript
- javascript(5)原型链(Evernote)
- javascript(3、4)module模式、立执行函数(Evernote)
- javascript笔记(2)(Evernote)