~ubuntu-branches/ubuntu/utopic/sikuli/utopic

« back to all changes in this revision

Viewing changes to sikuli-script/src/main/java/org/sikuli/script/Env.java

  • Committer: Bazaar Package Importer
  • Author(s): Gilles Filippini
  • Date: 2011-04-16 00:23:53 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110416002353-cn79cto3c03z5jx1
Tags: 1.0~x~rc2-dfsg1-1
* New upstream release:
  + Redesigned user interface for Sikuli-IDE
  + Support for extensions for Sikuli Script

* debian/control, debian/copyright:
  The package is now maintained by the Debian Java maintainers Team

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
 
12
12
public class Env {
 
13
   final static String SikuliVersion = "X-1.0rc2";
 
14
 
13
15
   public static Location getMouseLocation() throws HeadlessException{
14
16
      Point loc = MouseInfo.getPointerInfo().getLocation();
15
17
      return new Location(loc.x, loc.y);
55
57
            return content.getTransferData(DataFlavor.stringFlavor).toString();
56
58
      }
57
59
      catch(UnsupportedFlavorException e){
58
 
         System.out.println("UnsupportedFlavorException: " + content);
 
60
         Debug.error("UnsupportedFlavorException: " + content);
59
61
      }
60
62
      catch(IOException e){
61
63
         e.printStackTrace();
70
72
         case WINDOWS:   return pkg+"Win32Util";
71
73
         case LINUX:     return pkg+"LinuxUtil";
72
74
         default:
73
 
            System.err.println("Warning: Sikuli doesn't fully support your OS.");
 
75
            Debug.error("Warning: Sikuli doesn't fully support your OS.");
74
76
            return pkg+"DummyUtil";
75
77
      }
76
78
   }
77
79
 
78
80
   static OSUtil _osUtil = null;
79
 
   static OSUtil getOSUtil(){
 
81
   public static OSUtil getOSUtil(){
80
82
      if(_osUtil == null){
81
83
         try{
82
84
            Class c = Class.forName(getOSUtilClass());
90
92
      return _osUtil;
91
93
   }
92
94
 
 
95
   static boolean isLockOn(char key){
 
96
      Toolkit tk = Toolkit.getDefaultToolkit();
 
97
      switch(key){
 
98
         case '\ue025': return tk.getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);
 
99
         case '\ue027': return tk.getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
 
100
         case '\ue03B': return tk.getLockingKeyState(KeyEvent.VK_NUM_LOCK);
 
101
         default:
 
102
            return false;
 
103
      }
 
104
   }
 
105
 
93
106
   static int getHotkeyModifier(){
94
107
      if(getOS() == OS.MAC)
95
108
         return KeyEvent.VK_META;
96
109
      else
97
110
         return KeyEvent.VK_CONTROL;
98
111
   }
 
112
 
 
113
   static String getSikuliDataPath(){
 
114
      String home, sikuliPath;
 
115
      if(isWindows()){
 
116
         home = System.getenv("APPDATA");  
 
117
         sikuliPath = "Sikuli";
 
118
      }
 
119
      else if(isMac()){
 
120
         home = System.getProperty("user.home") + 
 
121
                "/Library/Application Support";
 
122
         sikuliPath = "Sikuli";
 
123
      }
 
124
      else{
 
125
         home = System.getProperty("user.home");
 
126
         sikuliPath = ".sikuli";
 
127
      }
 
128
      File fHome = new File(home, sikuliPath);
 
129
      return fHome.getAbsolutePath();
 
130
   }
 
131
 
 
132
   static String getSikuliVersion(){
 
133
      return SikuliVersion;
 
134
   }
 
135
 
99
136
}