21 September, 2013

Robot Programming in Java

Robot class:

This class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations.


Using the class to generate input events differs from posting events to the AWT event queue or AWT components in that the events are generated in the platform's native input queue. For example, Robot.mouseMove will actually move the mouse cursor instead of just generating mouse move events.

More about Robot class Click Here:

Example of Robot class:

I have created simple example for Robot class using KeyBoard Events:

Just Follow this Step:
  • Copy/Paste whole code in Notepad or any Editor.
  • Save with named "JavaRobotExample.java"
  • Run it
  • You may ask for Editor name to run in your computer for e.g. notepad, wordpad, winword etc. whatever you can write in Run window.
  • press Enter, now don't touch keyboard or mouse and just wait for while Running... Typing... Saving...
Have fun ;) 


import java.awt.AWTException;
import java.awt.Robot;
//import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.Scanner;

public class JavaRobotExample
{
Robot robot = new Robot();
Scanner scanner;
public static void main(String[] args) throws AWTException
{
new JavaRobotExample();
}

public JavaRobotExample() throws AWTException
{

scanner = new Scanner(System.in);

String get;

System.out.print("\nEnter Program Name to Run In Your Computer... :- ");
get = scanner.next();

robot.setAutoDelay(50);
robot.setAutoWaitForIdle(true);

robot.delay(100);
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.delay(500);
type("R");
robot.delay(500);
robot.keyRelease(KeyEvent.VK_WINDOWS);

robot.delay(500);
type(get);
robot.delay(1000);
type(KeyEvent.VK_ENTER);

robot.delay(5000);

type("Hello to everyone...!!");

type(KeyEvent.VK_ENTER);
robot.delay(50);
type(KeyEvent.VK_ENTER);

robot.delay(100);
type("This is a Robot Class Presentation in JAVA...!!!");
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);

robot.delay(100);
type("Created By - Pratik Butani- MCA");
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);
robot.delay(100);

type("- Android Developer at Kevalam Software");
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);

robot.delay(100);
type("Contact No.- 88 66 22 45 46");
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);
type("Thank You..!!!");

robot.delay(500);
robot.keyPress(KeyEvent.VK_CONTROL);

type("s");
robot.keyRelease(KeyEvent.VK_CONTROL);

robot.delay(1000);
type("pratik");
robot.delay(500);
type(KeyEvent.VK_ENTER);

robot.delay(1000);
type("y");        
robot.delay(1000);

robot.delay(1000);
type(KeyEvent.VK_ALT);
robot.delay(1000);
type("f");
robot.delay(1000);
type("x");

type("n");
System.exit(0);
}

private void type(int i)
{
robot.delay(50);
robot.keyPress(i);
robot.keyRelease(i);
}

private void type(String s)
{
byte[] bytes = s.getBytes();
for (byte b : bytes)
{
int code = b;
// keycode only handles [A-Z] (which is ASCII decimal [65-90])
if (code > 96 && code < 123) code = code - 32;
robot.delay(40);
robot.keyPress(code);
robot.keyRelease(code);
}
}
}

Have Fun :D

Thank you...

04 September, 2013

101 Most Useful Websites and WebApps

The Most Useful Websites and Web Apps

  1. screenr.com – record movies of your desktop and send them straight to YouTube.
  2. ctrlq.org/screenshots – for capturing screenshots of web pages on mobile and desktops.
  3. goo.gl – shorten long URLs and convert URLs into QR codes.
  4. unfurlr.come – find the original URL that’s hiding behind a short URL.
  5. qClock – find the local time of a city using a Google Map.
  6. copypastecharacter.com – copy special characters that aren’t on your keyboard.
  7. postpost.com – a better search engine for twitter.
  8. lovelycharts.com – create flowcharts, network diagrams, sitemaps, etc.
  9. iconfinder.com – the best place to find icons of all sizes.
  10. office.com – download templates, clipart and images for your Office documents.
  11. followupthen.com – the easiest way to setup email reminders.
  12. jotti.org – scan any suspicious file or email attachment for viruses.
  13. wolframalpha.com – gets answers directly without searching   – see more wolfram tips.
  14. printwhatyoulike.com – print web pages without the clutter.
  15. joliprint.com – reformats news articles and blog content as a newspaper.
  16. ctrql.org/rss – a search engine for RSS feeds.
  17. e.ggtimer.com – a simple online timer for your daily needs.
  18. coralcdn.org – if a site is down due to heavy traffic, try accessing it through coral CDN.
  19. random.org – pick random numbers, flip coins, and more.
  20. pdfescape.com – lets you can quickly edit PDFs in the browser itself.
  21. viewer.zoho.com – Preview PDFs and Presentations directly in the browser.
  22. tubemogul.com – simultaneously upload videos to YouTube and other video sites.
  23. ctrlq.org/dictation – online voice recognition in the browser itself.
  24. scr.im – share you email address online without worrying about spam.
  25. spypig.com – now get read receipts for your email.
  26. sizeasy.com – visualize and compare the size of any product.
  27. myfonts.com/WhatTheFont – quickly determine the font name from an image.
  28. google.com/webfonts – a good collection of open source fonts.
  29. regex.info – find data hidden in your photographs – see more EXIF tools.
  30. livestream.com – broadcast events live over the web, including your desktop screen.