如果大家玩过传奇,那么肯定知道外挂巴,尤其是脱机外挂比较好使。
近日,本人研究了利用传神私服代理,风雪验证器和热血传神脱机外挂得使用,如果用户需要挂机得话,必须自己一步一步来,很是麻烦。
因此,我编写了这个自动登陆的外挂。
主要用倒的是FindwindowEx和SendMessage,很简单的。
说一下功能:
1。自动运行,自动登陆
2。自动添加私服
3。自动执行脚本,解决小退招宝宝问题
4。解决异常窗口弹出
目前对云龙传奇有效。
不说了,贴代码。
/////////////////////////////////////////////////////////////.h////////////////////////////////////////////////////
class CMirDlg : public CDialog
{
// Construction
public:
CMirDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CMirDlg)
enum { IDD = IDD_MIR_DIALOG };
CString m_PSW;
CString m_User;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMirDlg)
public:
virtual BOOL DestroyWindow();
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CMirDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButtonBegin();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnButtonSet();
afx_msg void OnButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
BOOL CheckAllProgram();
void RegisterProgram();
void ActionScript();
BOOL SearchStr(LPCSTR lpBuf,int count,LPCSTR lpstr);
BOOL GetScriptState();
void ReadInfoFromRegister();
void WriteInfoToRegister();
BOOL FindHotPanel();
BOOL IsLoginOK();
BOOL FindRichEdit();
BOOL FindHotCSpnLogin();
BOOL FindHotCSDlg();
BOOL Find51pywgButton();
BOOL Find51pywgDlg();
BOOL FindWgButton();
BOOL FindWgComBox();
BOOL FindWgDlg();
BOOL CreateWgDlg(LPCSTR lpAppPath,PROCESS_INFORMATION *pi);
HWND hWgDlg; //˽·þ¾ä±ú
HWND hWgComBox; //˽·þÏÂÀÁбí
HWND hWgButton; //˽·þ¿ªÊ¼°´Å¥
HWND h51pywg; //51pywg¾ä±ú
HWND h51pywgButton; //51pywg°´Å¥¾ä±ú
HWND hHotWnd; //ÈÈѪ¾ä±ú
HWND hHotLoadButton; //ÈÈѪµÇ½¾ä±ú
HWND hHotEdit; //ÈÈѪ±à¼¾ä±ú
HWND hHotUserEdit;
HWND hHotPSWEdit;
HWND hHotPanel;
PROCESS_INFORMATION mypi[3];
int nState;
int iReLoadTimeOut;
DWORD ulTimeOut;
char apppath[256];
BOOL bLoadState;
CString strwgPath;
CString str51PywgPath;
CString strHotcsPath;
CString strwgName;
UINT uPort;
BOOL bAutoRun;
BOOL bAutoLoad;
BOOL bAutoSave;
BYTE byteIPAddress[4];
int iWinState;
};
*********************cpp*********************************
// mirDlg.cpp : implementation file
//
#include "stdafx.h"
#include "mir.h"
#include "mirDlg.h"
#include "DialogSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
static BOOL CALLBACK enumProc(HWND hwnd, LPARAM lParam);
char szSection[]="ÍÑ»úÍâ¹ÒÖ®×Ô¶¯°æ";
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMirDlg dialog
CMirDlg::CMirDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMirDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMirDlg)
m_PSW = _T("");
m_User = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMirDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMirDlg)
DDX_Text(pDX, IDC_EDIT_PSW, m_PSW);
DDV_MaxChars(pDX, m_PSW, 20);
DDX_Text(pDX, IDC_EDIT_USER, m_User);
DDV_MaxChars(pDX, m_User, 20);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMirDlg, CDialog)
//{{AFX_MSG_MAP(CMirDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_BEGIN, OnButtonBegin)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON_SET, OnButtonSet)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMirDlg message handlers
BOOL CMirDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
int i,len;
if(!RegisterHotKey(m_hWnd,0xA002,MOD_CONTROL|MOD_ALT,VK_F7))
{
//DWORD error=GetLastError();
return FALSE;
}
iWinState=0;
GetModuleFileName(AfxGetInstanceHandle(),apppath,256);
len=strlen(apppath);
i=1;
while(len>0)
{
if(apppath[len-i]=='\\')
{
apppath[len-i]='\0';
break;
}
i++;
}
ulTimeOut=0;
nState=0;
hWgDlg=NULL; //˽·þ¾ä±ú
hWgComBox=NULL; //˽·þÏÂÀÁбí
hWgButton=NULL; //˽·þ¿ªÊ¼°´Å¥
h51pywg=NULL; //51pywg¾ä±ú
h51pywgButton=NULL; //51pywg°´Å¥¾ä±ú
hHotWnd=NULL; //ÈÈѪ¾ä±ú
hHotLoadButton=NULL; //ÈÈѪµÇ½¾ä±ú
hHotEdit=NULL; //ÈÈѪ±à¼¾ä±ú
hHotUserEdit=NULL;
hHotPSWEdit=NULL;
hHotPanel=NULL;
SetTimer(1,1000,NULL);
iReLoadTimeOut=0;
bLoadState=0;
ReadInfoFromRegister();
if(!bAutoSave)
{
m_User="";
m_PSW="";
bAutoLoad=FALSE;
WriteInfoToRegister();
}
else
{
if(bAutoLoad)
{
UpdateData(FALSE);
OnButtonBegin();
}
}
RegisterProgram();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CMirDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMirDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMirDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMirDlg::OnButtonBegin()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
bLoadState=!bLoadState;
if(bLoadState)
{
GetDlgItem(IDC_BUTTON_BEGIN)->SetWindowText("×¢Ïú");
GetDlgItem(IDC_EDIT_USER)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT_PSW)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_SET)->EnableWindow(FALSE);
}
else
{
GetDlgItem(IDC_BUTTON_BEGIN)->SetWindowText("怫");
GetDlgItem(IDC_EDIT_USER)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT_PSW)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_SET)->EnableWindow(TRUE);
}
if(bLoadState) nState=1;
else
{
::SendMessage(hHotWnd,WM_CLOSE,0,0);
//::SendMessage(h51pywg,WM_QUIT,0,0);
//::SendMessage(h51pywg,WM_CLOSE,0,0);
::SendMessage(hWgDlg,WM_CLOSE,0,0);
::TerminateProcess(mypi[1].hProcess,0);
}
// WriteInfoToRegister();
}
BOOL CMirDlg::CreateWgDlg(LPCSTR lpAppPath,PROCESS_INFORMATION *pi)
{
CString str;
STARTUPINFO startInfo;
startInfo.cb = sizeof(STARTUPINFO);
startInfo.lpReserved = NULL;
startInfo.lpTitle = "";
startInfo.lpDesktop = NULL;
startInfo.dwX = 0;
startInfo.dwY = 0;
startInfo.dwXSize = 0;
startInfo.dwYSize = 0;
startInfo.dwXCountChars = 0;
startInfo.dwYCountChars = 0;
startInfo.dwFlags = STARTF_USESTDHANDLES;
startInfo.wShowWindow = 0; //SW_SHOWDEFAULT;
startInfo.lpReserved2 = NULL;
startInfo.cbReserved2 = 0;
startInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
startInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
startInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
if(CreateProcess(lpAppPath,NULL,NULL,NULL,0,0,NULL,NULL,&startInfo,pi))
{
return TRUE;
}
return FALSE;
}
BOOL CMirDlg::FindWgDlg()
{
hWgDlg=NULL;
hWgDlg=FindWindowEx(NULL,hWgDlg,"ThunderRT6FormDC","£¨·½Ð°棩----´«Éñ˽·þÍâ¹Ò");
if(hWgDlg)
{
return TRUE;
}
return FALSE;
}
BOOL CMirDlg::FindWgComBox()
{
if(hWgDlg==NULL)return FALSE;
unsigned short int nID;
hWgComBox=NULL;
hWgComBox=FindWindowEx(hWgDlg,hWgComBox,"ThunderRT6ComboBox",NULL);
if(hWgComBox)
{
::SendMessage(hWgComBox,CB_SETCURSEL,0,0);
nID=::GetDlgCtrlID(hWgComBox);
::SendMessage(hWgDlg, WM_COMMAND,MAKEWPARAM(nID,CBN_SELCHANGE),(LPARAM)hWgComBox);
return TRUE;
}
return FALSE;
}
BOOL CMirDlg::FindWgButton()
{
if(hWgDlg==NULL)return FALSE;
unsigned short int nID;
hWgButton=NULL;
hWgButton=FindWindowEx(hWgDlg,hWgButton,"ThunderRT6CommandButton","¿ªÊ¼(&S)");
if(hWgComBox)
{
nID=::GetDlgCtrlID(hWgButton);
::PostMessage(hWgDlg, WM_COMMAND,nID,(LPARAM)hWgButton);
return TRUE;
}
return FALSE;
}
void CMirDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
switch(nState)
{
case 0:
break;
case 1:
if(CreateWgDlg(strwgPath,&mypi[0]))
{
nState=2;
}
break;
case 2:
if(FindWgDlg())
{
nState=3;
}
break;
case 3:
if(FindWgComBox())
{
nState=4;
}
break;
case 4:
if(FindWgButton())
{
::ShowWindow(hWgDlg,SW_HIDE);
nState=16;
}
break;
case 5:
if(CreateWgDlg(str51PywgPath,&mypi[1]))
{
nState=6;
}
break;
case 6:
if(Find51pywgDlg())
{
nState=7;
}
break;
case 7:
if(Find51pywgButton())
{
nState=8;
//::ShowWindow(h51pywg,SW_HIDE);
::SendMessage(h51pywg,WM_SYSCOMMAND,SC_MINIMIZE,0);
}
break;
case 8:
if(CreateWgDlg(strHotcsPath,&mypi[2]))
{
nState=9;
}
break;
case 9:
if(FindHotCSDlg())
{
nState=10;
}
break;
case 10:
if(FindRichEdit())
{
nState=11;
}
break;
case 11:
ulTimeOut+=1000;
if(FindHotCSpnLogin())
{
nState=12;
}
break;
case 12:
ulTimeOut+=1000;
iReLoadTimeOut+=1000;
if(iReLoadTimeOut>=15000)
{
iReLoadTimeOut=0;
if(IsLoginOK())
{
ulTimeOut=0;
nState=13;
}
else
nState=11;
}
if(ulTimeOut>=2*60*1000)
{
//nState=1;
//::SendMessage(hHotWnd,WM_CLOSE,0,0);
//::SendMessage(h51pywg,WM_CLOSE,0,0);
//::SendMessage(hWgDlg,WM_CLOSE,0,0);
OnButtonBegin();
OnButtonBegin();
}
break;
case 13:
if(FindHotPanel())
{
nState=14;
ulTimeOut=0;
}
break;
case 14:
iReLoadTimeOut+=1000;
if(iReLoadTimeOut>=10000)
{
iReLoadTimeOut=0;
if(GetScriptState())
{
ActionScript();
nState=15;
}
else
{
ulTimeOut++;
}
}
if(ulTimeOut>=1)
{
if(CheckAllProgram())
{
OnButtonBegin();
}
ulTimeOut=0;
}
break;
case 15:
ulTimeOut=0;
ActionScript();
// ::ShowWindow(hHotWnd,SW_HIDE);
nState=14;
break;
case 16:
EnumWindows(enumProc,0);
nState=5;
break;
}
CDialog::OnTimer(nIDEvent);
}
BOOL CMirDlg::Find51pywgDlg()
{
h51pywg=NULL;
h51pywg=FindWindowEx(NULL,h51pywg,"TFRMMAIN","·çÑ©51pywgÑéÖ¤Æ÷1.02°æ");
//h51pywg=FindWindowEx(NULL,h51pywg,"TForm1","·çÑ©´«ÉñÑéÖ¤Æ÷1.10°æ");
if(h51pywg)
{
return TRUE;
}
return FALSE;
}
BOOL CMirDlg::Find51pywgButton()
{
if(h51pywg==NULL)return FALSE;
int nID;
h51pywgButton=NULL;
h51pywgButton=FindWindowEx(h51pywg,h51pywgButton,"TBUTTON","´«Éñ");
if(h51pywgButton)
{
nID=::GetDlgCtrlID(h51pywgButton);
::SendMessage(h51pywg,WM_COMMAND,nID,(LPARAM)h51pywgButton);
//::SendMessage(h51pywgButton,WM_KEYDOWN,13,0);
::ShowWindow(h51pywgButton,SW_HIDE);
::ShowWindow(h51pywgButton,SW_SHOW);
return TRUE;
}
return FALSE;
}
BOOL CMirDlg::FindHotCSDlg()
{
hHotWnd=NULL;
hHotWnd=FindWindowEx(NULL,hHotWnd,"TFrmmain","V 1.0");
if(hHotWnd)
{
return TRUE;
}
return FALSE;
}
BOOL CMirDlg::FindHotCSpnLogin()
{
HWND hwnd1,hwnd2;
char szBuf[256];
int nIdFirst;
int i;
hwnd1=NULL;
hwnd2=NULL;
hwnd1=FindWindowEx(hHotWnd,hwnd1,"TPanel","pnlLogin");
if(hwnd1)
{
hwnd2=::GetWindow(hwnd1,GW_CHILD);
if(hwnd2 == NULL || !::IsWindow(hwnd2)) return FALSE;
i=0;
nIdFirst=::GetDlgCtrlID(hwnd2);
do
{
::GetClassName(hwnd2,szBuf,256);
if(hwnd2)
{
if(::IsWindow(hwnd2))
{
i++;
::GetWindowText(hwnd2,szBuf,256);
switch(i)
{
case 2:
hHotLoadButton=hwnd2;
break;
case 4:
hHotPSWEdit=hwnd2;
break;
case 5:
hHotUserEdit=hwnd2;
break;
}
}
}
hwnd2=::GetWindow(hwnd2,GW_HWNDNEXT);
if(!::IsWindow(hwnd2) || hwnd2==NULL)
break;
}while(nIdFirst != ::GetDlgCtrlID(hwnd2));
//***********************
if(hHotLoadButton==NULL)return FALSE;
if(hHotPSWEdit==NULL)return FALSE;
if(hHotUserEdit==NULL)return FALSE;
char buf1[20],buf2[20];
strcpy(buf1,m_User);
strcpy(buf2,m_PSW);
::SendMessage(hHotUserEdit,WM_SETTEXT,0,LPARAM(buf1));
::SendMessage(hHotPSWEdit,WM_SETTEXT,0,LPARAM(buf2));
if(::BringWindowToTop(hHotWnd))
{
::SendMessage(hHotLoadButton,WM_SETFOCUS,NULL,0);
::SendMessage(hHotLoadButton,WM_KEYDOWN,VK_SPACE,0);
::SendMessage(hHotLoadButton,WM_KEYUP,VK_SPACE,0);
return TRUE;
}
return TRUE;
}
return FALSE;
}
BOOL CMirDlg::FindRichEdit()
{
if(hHotEdit!=NULL)return TRUE;
if(hHotWnd==NULL)return FALSE;
char szBuf[256];
char buf[1024];
int nIdFirst1,nIdFirst2;
HWND hwnd1,hwnd2;
hwnd1=NULL;
hwnd2=NULL;
hwnd1=::GetWindow(hHotWnd,GW_CHILD);
if(hwnd1 == NULL || !::IsWindow(hwnd1)) return FALSE;
nIdFirst1=::GetDlgCtrlID(hwnd1);
do
{
::GetClassName(hwnd1,szBuf,256);
::GetWindowText(hwnd1,buf,100);
if(strcmp(szBuf,"TPanel")==0)
{
hwnd2=::GetWindow(hwnd1,GW_CHILD);
if(hwnd2||::IsWindow(hwnd2))
{
nIdFirst2=::GetDlgCtrlID(hwnd2);
do
{
::GetClassName(hwnd2,szBuf,256);
::GetWindowText(hwnd2,buf,1024);
if(strcmp(szBuf,"TRichEdit")==0)
{
hHotEdit=hwnd2;
return TRUE;
}
hwnd2=::GetWindow(hwnd2,GW_HWNDNEXT);
if(!::IsWindow(hwnd2) || hwnd2==NULL) break;
}while(nIdFirst2 != ::GetDlgCtrlID(hwnd2));
}
}
hwnd1=::GetWindow(hwnd1,GW_HWNDNEXT);
if(!::IsWindow(hwnd1) || hwnd1==NULL) break;
}while(nIdFirst1 != ::GetDlgCtrlID(hwnd1));
return FALSE;
}
BOOL CMirDlg::IsLoginOK()
{
if(hHotEdit==NULL)return FALSE;
char buf[2048];
int len;
EnumWindows(enumProc,0);
::SendMessage(hHotWnd,WM_SETFOCUS,WPARAM(hHotEdit),0);
memset(buf,0,2048);
::SendMessage(hHotEdit,WM_GETTEXT,2048,LPARAM(buf));
len=strlen(buf);
::SendMessage(hHotEdit,WM_SETTEXT,0,LPARAM(""));
return SearchStr(buf,len,"»¶Ó¹âÁÙÔÆÁú´«Ææ");
}
static BOOL CALLBACK enumProc(HWND hwnd, LPARAM lParam)
{
if (hwnd == NULL) return FALSE;
HWND hwnd1;
if (::IsWindow(hwnd) && ::IsWindowVisible(hwnd))
{
TCHAR szCap[255] = {0};
TCHAR buf[255]={0};
::GetClassName(hwnd, szCap, 255);
::GetWindowText(hwnd,buf,255);
if(strcmp(buf,"51pywg´«Éñ")==0)
{
hwnd1=NULL;
hwnd1=::FindWindowEx(hwnd,hwnd1,"Button","È·¶¨");
::GetWindowText(hwnd1,szCap,255);
int nID=::GetDlgCtrlID(hwnd1);
::SendMessage(hwnd,WM_COMMAND,nID,LPARAM(hwnd1));
return TRUE;
}
if(strcmp(szCap,"#32770")==0)
{
hwnd1=NULL;
hwnd1=::FindWindowEx(hwnd,hwnd1,"Static","´«Éñ˽·þ´úÀíÒÑ×¼±¸ºÃ£¬Çë°´¡°È·¶¨¡±°´Å¥ºó½øÈë´«Éñ");
if(hwnd1==NULL)return TRUE;
hwnd1=NULL;
hwnd1=::FindWindowEx(hwnd,hwnd1,"Button","È·¶¨");
int nID=::GetDlgCtrlID(hwnd1);
::SendMessage(hwnd,WM_COMMAND,nID,LPARAM(hwnd1));
return TRUE;
}
}
return TRUE;
}
BOOL CMirDlg::FindHotPanel()
{
if(hHotWnd==NULL)return FALSE;
char szBuf[256];
int nIdFirst;
CRect rect;
hHotPanel=NULL;
hHotPanel=::GetWindow(hHotWnd,GW_CHILD);
if(hHotPanel||::IsWindow(hHotPanel))
{
nIdFirst=::GetDlgCtrlID(hHotPanel);
do
{
::GetClassName(hHotPanel,szBuf,256);
if(strcmp(szBuf,"TPanel")==0)
{
::GetWindowRect(hHotPanel,&rect);
if(rect.Width()==64)
{
ActionScript();
return TRUE;
}
}
hHotPanel=::GetWindow(hHotPanel,GW_HWNDNEXT);
if(!::IsWindow(hHotPanel) || hHotPanel==NULL) break;
}while(nIdFirst != ::GetDlgCtrlID(hHotPanel));
}
return FALSE;
}
void CMirDlg::OnButtonSet()
{
// TODO: Add your control notification handler code here
CDialogSet myDlg;
UpdateData(TRUE);
myDlg.lpAppPath=apppath;
myDlg.m_atuo=bAutoLoad;
myDlg.m_save=bAutoSave;
myDlg.m_run=bAutoRun;
myDlg.m_sfname=strwgName;
myDlg.m_SF_Path=strwgPath;
myDlg.m_CheckPath=str51PywgPath;
myDlg.m_pywgPath=strHotcsPath;
myDlg.m_Port=uPort;
memcpy(myDlg.byteIP,byteIPAddress,4);
if(myDlg.DoModal()==IDOK)
{
bAutoLoad=myDlg.m_atuo;
bAutoSave=myDlg.m_save;
bAutoRun=myDlg.m_run;
strwgName=myDlg.m_sfname;
strwgPath=myDlg.m_SF_Path;
str51PywgPath=myDlg.m_CheckPath;
strHotcsPath=myDlg.m_pywgPath;
uPort=myDlg.m_Port;
memcpy(byteIPAddress,myDlg.byteIP,4);
RegisterProgram();
WriteInfoToRegister();
}
UpdateData(FALSE);
}
void CMirDlg::WriteInfoToRegister()
{
CString str;
str.Format("%03d.%03d.%03d.%03d",
byteIPAddress[0],
byteIPAddress[1],
byteIPAddress[2],
byteIPAddress[3]);
AfxGetApp()->WriteProfileString(szSection,"´«Éñ˽·þ",strwgPath);
AfxGetApp()->WriteProfileString(szSection,"·çÑ©ÑéÖ¤Æ÷",str51PywgPath);
AfxGetApp()->WriteProfileString(szSection,"51pywg´«Éñ",strHotcsPath);
AfxGetApp()->WriteProfileString(szSection,"̞",m_User);
AfxGetApp()->WriteProfileString(szSection,"ÃÜÂë",m_PSW);
AfxGetApp()->WriteProfileString(szSection,"˽·þÃû³Æ",strwgName);
AfxGetApp()->WriteProfileString(szSection,"IPµØÖ·",str);
AfxGetApp()->WriteProfileInt(szSection,"¶Ë¿Ú",uPort);
AfxGetApp()->WriteProfileInt(szSection,"Æô¶¯ÔËÐÐ",bAutoRun);
AfxGetApp()->WriteProfileInt(szSection,"Õʺű£´æ",bAutoSave);
AfxGetApp()->WriteProfileInt(szSection,"×Ô¶¯µÇ½",bAutoLoad);
}
void CMirDlg::ReadInfoFromRegister()
{
CString str;
strwgPath=AfxGetApp()->GetProfileString(szSection,"´«Éñ˽·þ",apppath);
str51PywgPath=AfxGetApp()->GetProfileString(szSection,"·çÑ©ÑéÖ¤Æ÷",apppath);
strHotcsPath=AfxGetApp()->GetProfileString(szSection,"51pywg´«Éñ",apppath);
m_User=AfxGetApp()->GetProfileString(szSection,"̞","");
m_PSW=AfxGetApp()->GetProfileString(szSection,"ÃÜÂë","");
strwgName=AfxGetApp()->GetProfileString(szSection,"˽·þÃû³Æ","ÔÆÁú´«Ææ");
str=AfxGetApp()->GetProfileString(szSection,"IPµØÖ·","219.136.248.138");
uPort=AfxGetApp()->GetProfileInt(szSection,"¶Ë¿Ú",7077);
bAutoRun=AfxGetApp()->GetProfileInt(szSection,"Æô¶¯ÔËÐÐ",0);
bAutoSave=AfxGetApp()->GetProfileInt(szSection,"Õʺű£´æ",0);
bAutoLoad=AfxGetApp()->GetProfileInt(szSection,"×Ô¶¯µÇ½",0);
sscanf(str,"%d.%d.%d.%d",
&byteIPAddress[0],
&byteIPAddress[1],
&byteIPAddress[2],
&byteIPAddress[3]);
}
BOOL CMirDlg::GetScriptState()
{
if(hHotPanel==NULL)return FALSE;
char buf[2048];
int len;
EnumWindows(enumProc,0);
memset(buf,0,1024);
::SendMessage(hHotWnd,WM_SETFOCUS,WPARAM(hHotEdit),0);
::SendMessage(hHotEdit,WM_GETTEXT,2048,LPARAM(buf));
::SendMessage(hHotEdit,WM_SETTEXT,0,LPARAM(""));
len=strlen(buf);
return SearchStr(buf,len,"»¶Ó¹âÁÙÔÆÁú´«Ææ");
}
BOOL CMirDlg::SearchStr(LPCSTR lpBuf, int count, LPCSTR lpstr)
{
int i,j;
int len;
len=strlen(lpstr);
j=len;
for(i=count-1;i>=0;i--)
{
if(lpstr[j-1]==lpBuf[i])
{
j--;
if(j==0)
{
return TRUE;
}
}
else
j=len;
}
return FALSE;
}
void CMirDlg::ActionScript()
{
// ::ShowWindow(hHotWnd,SW_SHOW);
// ::SendMessage(hHotWnd,WM_SYSCOMMAND,SC_MAXIMIZE,0);
// ::BringWindowToTop(hHotWnd);
//OnButton1();
SendMessage(WM_COMMAND,MAKELPARAM(IDC_BUTTON1,BN_CLICKED),LPARAM(GetDlgItem(IDC_BUTTON1)->m_hWnd));
// ::BringWindowToTop(hHotWnd);
// ::SendMessage(hHotWnd,WM_SYSCOMMAND,SC_MAXIMIZE,0);
SetCursorPos(34,312);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
void CMirDlg::OnButton1()
{
// TODO: Add your control notification handler code here
FindHotCSDlg();
// ::SendMessage(hHotWnd,SC_RESTORE,SC_MAXIMIZE,0);
::ShowWindow(hHotWnd,SW_SHOW);
::SendMessage(hHotWnd,WM_SYSCOMMAND,SC_MAXIMIZE,0);
::BringWindowToTop(hHotWnd);
}
void CMirDlg::RegisterProgram()
{
HKEY hKEY;
char CurrentPath[MAX_PATH];
long ret;
LPSTR FileName;
DWORD type=REG_SZ;
DWORD size=MAX_PATH;
if(!bAutoRun)return;
LPCTSTR Rgspath="Software\\Microsoft\\Windows\\CurrentVersion\\Run" ;
GetModuleFileName(NULL,CurrentPath,size);
//Open key
ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE,Rgspath,0,KEY_WRITE, &hKEY);
if(ret!=ERROR_SUCCESS)
{
RegCloseKey(hKEY);
return ;
}
//Set Key
FileName = CurrentPath;
ret=RegSetValueEx(hKEY,"System_Funny",NULL,type,(const unsigned char*)FileName,size);
if(ret!=ERROR_SUCCESS)
{
RegCloseKey(hKEY);
return ;
}
RegCloseKey(hKEY);
}
BOOL CMirDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
UnregisterHotKey(NULL,0xA002);
WriteInfoToRegister();
::SendMessage(hHotWnd,WM_CLOSE,0,0);
::SendMessage(hWgDlg,WM_CLOSE,0,0);
::TerminateProcess(mypi[1].hProcess,0);
return CDialog::DestroyWindow();
}
BOOL CMirDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_HOTKEY)
{
if(pMsg->wParam==0xA002)
{
iWinState++;
if(iWinState%2==0)
{
ShowWindow(SW_HIDE);
}
else
{
ShowWindow(SW_SHOW);
}
}
}
char buf[1];
CString str;
str+=buf;
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CMirDlg::CheckAllProgram()
{
HANDLE handle;
handle=NULL;
for(int i=0;i<3;i++)
{
handle=OpenProcess(PROCESS_ALL_ACCESS,TRUE,mypi[i].dwProcessId);
if(handle==NULL)
{
OnButtonBegin();
return TRUE;
}
CloseHandle(handle);
handle=NULL;
}
return FALSE;
}
本文地址:http://com.8s8s.com/it/it27367.htm