I need help to make something run faster!

Discussion in 'Programming General' started by SuF, Dec 26, 2007.

I need help to make something run faster!
  1. Unread #1 - Dec 26, 2007 at 5:17 PM
  2. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    I need help to make something run faster!

    Having a long time I finally was able to make a program that tells you the colors of every pixel on my screen. (I was doing this is trouble shoot it so I could figure stuff out and stuff. Gunna change it some to use in bots if I get it to run faster)

    I have 1440 by 900 pixels which is 1,296,000 pixels on my screen. My program takes 1:37 minutes to display all the pixels. (I got dual core and Niv. GFo. 8600.)

    Thats much to damned long. :/

    I wrote this in simple code and it took like 2 hours to make it so that it accualy did the whole screen not just to top row or from corner to corner. If someone could help me make this run faster I would be very happy.

    Code:
    import java.awt.*;
    
    
    
    
    public class test 
    
    
    
    {
    	static boolean con = true;
    	static boolean cony = true;
    	static boolean conx = true;
    	public static void main(String[] args) throws Exception 
    	{
    		
    		Robot auto = new Robot();
    		{	
    		
    			int x = 0;
    			int y = 0;
    			int r = 1;
    			int x2 = 1440;
    			int y2 = 900;
    			
    				while(cony) 
    				{
    					if (y < y2)
    						{
    							x = 0;
    							conx = true;
    							while(conx)
    							{
    								if (x < x2)
    									{
    							
    										Color pxcolor = auto.getPixelColor(x,y);
    										System.out.println("" + pxcolor + r);
    										x ++;
    										r ++;
    										
    		
    									}
    								else if (x > x2)
    									{
    										conx = false;
    										y ++;	
    									}
    								else
    									{
    										conx = false;
    										y ++;
    								
    									}
    						
    						
    							}
    						}
    		
    					else if (y > y2)
    						{
    							
    						cony = false;
    						
    						}
    					else
    						{
    							cony = false;
    						}
    					
    				}
    			
    		}
    
    	}	
    }	
    
    Don't tell me anything about objects and shit... I was making something simple this time and will probelly use objects when I accualy make some sort of bot. :/
     
  3. Unread #2 - Dec 27, 2007 at 4:00 PM
  4. Varreon
    Joined:
    Nov 23, 2007
    Posts:
    59
    Referrals:
    0
    Sythe Gold:
    0

    Varreon Member

    I need help to make something run faster!

    I don't know java very well, but why don't you just do this:

    Code:
    for(int x=0;x<=1440;x++){
        for(int y=0;y<=900;y++){
            Color pxcolor=auto.getPixelColor(x,y);
            System.out.println(""+pxcolor);
        }
    }
    
    not sure what r was for in your code, but I doubt you need it. Good Luck.
     
  5. Unread #3 - Dec 27, 2007 at 6:30 PM
  6. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    I need help to make something run faster!

    r was a counter to see how many pixels it had looked at.... It kept only doing the top line of my screen for some reason... Lemme look at yours XD
     
  7. Unread #4 - Dec 27, 2007 at 6:33 PM
  8. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    I need help to make something run faster!

    Yes yours works... My first one looked just like yours.... I dunno why it didn't work. :/ It still takes forever though...


    EDIT: it takes less time but it froze the second time I ran it =P


    EDIT 2: took 40 seconds igunna try my programy thingy

    EDIT 3: mine took 43 this time =P the rs window has about.. 300,000 pixels which takes about.... less than 10 seconds.... on slower machines it will probelly take more than 20 :/ i got vista which also may slow it down some XD
     
  9. Unread #5 - Dec 27, 2007 at 7:23 PM
  10. Varreon
    Joined:
    Nov 23, 2007
    Posts:
    59
    Referrals:
    0
    Sythe Gold:
    0

    Varreon Member

    I need help to make something run faster!

    And you dont have to scan your entire screen, just the runescape client. Its also faster to get a screenshot in java, then iterate through that.
     
  11. Unread #6 - Dec 27, 2007 at 8:09 PM
  12. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    I need help to make something run faster!

    yes I know... do you know how i could get my program to find out where the rs screen is on the persons comp screen? that would help me a lot :/


    also how to make a hotkey that would stop my auto clicker i am working on :/
     
  13. Unread #7 - Dec 27, 2007 at 9:52 PM
  14. Varreon
    Joined:
    Nov 23, 2007
    Posts:
    59
    Referrals:
    0
    Sythe Gold:
    0

    Varreon Member

    I need help to make something run faster!

    In c++, theres a function called FindWindow, then you use the handle from that and get the window position. As long as you can get your cursor's position, I'd do the following:
    Create A Button; When Clicked, wait 2 seconds; Get Cursor Position. Then have this your starting x and y. The user would have to move the mouse to the upper left of the runescape client.
     
  15. Unread #8 - Dec 28, 2007 at 8:40 AM
  16. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    I need help to make something run faster!

    or press a butten then click the top corner :/ then start it would seem like a better idea but thanks XD
     
< VB 6 Download | New need help. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site