Find Runescape Window

Discussion in 'Programming General' started by Govind, Nov 6, 2010.

Find Runescape Window
  1. Unread #1 - Nov 6, 2010 at 6:45 PM
  2. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Find Runescape Window

    Declare the following global variables:
    int count = 0, count2 = 0; HWND frame;

    The first two functions are to count the number of windows present and compare it to the count variable for the actual finding of Runescape and decide when to finish.

    hFinished is a static (label) control that displays the result to the user.

    These functions are intended to be used as such:

    1. First, call EnumWindows in main with CountAllWindows as the callback function
    2. Then, call EnumWindows in main with TopLevelSearch as the callback function

    Manually write your own code for checking dimensions and stuff. You can change the hFinished stuff to your own notification that RS isn't running, of course.
    Code:
    bool GetSecondDepth(HWND parent)
    {
            frame = FindWindowEx(parent,NULL,"SunAwtCanvas",NULL);
            if(frame) return true;
            return false;
    }
    BOOL CALLBACK EnumChildCount(HWND hWnd, LPARAM lParam)
    {
    	count++;
    	return TRUE;
    }
    
    BOOL CALLBACK CountAllWindows(HWND hWnd, LPARAM lParam)
    {
    	count++;
    	EnumChildWindows(hWnd, EnumChildCount, 0);
    	return TRUE;
    }
    
    BOOL CALLBACK FindRSApplet(HWND hWnd, LPARAM lParam)
    {
    	count2++;
    	TCHAR *RScmp = (TCHAR*)malloc(1000);
    	GetClassName(hWnd,RScmp,1000);
    	//wchar_t hBuf[100];
    	if(wcscmp(RScmp,TEXT("SunAwtCanvas"))==0)
    	{
    		if(GetSecondDepth(hWnd))
    		{
    			return FALSE;
    		}
    		return TRUE;
    	}
    	
    	if(count2==count)
    	{
    		//MessageBox(0,TEXT("You either have no browser open, or RS is not open in your browser."),TEXT("Problem!"),MB_OK|MB_ICONINFORMATION);
    		SetWindowText(hFinished,TEXT("RS Not Found.  Make sure RS is set to Min Quality and Fixed size."));
    		return FALSE;
    	}
    	return TRUE;
    }
    
    BOOL CALLBACK TopLevelSearch(HWND hWnd, LPARAM lParam)
    {
    	count2++;
    	if(count2==count)
    	{
    		//MessageBox(0,TEXT("You either have no browser open, or RS is not open in your browser."),TEXT("Problem!"),MB_OK|MB_ICONINFORMATION);
    		SetWindowText(hFinished,TEXT("RS Not Found.  Make sure RS is set to Min Quality and Fixed size."));
    		return FALSE;
    	}
    	EnumChildWindows(hWnd,FindRSApplet,0);
    	
    	return TRUE;
    }
     
< Factorials | Java Homework Services >

Users viewing this thread
1 guest


 
 
Adblock breaks this site