您的位置:首页 > Web前端 > JavaScript

jsjl_for_ubuntu12.04

2016-03-13 18:03 543 查看
1、

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、
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: