64,654
社区成员
发帖
与我相关
我的任务
分享
class EVECharacter{//角色参数类
public:
CString Name;
HWND Hwnd;
bool Threadrun;
int NumInSelection;
CString HostileMode;
CString BattleMode;
int HPMode;
int WarpKM;
int AntiBan;
int AtSafePoint;
CString RepairMode;
int Friendly_Corp;
int Friendly_Aillance;
int Friendly_Execellent;
int Friendly_Good;
CString ComplexSelect;
CString RepairType;
CString ChargeSetting;
CString SalvageBookmark;
CString DronesAttack;
CString KeepInRange;
int ComplexDelay;
CString AfterBurner;
CString BusyReturn;
CString Refouced;
CString EasyMode;
CString RiskSetting;
int SystemFont;
int beep;
int Gotosafe;
int SelfCheck;
EVECharacter()
{
AtSafePoint=1;
beep=0;
Gotosafe=0;
Hwnd=0;
Name="";
Threadrun=false;
NumInSelection=-1;
HostileMode="";
BattleMode="";
HPMode=0;
WarpKM=0;
AntiBan=0;
SelfCheck=0;
RepairMode="";
int Friendly_Corp=0;
int Friendly_Aillance=0;
int Friendly_Execellent=0;
int Friendly_Good=0;
ComplexSelect="";
RepairType="";
ChargeSetting="";
SalvageBookmark="";
DronesAttack="";
KeepInRange="";
ComplexDelay=0;
AfterBurner="";
BusyReturn="";
Refouced="";
EasyMode="";
SystemFont=0;
RiskSetting="";
}
int EmptyData()
{
AtSafePoint=1;
beep=0;
Gotosafe=0;
Threadrun=false;
NumInSelection=-1;
HostileMode="";
BattleMode="";
HPMode=0;
WarpKM=0;
AntiBan=0;
SelfCheck=0;
RepairMode="";
int Friendly_Corp=0;
int Friendly_Aillance=0;
int Friendly_Execellent=0;
int Friendly_Good=0;
ComplexSelect="";
RepairType="";
ChargeSetting="";
SalvageBookmark="";
DronesAttack="";
KeepInRange="";
ComplexDelay=0;
AfterBurner="";
BusyReturn="";
Refouced="";
EasyMode="";
SystemFont=0;
RiskSetting="";
return 0;
}
};
DWORD WINAPI TR_Char(PVOID lpParameter)
{
while(1)
{
Sleep(2000);
int *p = (int *)lpParameter;
HWND Hwnd;
Hwnd=GetDesktopWindow();
Hwnd=GetWindow(Hwnd,GW_CHILD);
char WindowTitle[MAX_PATH] = {0};
PSTR EVETitle = "EVE -";
HWND list;
int Arrlocation=0;
int WindowTitleLen=0;
int TimesOfWhile=0;
int userselection=-1;
int findstr;
int listcount=-1;
list=GetDlgItem(hDlgWnd,IDC_CHARLIST);
listcount=SendMessage(list,LB_GETCOUNT,NULL,NULL);//取得列表框条目数
CString Charactername;
for(int i=0;i<=100;i++)//刷新角色数组
EVECharHwndNow[i]=0;
while(Hwnd)//遍历句柄
{
/*WindowTitleLen=GetWindowTextLength(Hwnd);
WindowTitle = (PSTR) VirtualAlloc((LPVOID) NULL,
(DWORD) (WindowTitleLen + 1), MEM_COMMIT,
PAGE_READWRITE); */
GetWindowText(Hwnd,WindowTitle,MAX_PATH);
if(strstr(WindowTitle,EVETitle))
{
if(FindCharInArr(Hwnd)==101)//检查角色是否已经在数组中
{
Arrlocation=FindEmptyArrLocation();
Charactername=WindowTitle;
Charactername=Charactername.Mid(6);
EVEChar[Arrlocation].Name=Charactername;
EVEChar[Arrlocation].Hwnd=Hwnd;
SendMessage(list,LB_ADDSTRING ,NULL,(LPARAM)Charactername.GetBuffer());
}
EVECharHwndNow[TimesOfWhile++]=Hwnd;//将角色句柄添加到临时数组
}
Hwnd=GetWindow(Hwnd,GW_HWNDNEXT);
}
if(listcount==0)//如果列表框没有角色
{
findstr=SendMessage(list,LB_FINDSTRING,0,(LPARAM)"没有检测到角色..");//没有角色则显示没有角色
if(findstr!=-1)
{
}
else
{
SendMessage(list,LB_ADDSTRING,NULL,(LPARAM)("没有检测到角色.."));
}
}
else
{
findstr=SendMessage(list,LB_FINDSTRING,0,(LPARAM)"没有检测到角色..");
if((findstr!=-1 && listcount>1))
{
SendMessage(list,LB_DELETESTRING,findstr,NULL);
}
}
DelAllUnexistChar();//删除已经下线的角色
}
return 0;
}
int FindCharInArr(HWND Hwnd)
{
for(int i=0;i<=100;i++)
{
if(EVEChar[i].Hwnd==Hwnd)
return i;
}
return 101;
}
int FindEmptyArrLocation()
{
for(int i=0;i<=100;i++)
{
if(!EVEChar[i].Hwnd)
return i;
}
}
int DelAllUnexistChar(){
for(int i=0;i<=100;i++){
bool characterfind=false;
for(int j=0;j<=100;j++)
{
if(EVEChar[i].Hwnd==EVECharHwndNow[j])
{
characterfind=true;
break;
}
}
if(characterfind!=true)//标记该角色为无效
{
Addlog(EVEChar[i].Name,"角色已下线,清除角色.");
// EVEChar[i].Hwnd=0;
// EVEChar[i].Threadrun = false;
//EVEChar[i].EmptyData();
int findstr;
int listcount=-1;
HWND list;
list=GetDlgItem(hDlgWnd,IDC_CHARLIST);
findstr=SendMessage(list,LB_FINDSTRING,0,(LPARAM)EVEChar[i].Name.GetBuffer());
SendMessage(list,LB_DELETESTRING,findstr,NULL);
}
}
return 0;
}