Sáb Oct 02, 2010 4:46 pm
- Código:
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <winsock.h>
#pragma comment(lib, "wsock32.lib")
#pragma warning (disable:4786)
#define WIDTH 340
#define HEIGHT 330
#define bListConvos 1
#define bButtonstart 2
#define bButtonRefresh 3
#define bTextSpam 4
#define bLabelTimes 5
#define bTextTimes 6
#define bLabelError 7
#define BUFFERNAME 160
#define BUFFERMED 512
#define COPYBUFFERMED 1024
#define BUFFERLARGE 1024
HFONT Font1 = CreateFont(16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,0,0,0,0,"Arial");
HWND hListConvos,hButtonstart,hButtonRefresh,hTextSpam,hLabelTimes,hTextTimes,hLabelE
rrors;
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,WPARAM wParam, LPARAM lParam);
int setClipboard(char cSetText[COPYBUFFERMED])
{
int iRet = 0;
iRet = OpenClipboard(NULL);
if(!iRet){
return 0;
}
EmptyClipboard();
char* cText = (char*) malloc(sizeof(char) * COPYBUFFERMED);
strncpy(cText,cSetText,COPYBUFFERMED);
SetClipboardData(CF_TEXT,cText);
free(cText);
CloseClipboard();
return 1;
}
void setText(HWND hWnd,char* pcText)
{
SendMessage(hWnd,WM_SETTEXT,NULL,(LPARAM)pcText);
}
void getText(HWND hWnd,char cBuffer[], int iSize)
{
SendMessage(hWnd,WM_GETTEXT,(WPARAM)iSize,(LPARAM)cBuffer);
}
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
MSG msgMessage;
HWND hWnd;
WNDCLASSEX wndClass;
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProcedure;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(101));
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = "Basic";
wndClass.hInstance = hInstance;
wndClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(101));
if((RegisterClassEx(&wndClass)) == NULL){
return 0;
}
if((hWnd = CreateWindow("Basic","MSN",WS_SYSMENU,CW_USEDEFAULT,CW_USEDEFAULT,WIDTH+10,HEIGHT,NULL,NULL,hInstance,
NULL)) == NULL){
return 0;
}
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
while(GetMessage(&msgMessage, NULL, 0, 0)){
TranslateMessage(&msgMessage);
DispatchMessage(&msgMessage);
}
return msgMessage.wParam;
}
BOOL CALLBACK spreadMSN(HWND hWnd, LPARAM lParam)
{
char cClassName[BUFFERMED],cWindowName[BUFFERNAME];
HWND hwConvo;
if(!GetClassName(hWnd,cClassName,BUFFERMED)){
return FALSE;
}
if(!strcmp(cClassName,"IMWindowClass")){
if((GetWindowText(hWnd,cWindowName,BUFFERNAME))){
if(strstr(cWindowName," - Conversation")){
SendMessage(hListConvos,LB_ADDSTRING,(WPARAM)0,(LPARAM)cWindowName);
}
}
}
return TRUE;
}
void spamConvos(char* pcConvoName,char* pcMessage,int iTimes)
{
unsigned short x = 0;//Spam loop
HWND hwConvo = FindWindow(NULL,pcConvoName);
if(hwConvo == NULL){
setText(hLabelErrors,"Error, conversation window not found\n");
return;
}
for(x=0; x<iTimes; x++){
SetForegroundWindow(hwConvo);
keybd_event(VK_LCONTROL,0,0,0);
keybd_event(86,0,0,0);
keybd_event(VK_LCONTROL,0,KEYEVENTF_KEYUP,0);
keybd_event(86,0,KEYEVENTF_KEYUP,0);
keybd_event(13,0,0,0);
keybd_event(13,0,KEYEVENTF_KEYUP,0);
}
Sleep(100);
return;
}
void startSpam()
{
char cWindowName[BUFFERNAME],cSpamText[BUFFERMED],char cSpamTimes[3];
unsigned short int i=0; //Convo's
unsigned short int iItem=0, iItems=0,iSpamTimes=0; //Current item, Total items, loop amount
getText(hTextSpam,cSpamText,BUFFERMED);
if(setClipboard(cSpamText)){
iItems = SendMessage(hListConvos,(UINT) LB_GETCOUNT,0,0);
for(i=0; i<iItems; i++){
int iSelected = SendMessage(hListConvos,(UINT)LB_GETSEL,(WPARAM)i,0);
if(iSelected){
SendMessage(hListConvos,(UINT)LB_GETTEXT,(WPARAM)i,(LPARAM)cWindowName);
getText(hTextTimes,cSpamTimes,3);
iSpamTimes = atoi(cSpamTimes);
spamConvos(cWindowName,cSpamText,iSpamTimes);
}
}
}
else{
setText(hLabelErrors,"Error, clipboard set failed\n");
}
}
void addConvos()
{
unsigned short int iItem=0,iItems=0;
iItems = SendMessage(hListConvos,(UINT) LB_GETCOUNT,0,0);
iItem = iItems + 1;
do{
iItem--;
SendMessage(hListConvos,(UINT) LB_DELETESTRING,(WPARAM)iItem,0);
}while(iItem);
EnumWindows(spreadMSN,0);
}
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam)
{
switch(Msg){
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
case WM_CREATE: //x y width height
hListConvos = CreateWindowEx(0,"ListBox",0,LBS_STANDARD | WS_CHILD | WS_VISIBLE |LBS_EXTENDEDSEL |LBS_SORT | WS_VSCROLL | WS_TABSTOP,0, 0, WIDTH, 150,hWnd,(HMENU)bListConvos,0,NULL);
hButtonstart = CreateWindowEx(0,"Button","Spam",WS_VISIBLE | WS_CHILD,0, 150, 70, 18,hWnd,(HMENU)bButtonstart,0,NULL);
hButtonRefresh = CreateWindowEx(0,"Button","Refresh convos",WS_VISIBLE | WS_CHILD,230, 150, 110, 18,hWnd,(HMENU)bButtonRefresh,0,NULL);
hTextSpam = CreateWindowEx(0,"Edit",NULL,WS_VISIBLE | WS_CHILD | WS_BORDER | ES_MULTILINE,0, 170, WIDTH, 100,hWnd,(HMENU)bTextSpam,0,NULL);
hTextTimes = CreateWindowEx(0,"Edit",NULL,WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL,80, 150, 30, 18,hWnd,(HMENU)hTextTimes,0,NULL);
hLabelTimes = CreateWindowEx(0,"Edit",NULL,WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL,120, 150, 70, 18,hWnd,0,0,NULL);
hLabelErrors = CreateWindowEx(0,"Edit",NULL,WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL,0, 280, WIDTH, 20,hWnd,0,0,NULL);
SendMessage(hLabelErrors,EM_SETREADONLY,(WPARAM)TRUE,(LPARAM)TRUE);
SendMessage(hLabelTimes,EM_SETREADONLY,(WPARAM)TRUE,(LPARAM)TRUE);
setText(hTextSpam," < Enter a message here > ");
setText(hLabelTimes," times");
setText(hTextTimes,"50");
EnumWindows(spreadMSN,0);
case WM_COMMAND:
switch(LOWORD(wParam)){
case bButtonstart:
setText(hButtonstart,"Spamming");
EnableWindow(hButtonstart,FALSE);
startSpam();
Sleep(100);
setText(hButtonstart,"Spam");
EnableWindow(hButtonstart,TRUE);
break;
case bButtonRefresh:
addConvos();
break;
default:
break;
}
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}