简单登录脚本测试

0x001 易语言模拟了一个登录框

展示:

360截图20180117002924646.jpg


0x002 使用win32 模拟登录测试

全部代码:



// 20180117_01.cpp : Defines the entry point for the application.
//WTWindow

#include "stdafx.h"
#include <windows.h>

BOOL isStart=FALSE;
//登录
void QQLogin()
{
	TCHAR szTitle[MAX_PATH]={0};
	HWND hwnd = FindWindow("WTWindow","QQ2018");
	if(hwnd)
	{
		//找到编辑框_用户名78
		HWND hEditUser = GetDlgItem(hwnd,0x78);
		SendMessage(hEditUser,WM_SETTEXT,0,(LPARAM)"111111");
		//找到编辑框_密码8C
		HWND hEditPass = GetDlgItem(hwnd,0x8C);
		SendMessage(hEditPass,WM_SETTEXT,0,(LPARAM)"111111");
		//点击登录96
		HWND hButtonLogin=GetDlgItem(hwnd,0x96);
		
		Sleep(3000);
		SendMessage(hButtonLogin,WM_LBUTTONDOWN,0,0);
		SendMessage(hButtonLogin,WM_LBUTTONUP,0,0);

	}else{
		MessageBox(0,"没有找到QQ","失败",MB_OK);
	}

	return ;
}

//最前列
void SetQQFirst()
{
	TCHAR szTitle[MAX_PATH]={0};
	HWND hwnd = FindWindow("WTWindow","QQ2018");

	if(hwnd!=NULL)
	{	
		typedef void (WINAPI* PSWITCHTOTHISWINDOW)(HWND,BOOL);
		PSWITCHTOTHISWINDOW SwitchToThisWindow;
		HMODULE  hUser32 = LoadLibrary("user32.dll");
		SwitchToThisWindow = (PSWITCHTOTHISWINDOW)GetProcAddress(hUser32,"SwitchToThisWindow");

		//切换窗口
		SwitchToThisWindow(hwnd,TRUE);

		Sleep(1000);
		//SendMessage(hwnd,WM_CLOSE,0,0);

	}else
	{
		MessageBox(NULL,TEXT("窗口没有找到"),TEXT("[ERROR]"),MB_OK);
	}
}


//QQ是否打开
BOOL CALLBACK EnumWindowsProc(
							  HWND hwnd,      // handle to parent window
							  LPARAM lParam   // application-defined value
)
{
	TCHAR szTitle[MAX_PATH]={0};
	GetWindowText(hwnd,szTitle,MAX_PATH);
	//MessageBox(NULL,szTitle,"[窗口]",MB_OK);
	if(strcmp(szTitle,"QQ2018")==0)
	{
		//MessageBox(0,"360软件打开了","【检测】",MB_OK);
		isStart = TRUE;
		return FALSE;
	}

	return TRUE;

}

//"用户名 采集 V1.0"
void isQQStart()
{
	EnumWindows(EnumWindowsProc,NULL);
}


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	
	//创建进程
	STARTUPINFO si={0};
	si.cb = sizeof(STARTUPINFO);
	PROCESS_INFORMATION pi;

	TCHAR szBuffer[]=TEXT("c://QQ.exe");

	CreateProcess(szBuffer,
		NULL,
		NULL,
		NULL,
		FALSE,
		CREATE_NEW_CONSOLE,
		NULL,
		NULL,
		&si,
		&pi);
	
	//检测进程是否存在
	Sleep(2000);
	isQQStart();

	Sleep(3000);
	if(isStart)
	{
	
		//最前列
		SetQQFirst();

		//登录
		QQLogin();
	}else{
		MessageBox(0,"没有打开QQ进程","[错误信息]",0);
	}

	return 0;
}



0x003 总结


开始使用了:

mouse_event

keybd_event

出错的概率很高,

建议使用:


SendMessage
并且, 脚本记住一定要控制时间, 如果你不给时间间隔, 很容易出错[教训!!!]




原文链接: 简单登录脚本测试 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-373.html )

发表评论

0则评论给“简单登录脚本测试”