Results 1 to 11 of 11
  1. #1
    Mr.abe90 is offline Member
    Join Date
    May 2011
    Posts
    18
    Rep Power
    0

    Default Use robot class to type a string?

    I there a way to have a robot class use key events to type a string of letters.
    like use:
    Java Code:
    robot.keyPress(KeyEvent.VK_L);
    but instead of "KeyEvent" have a string be typed.
    Can a robot only type single letters?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    The Robot can only use the methods that the API states are available to it. But I'll bet a clever programmer like yourself could write methods that would allow a Robot to write Strings. :)

  3. #3
    Mr.abe90 is offline Member
    Join Date
    May 2011
    Posts
    18
    Rep Power
    0

    Default

    I don't quite understand is it possible or not? What methods does the API state are available to it or where can I find them?

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    You should get a copy of the API doc or a link to it so you can read it and not have to ask someone to find it for you.

    Here's a link: Java Platform SE 6

  5. #5
    Mr.abe90 is offline Member
    Join Date
    May 2011
    Posts
    18
    Rep Power
    0

    Default

    So from what I see in the API doc is that using "robot.keyPress" won't really work with more than one character. But I saw something called "toString" but it didn't really go into detail about it. Would this be a possibility for what i am trying to do? would the code look something like:
    Java Code:
    robot.toString(str);
    ????

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,732
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Mr.abe90 View Post
    So from what I see in the API doc is that using "robot.keyPress" won't really work with more than one character. But I saw something called "toString" but it didn't really go into detail about it. Would this be a possibility for what i am trying to do? would the code look something like:
    Java Code:
    robot.toString(str);
    ????
    Use your imagination; programmers need a lot of imagination; if you can call the method once (for a single character) you can call it many times (for a lot of (different) characters) so you can effectively make your Robot type an entire String. If Java had methods for everything don't you think it ended up with a horrible lot of methods? e.g. System.out.printlnIfNotZero( ... ),
    JFrame.setVisibleIfFitsOnScreen( ... ), HashMap.doWhatIHaveInMind( ... ) etc. etc.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Mr.abe90 is offline Member
    Join Date
    May 2011
    Posts
    18
    Rep Power
    0

    Default

    Ok, I realize I can call it many times but in my case my string is over 10000 characters long. So... Ya... Doesn't really work there.

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,732
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Mr.abe90 View Post
    Ok, I realize I can call it many times but in my case my string is over 10000 characters long. So... Ya... Doesn't really work there.
    Do you think those bits will get tired? Is your processor going to fall asleep? If a computer can do something once, it can do it many times.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JosAH View Post
    Do you think those bits will get tired? Is your processor going to fall asleep?
    Shoot mine does! But that only happens when I find a bunch of empty Grolsch and tobacco pouches around it, and know that it must have been up way too late last night partying. I should have never bought a friggin' Dutch computer!

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,732
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Fubarable View Post
    Shoot mine does! But that only happens when I find a bunch of empty Grolsch and tobacco pouches around it, and know that it must have been up way too late last night partying. I should have never bought a friggin' Dutch computer!
    You should've read the manual and have the thing properly configured; this is what I have in its (Dutch) config file:

    Java Code:
    grolsch=uit
    tabak=uit
    feesten=uit
    mooie vrouwen=uit
    kleding=aan
    saai hard werk=aan
    (uit == off, aan == on) I hope this helps.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default

    Quote Originally Posted by Mr.abe90 View Post
    Ok, I realize I can call it many times but in my case my string is over 10000 characters long. So... Ya... Doesn't really work there.
    Use a loop.

Similar Threads

  1. Help with Robot class please
    By davetheant in forum New To Java
    Replies: 2
    Last Post: 01-04-2011, 01:13 PM
  2. Robot class
    By coltragon in forum New To Java
    Replies: 6
    Last Post: 07-12-2010, 06:54 PM
  3. Help with Robot Class
    By protocos in forum Eclipse
    Replies: 11
    Last Post: 10-05-2009, 09:15 PM
  4. Robot Class
    By Jessie Madman in forum New To Java
    Replies: 3
    Last Post: 05-15-2008, 05:13 AM
  5. Robot Class
    By jfredrickson in forum New To Java
    Replies: 2
    Last Post: 07-11-2007, 10:00 AM

Tags for this Thread

Posting Permissions

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