DarkMinion-vL Posted On 05/08/01 06:57PM
Here is some sample code for you C++ users who want to make a little edit window to go along with your console bot kind of like the one NBBot uses. I made this into a thread, you can use it by utilizing the following code:
_beginthread(EditWindowThread, 0, NULL);
void EditWindowThread(void *param)
{
HWND EditWnd = CreateWindowEx(WS_EX_ACCEPTFILES, "EDIT", "", ES_MULTILINE | WS_VISIBLE , 0, 565, 250, 47, GetWindow(), 0, (HINSTANCE)GetModuleHandle(0), 0);
MSG msg;
PAINTSTRUCT PaintSt;
HDC hDc;
while(GetMessage(&msg;, EditWnd, 0, 0) == TRUE)
{
TranslateMessage(&msg;);
switch(msg.message)
{
case WM_PAINT:
hDc = BeginPaint(EditWnd, &PaintSt;);
EndPaint(EditWnd, &PaintSt;);
break;
case WM_CREATE:
ShowWindow(EditWnd, SW_SHOW);
break;
case WM_DESTROY:
DestroyWindow(EditWnd);
break;
case WM_CHAR:
if(msg.wParam == 0x0D)
{
char txt[256] = "";
GetWindowText(EditWnd, (LPTSTR)txt, 256);
SetWindowText(EditWnd, "");
send(s, txt, strlen(txt), 0); // or whatever you use to send
}
break;
}
DispatchMessage(&msg;);
UpdateWindow(EditWnd);
}
_endthread();
}
and you also need this function:
HWND GetWindow(void) {
HWND result = 0;
char buffer[1024] = "";
GetConsoleTitle(buffer, sizeof(buffer) - 1);
SetConsoleTitle("finder");
while(result == 0)
result = FindWindow(0, "finder");
SetConsoleTitle(buffer);
return result;
}
hope you find it useful - DM
Message Edited on 05/09/01 04:52PM by DarkMinion-vL |