Results 1 to 6 of 6

Thread: Weird Handle help

  1. #1
    ChimpFace9000
    Guest

    Post

    Ok im making an app to go with netzero that will send messages to the ad bar so it will bot kick you off the net. Ive got it to where i can send the message, then the default web browser opens. Now i need to automaticly close that newly opened browser. Any ideas?

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Do they always have something the same in the title bar? Like "Netzero Add" or something?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3
    Guest
    Nope, its different with every add. Is there some way to get the newest window that has opened?

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Hmm you could keep a list of all the current window handles when your app starts, then with a timer continue to check for handles that is not part of the previous list, then send it your message when it finds one.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5
    Guest
    How do i get a list of all the window handles?

  6. #6
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Here but its going to be in MFC, but I am sure you can weed that stuff out. It is right now set to search for every window with "Instant Message", just set it to be "" instead.

    Code:
    BOOL CALLBACK CFindWindows::SearchFor(HWND hWnd, LPARAM lParam)
    {
    	char strBuffer[MAX_PATH];	//Buffer To Hold The Window Title
    	CString strComp;			//The String The Holds The String To Find (Instant Message)
    	CString strFound;			//Holds The Buffer String To Allow Searching
    	int ret = 0;
    
    	::GetWindowText(hWnd,strBuffer,MAX_PATH);	//Gets Window Title On Each Enum
    	
    	strFound = strBuffer;			//Gets The Buffer String To Allow CString Searching
    
    	if (strFound == "")				//If The String Is Empty Quit Function
    		return true;
    
    	strComp = "Instant Message";	//Sets The Search String
    	ret = strFound.Find(strComp,0);	//Search For The Search String
    
    	if (!(ret == -1))				//If Search String Is Found
    	{
    		CFindWindows::InArray(hWnd);
    	}
    
    	return true;
    }
    
    void CFindWindows::StartFind()
    {
    
    	CSendMessages tmp;
    
    	if (tmp.CheckTextOut() == true)					//Insure That Message Text Is There
    		::EnumWindows(SearchFor,(LPARAM)this);		//Enum Every Window
    
    }
    
    bool CFindWindows::InArray(HWND hWnd)
    {
    
    	int ret;						//Used To Hold The Array Size
    	int i;							//Used For The For Loop
    	bool Found = false;				//Used To Check If The Window Already Exists
    	
    	ret = PreWindows.GetSize();		//Gets Array Size
    
    	if (ret == 0)					//If Array = 0
    	{
    		PreWindows.Add(hWnd);		//Add To The Array
    		Found = true;				//Keep From Adding Again
    
    		CSendMessages tmp;			//Sets tmp To CSendMessages Class
    		
    		tmp.MsgOut(hWnd);			//Runs The MsgOut Function
    	}
    	else
    	{
    		for (i=0; i < ret; i++)			//Searchs The Array To Insure There Is No Repeating
    		{
    			if (PreWindows[i] == hWnd)
    			{
    				Found = true;
    			}
    		}
    	}
    
    	if (Found == false)
    	{
    		PreWindows.Add(hWnd);
    
    		CSendMessages tmp;
    
    		tmp.MsgOut(hWnd);
    	}
    
    	return true;
    
    }
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width