[Help]Returning to WinProc

Posts 1–4 of 4 · Page 1 of 1
[Help]Returning to WinProc
Ok, so i have been trying to solve my problem for a while but without success so now i have come to bother you guys by asking. LOL.


I have made a simple rs bot on a console application, i mean really simple cuz i was really bored so i just made an auto miner. My problem is that i have made it into a win32 applications(window), and whenever i press the start button on my program it goes to the bot function which is outside winproc. The problem is i don't know how to make it return to winproc, when i press the stop button it freezes the whole desktop and i have to force shutdown my computer. Here is my code and I want to know how to make it return to the WinProc from an outside function:

Code:
 #include <windows.h>
#define ID_start 1
#define ID_stop  2
int pixelsearch();
HANDLE thread;
int leftclicker();
void rightclickunloader();
void messages();
int main();
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
HINSTANCE hInst;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT ("HelloWin") ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;
	 hInst = hInstance;
     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL ;
     wndclass.lpszClassName = szAppName ;

     if (!RegisterClass (&wndclass))
     {
          MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
     hwnd = CreateWindow (szAppName,                  // window class name
                          TEXT ("The Hello Program"), // window caption
                          WS_OVERLAPPEDWINDOW,        // window style
                          CW_USEDEFAULT,              // initial x position
                          CW_USEDEFAULT,              // initial y position
                          CW_USEDEFAULT,              // initial x size
                          CW_USEDEFAULT,              // initial y size
                          NULL,                       // parent window handle
                          NULL,                       // window menu handle
                          hInstance,                  // program instance handle
                          NULL) ;                     // creation parameters
     
     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ;
     
     while (GetMessage (&msg, NULL, 0, 0))
     {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     }
     return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     HDC         hdc ;
     PAINTSTRUCT ps ;
     RECT        rect ;
	 TEXTMETRIC tm;
	 static HWND hwndsup, hwndstop;
	 static int cychar, cxchar;
	 
	 SECURITY_ATTRIBUTES sa;
     
	 switch (message)
     {
	 case WM_CREATE:
		
		 hwndsup = CreateWindow("button", "start up instructions",
    WS_BORDER | WS_CHILD | WS_VISIBLE,
    100, 20, 140, 20, hwnd, (HMENU)ID_start, NULL, NULL);
		 hwndstop = CreateWindow("button", "start bot",
    WS_BORDER | WS_CHILD | WS_VISIBLE,
    300, 20, 140, 20, hwnd, (HMENU)ID_stop, NULL, NULL);
		return 0;
	 case WM_COMMAND:
		 switch(wParam){
	 case ID_start:
		
		return 0;
	 case ID_stop:
		 while(wParam != ID_start){
		 thread = CreateThread(0,0,(LPTHREAD_START_ROUTINE)main, 0,0,0);
		 Sleep(3000);
		 PostQuitMessage(0);
		 }
		SuspendThread(thread);
		return 0;
		 }
		return 0;
	 case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
          TextOut(hdc, 0,  1, TEXT("Press Button to start the bot for further instructions."), 56);
          EndPaint(hwnd, &ps);
		 

          return 0 ;
          
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}


DWORD ms;
POINT one;
POINT two;
POINT three;
POINT four;
POINT five;
POINT six;
POINT seven;
int i;
int b;
int c;
int d;
int z;
int main()
{

	messages();
}
void messages()
{
z = 0;
while(z!=8)
{
	
	if(GetAsyncKeyState(VK_NUMPAD1) &1)
{
	GetCursorPos(&one);
	
	z +=1;
}
if(GetAsyncKeyState(VK_NUMPAD2) &1)
{
    GetCursorPos(&two);
	
	z +=1;
}
if(GetAsyncKeyState(VK_NUMPAD3) &1)
{
	GetCursorPos(&three);
	
	z+=1;
}
if(GetAsyncKeyState(VK_RETURN) &1)
{
	z+=1;
	leftclicker();
}
if(GetAsyncKeyState(VK_NUMPAD4) &1)
{
	GetCursorPos(&four);

	z += 1;
	
}
if(GetAsyncKeyState(VK_NUMPAD5) &1)
{
	GetCursorPos(&five);
	
	z +=1;
}
if(GetAsyncKeyState(VK_NUMPAD6) &1)
{
	GetCursorPos(&six);
	
	z += 1;
}
if(GetAsyncKeyState(VK_NUMPAD7) &1)
{
	GetCursorPos(&seven);
	
	z+=1;
 
}

}


}



int leftclicker()
{
	
	while(true)
	{
		if(GetAsyncKeyState(VK_END)&1){FreeConsole(); }
		if(GetAsyncKeyState(VK_INSERT)&1){AllocConsole();}
		if(GetAsyncKeyState(VK_SHIFT) &1)
		{
			MessageBox(NULL, TEXT("BOT STOPPED"), TEXT("STATUS"), MB_OK);
			
			messages();
		}
		if(!GetAsyncKeyState(VK_SHIFT) &1)
		{
			;;
		
	}
		for(c = 0; c!=600; c++){
		for(i = 0; i!=50; i++)
	{
		if(GetAsyncKeyState(VK_END)&1){FreeConsole(); }
		if(GetAsyncKeyState(VK_INSERT)&1){AllocConsole();}
		SetCursorPos(one.x, one.y);
		mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0,0,0,0);
		Sleep(1000);
	if(GetAsyncKeyState(VK_SHIFT) &1){
		MessageBox(NULL, TEXT("BOT Stopped"), TEXT("Bot Status"), MB_OK);
       return 0;
		
		}
	}

	
for (b=0;b!=1;b++)
	{
		SetCursorPos(two.x, two.y);
		mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0,0,0,0);
		Sleep(1000);
		SetCursorPos(three.x, three.y);
		mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0,0,0,0);
		Sleep(2000);
		if(GetAsyncKeyState(VK_SHIFT)){
			MessageBox(NULL, TEXT("BOT STOPPED"), TEXT("Stopped"), MB_OK);
			return 0;
		}
		
}

	}
for(d = 0; d!=1; d++)
{


SetCursorPos(four.x, four.y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,0,0,0,0);
Sleep(1000);
SetCursorPos(five.x, five.y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,0,0,0,0);
Sleep(3000);
SetCursorPos(six.x, six.y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,0,0,0,0);
Sleep(6000);
SetCursorPos(seven.x, seven.y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,0,0,0,0);
Sleep(5000);
rightclickunloader();

}
}
}
void rightclickunloader()
{
	leftclicker();
}
Thanks in advance for your help.
really? no one knows?
please can someone answer it's been two days and this problem has been driving me crazy
i solved my problem, which was really simple actually, NO THANKS TO YOU!!!!!!! lol, jk ,but you can close it now.
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us