Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    I want this code to scrape a specific region on my screen (based on coordinates) and then hash it based on the hash function. And print the hashoutcome to my screen but somehow nothing shows up on my screen, any thoughts on what I did wrong? I called the region that I wanted to scrape "region"

    scrape.rar

    I compiled the code with Netbeans and it created a *.jar file that I attached.

    package scrape;
    /**
     *
     * @author Jim
     */
    import java.awt.Robot;
     
    public class Scrape {
     
        public static void main(String[] args) {
            // TODO code application logic here
        }
     
        protected int x;
        protected int y;
        private int region;
        private final int xofs = 3;
        private final int yofs = 3;
     
        public Scrape(int x, int y) {
     
            this.x = x;
    	this.y = y;
        }
     
        public int hash(Robot myRobot, int x, int y, int width, int height) {
     
            int sum = 0;
     
    	sum = width*height;
    	for (int i = 0; i < width; ++i)
    		for (int j = 0; j < height; ++j)
    			sum = (sum << 5 ^ sum >> 27)
    					^ (myRobot.getPixelColor(xofs + x + i + this.x, yofs + y + j + this.y).getRGB() & 0x00ffffff);
    	return sum;
        }
     
        public int doScrape(Robot myRobot) {
     
            int sum = 0;
     
                region = hash(myRobot, 157, 133, 8, 14);
                System.out.println("Region 1       : "+region+" : "+getData(region)+"\r\n");
                sum += (int) region;
                return sum;
        }
     
        private static String getData(int rgbSum) {
            //compiled code
            throw new RuntimeException("Compiled Code");
        }
     
        public String region(Robot myRobot) {
     
            return getData(region);
        }
     
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    You don't have anything in your main method, so this program won't do anything.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    What should I put in my main method? Sorry I'm really a total noob with java and got this code from a friend and I cut/pasted it a bit.

    Do you mean like this?

    package scrape;
    /**
     *
     * @author Jim
     */
    import java.awt.Robot;
     
    public class Scrape {
     
        public static void main(String[] args) {
     
       protected int x;
        protected int y;
        private int region;
        private final int xofs = 3;
        private final int yofs = 3;
     
        public Scrape(int x, int y) {
     
            this.x = x;
    	this.y = y;
        }
     
        public int hash(Robot myRobot, int x, int y, int width, int height) {
     
            int sum = 0;
     
    	sum = width*height;
    	for (int i = 0; i < width; ++i)
    		for (int j = 0; j < height; ++j)
    			sum = (sum << 5 ^ sum >> 27)
    					^ (myRobot.getPixelColor(xofs + x + i + this.x, yofs + y + j + this.y).getRGB() & 0x00ffffff);
    	return sum;
        }
     
        public int doScrape(Robot myRobot) {
     
            int sum = 0;
     
                region = hash(myRobot, 157, 133, 8, 14);
                System.out.println("Region 1       : "+region+" : "+getData(region)+"\r\n");
                sum += (int) region;
                return sum;
        }
     
        private static String getData(int rgbSum) {
            //compiled code
            throw new RuntimeException("Compiled Code");
        }
     
        public String region(Robot myRobot) {
     
            return getData(region);
        }
           // TODO code application logic here
        }
     
     
    }
    Last edited by javanoobish; August 30th, 2011 at 07:50 AM.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    Quote Originally Posted by javanoobish View Post
    What should I put in my main method? Sorry I'm really a total noob with java and got this code from a friend and I cut/pasted it a bit.

    Do you mean like this?
    No, no I do not. What happened when you tried to compile that? If you're really that lost, I highly suggest starting at the basic tutorials. Trying to hack at copy-pasted code will only give everybody headaches.

    Start here: The Java™ Tutorials
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    All went well when I wanted to compile it, and when I want to run it with java -jar <filename> then it just runs but I see nothing happening. Could you please help me get this little thing working, that's all I need, just that it outputs the value on my screen, so i can use that value in the rest by just changing 10digits in certain spots.

    I tried to rent a coder for this but 99% show no interest or say they can't do it, and one guy came up with like $500,- to make this little script work :S

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    Quote Originally Posted by javanoobish View Post
    All went well when I wanted to compile it, and when I want to run it with java -jar <filename> then it just runs but I see nothing happening.
    I meant, what happened when you compiled your "edited" code. I only asked because you should have tested that before asking what it would do. I wouldn't expect your original program to do anything.


    Quote Originally Posted by javanoobish View Post
    Could you please help me get this little thing working, that's all I need, just that it outputs the value on my screen, so i can use that value in the rest by just changing 10digits in certain spots.
    I'm not really in the market of doing other people's work for them. If you want help, start at the basic tutorials (did you even look at them before rejecting them? At least look at these two: Lesson: A Closer Look at the "Hello World!" Application (The Java™ Tutorials > Getting Started) and Trail: Learning the Java Language (The Java™ Tutorials)

    Quote Originally Posted by javanoobish View Post
    I tried to rent a coder for this but 99% show no interest or say they can't do it, and one guy came up with like $500,- to make this little script work :S
    Just another reason to read through the tutorials yourself.

    If you want help learning, cool, but if not, there's a forum for paid Java projects here you can check out.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    I havent compiled my edited code yet indeed. Will do that in a minute, but like you said you won't expect anything of it.

    I downloaded the ebook Java for Dummys but I'm in a hurry and I really don't understand crap of it. One time it compiles to *.java the other time it compiles to *.class. I can only run this program when it's packed as a *.jar file, it's totally confusing.

    I tried the paid forum , there you can hire people for $0.50 cent a minute, I chattted with 10 people all ready and everyone says: Send me the complete source and I'll take a look at it, well this whole sourced costed my friend thousands of dollars so I don't think he will be happy if I send that to anyone. So I filtered out only the essential parts. I wrote scripts before in AHK/AutoIT so on that front I'm not a total noob. I just don't get this *.java *.class *.svn-base.java and how to construct it all.

    Anyway instead of being able to hire the people right away for $0.50/minute, it seems more that they like to steal my complete sourcecode. Thats why I posted in on this forum.

    I'll pay anyone $100,- who makes this little program work and output the hashcode on my screen or in a txt file!

  8. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    Sigh. Working through the basic tutorials would have taken you about an hour. But I'll move this to the Paid Java Projects forum for you.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    Junior Member
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    I already posted it there, thanks though! Maybe some day I will read into this stuff, but now i'm extremely busy and already read tons of basic stuff and still don't get it. Am I really that stupid? lol, must admit I didn't read much more then the hello world part though!

  10. #10
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Scraping region (based on screen coords) and outputting rgbSumvalue to screen

    Is this still active? I can solve this this no problems at all. $100 seems fair. If you need proof I can pull this off - my image processing tutorial is not far off the mark - http://www.javaprogrammingforums.com...-tutorial.html

Similar Threads

  1. how to set my frame in the middle of the screen
    By chronoz13 in forum AWT / Java Swing
    Replies: 3
    Last Post: February 10th, 2012, 08:13 AM
  2. Showing an Image on screen
    By doobybug in forum AWT / Java Swing
    Replies: 1
    Last Post: May 10th, 2011, 07:49 AM
  3. Screen Resolution
    By bartonn in forum Member Introductions
    Replies: 2
    Last Post: December 16th, 2010, 06:49 AM
  4. How to print results to screen
    By NinjaLink in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 19th, 2010, 01:46 PM
  5. clear screen.
    By chronoz13 in forum Java Theory & Questions
    Replies: 10
    Last Post: December 5th, 2009, 07:27 AM