自动登录linux服务器,自动输入用户名和密码

#include
#include

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
HWND ParenthWnd;
HWND ButtonHWnd;

HWND EditHwnd;

ShellExecute(NULL,"open","D:\\Program Files\\teraterm\\ttermpro.exe",NULL,NULL,SW_SHOWNORMAL);

Sleep(1000);

ParenthWnd = FindWindow(NULL,TEXT("Tera Term: New connection"));
if(NULL == ParenthWnd)
{
MessageBox(NULL,TEXT("Cant't find term"),NULL,MB_OK);
}


ButtonHWnd = FindWindowEx(ParenthWnd,NULL,"Button","OK"); 
if(NULL == ButtonHWnd)
{
MessageBox(NULL,TEXT("Cant't find button"),NULL,MB_OK);
}


SendMessage(ButtonHWnd, BM_CLICK , 0, 0);


Sleep(1000);


ParenthWnd = FindWindow(NULL,TEXT("SSH Authentication"));
if(NULL == ParenthWnd)
{
MessageBox(NULL,TEXT("Cant't find SSH"),NULL,MB_OK);
}

EditHwnd = FindWindowEx(ParenthWnd,NULL,"Edit",""); 
if(NULL == EditHwnd)
{
MessageBox(NULL,TEXT("Cant't find Edit"),NULL,MB_OK);
}


SendMessage(EditHwnd, WM_SETTEXT , 0, (LPARAM)"abc");


EditHwnd = FindWindowEx(ParenthWnd,EditHwnd,"Edit",""); 
if(NULL == EditHwnd)
{
MessageBox(NULL,TEXT("Cant't find Edit"),NULL,MB_OK);
}


SendMessage(EditHwnd, WM_SETTEXT , 0, (LPARAM)"123");


ButtonHWnd = FindWindowEx(ParenthWnd,NULL,"Button","OK"); 
if(NULL == ButtonHWnd)
{
MessageBox(NULL,TEXT("Cant't find button"),NULL,MB_OK);
}


SendMessage(ButtonHWnd, BM_CLICK , 0, 0);
return 0;
}

你可能感兴趣的:(自动登录linux服务器,自动输入用户名和密码)