1 /* 2 * Copyright (c) 2007, 2017 Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package org.jemmy.interfaces; 27 28 import org.jemmy.action.Action; 29 import org.jemmy.dock.Shortcut; 30 import org.jemmy.env.Environment; 31 import org.jemmy.env.Timeout; 32 33 34 /** 35 * Defines how to simulate keyboard operations. 36 */ 37 public interface Keyboard extends ControlInterface { 38 39 public static final Timeout PUSH = new Timeout("keyboard.push", 100); 40 41 @Shortcut 42 public void pressKey(KeyboardButton key, Modifier... modifiers); 43 44 @Shortcut 45 public void pressKey(KeyboardButton key); 46 47 @Shortcut 48 public void releaseKey(KeyboardButton key, Modifier... modifiers); 49 50 @Shortcut 51 public void releaseKey(KeyboardButton key); 52 53 @Shortcut 54 public void pushKey(Timeout pushTime, KeyboardButton key, Modifier... modifiers); 55 56 @Shortcut 57 public void pushKey(KeyboardButton key, Modifier... modifiers); 58 59 @Shortcut 60 public void pushKey(KeyboardButton key); 61 62 @Shortcut 63 public void typeChar(char keyChar, Timeout pushTime); 64 65 @Shortcut 66 public void typeChar(char keyChar); 67 68 /** 69 * Detaches the implementation so that all actions of it will be ran detached. 70 * @see org.jemmy.action.ActionExecutor#executeDetached(Environment, boolean, Action, Object...) 71 * @return todo document 72 */ 73 public Keyboard detached(); 74 75 /** 76 * Keyboard button interface (i. e. Q, W, ENTER, LEFT, F1, etc.) 77 * created to left the possibility for extention as enums can't be extended 78 */ 79 public static interface KeyboardButton extends Button { 80 81 } 82 83 /** 84 * Keyboard modifier interface (i. e. SHIFT_DOWN_MASK) 85 * created to left the possibility for extention as enums can't be extended 86 */ 87 public static interface KeyboardModifier extends Modifier { 88 89 } 90 91 /** 92 * Keyboard modifiers enum (i. e. SHIFT_DOWN_MASK) 93 * to be used in Keyboard interface methods 94 */ 95 public static enum KeyboardModifiers implements KeyboardModifier { 96 SHIFT_DOWN_MASK, 97 CTRL_DOWN_MASK, 98 ALT_DOWN_MASK, 99 META_DOWN_MASK 100 } 101 102 /** 103 * Keyboard buttons enum (i. e. Q, W, ENTER, LEFT, F1, etc.) 104 * to be used in Keyboard interface methods 105 */ 106 public static enum KeyboardButtons implements KeyboardButton { 107 /** 108 * 109 */ 110 ESCAPE, 111 /** 112 * 113 */ 114 F1, 115 /** 116 * 117 */ 118 F2, 119 /** 120 * 121 */ 122 F3, 123 /** 124 * 125 */ 126 F4, 127 /** 128 * 129 */ 130 F5, 131 /** 132 * 133 */ 134 F6, 135 /** 136 * 137 */ 138 F7, 139 /** 140 * 141 */ 142 F8, 143 /** 144 * 145 */ 146 F9, 147 /** 148 * 149 */ 150 F10, 151 /** 152 * 153 */ 154 F11, 155 /** 156 * 157 */ 158 F12, 159 /** 160 * 161 */ 162 F13, 163 /** 164 * 165 */ 166 PRINTSCREEN, 167 /** 168 * 169 */ 170 SCROLL_LOCK, 171 /** 172 * 173 */ 174 PAUSE, 175 /** 176 * 177 */ 178 BACK_QUOTE, 179 /** 180 * 181 */ 182 D1, 183 /** 184 * 185 */ 186 D2, 187 /** 188 * 189 */ 190 D3, 191 /** 192 * 193 */ 194 D4, 195 /** 196 * 197 */ 198 D5, 199 /** 200 * 201 */ 202 D6, 203 /** 204 * 205 */ 206 D7, 207 /** 208 * 209 */ 210 D8, 211 /** 212 * 213 */ 214 D9, 215 /** 216 * 217 */ 218 D0, 219 /** 220 * 221 */ 222 MINUS, 223 /** 224 * 225 */ 226 EQUALS, 227 /** 228 * 229 */ 230 BACK_SLASH, 231 /** 232 * 233 */ 234 BACK_SPACE, 235 /** 236 * 237 */ 238 INSERT, 239 /** 240 * 241 */ 242 HOME, 243 /** 244 * 245 */ 246 PAGE_UP, 247 /** 248 * 249 */ 250 NUM_LOCK, 251 /** 252 * 253 */ 254 DIVIDE, 255 /** 256 * 257 */ 258 MULTIPLY, 259 /** 260 * 261 */ 262 SUBTRACT, 263 /** 264 * 265 */ 266 TAB, 267 /** 268 * 269 */ 270 Q, 271 /** 272 * 273 */ 274 W, 275 /** 276 * 277 */ 278 E, 279 /** 280 * 281 */ 282 R, 283 /** 284 * 285 */ 286 T, 287 /** 288 * 289 */ 290 Y, 291 /** 292 * 293 */ 294 U, 295 /** 296 * 297 */ 298 I, 299 /** 300 * 301 */ 302 O, 303 /** 304 * 305 */ 306 P, 307 /** 308 * 309 */ 310 OPEN_BRACKET, 311 /** 312 * 313 */ 314 CLOSE_BRACKET, 315 /** 316 * 317 */ 318 DELETE, 319 /** 320 * 321 */ 322 END, 323 /** 324 * 325 */ 326 PAGE_DOWN, 327 /** 328 * 329 */ 330 NUMPAD7, 331 /** 332 * 333 */ 334 NUMPAD8, 335 /** 336 * 337 */ 338 NUMPAD9, 339 /** 340 * 341 */ 342 ADD, 343 /** 344 * 345 */ 346 CAPS_LOCK, 347 /** 348 * 349 */ 350 A, 351 /** 352 * 353 */ 354 S, 355 /** 356 * 357 */ 358 D, 359 /** 360 * 361 */ 362 F, 363 /** 364 * 365 */ 366 G, 367 /** 368 * 369 */ 370 H, 371 /** 372 * 373 */ 374 J, 375 /** 376 * 377 */ 378 K, 379 /** 380 * 381 */ 382 L, 383 /** 384 * 385 */ 386 SEMICOLON, 387 /** 388 * 389 */ 390 QUOTE, 391 /** 392 * 393 */ 394 ENTER, 395 /** 396 * 397 */ 398 NUMPAD4, 399 /** 400 * 401 */ 402 NUMPAD5, 403 /** 404 * 405 */ 406 NUMPAD6, 407 /** 408 * 409 */ 410 SHIFT, 411 /** 412 * 413 */ 414 Z, 415 /** 416 * 417 */ 418 X, 419 /** 420 * 421 */ 422 C, 423 /** 424 * 425 */ 426 V, 427 /** 428 * 429 */ 430 B, 431 /** 432 * 433 */ 434 N, 435 /** 436 * 437 */ 438 M, 439 /** 440 * 441 */ 442 COMMA, 443 /** 444 * 445 */ 446 PERIOD, 447 /** 448 * 449 */ 450 SLASH, 451 /** 452 * 453 */ 454 UP, 455 /** 456 * 457 */ 458 NUMPAD1, 459 /** 460 * 461 */ 462 NUMPAD2, 463 /** 464 * 465 */ 466 NUMPAD3, 467 /** 468 * 469 */ 470 CONTROL, 471 /** 472 * 473 */ 474 WINDOWS, 475 /** 476 * 477 */ 478 ALT, 479 /** 480 * Represents meta key on some platforms (eg Command key on MacOS X) 481 */ 482 META, 483 /** 484 * 485 */ 486 SPACE, 487 /** 488 * 489 */ 490 CONTEXT_MENU, 491 /** 492 * 493 */ 494 LEFT, 495 /** 496 * 497 */ 498 DOWN, 499 /** 500 * 501 */ 502 RIGHT, 503 /** 504 * 505 */ 506 NUMPAD0, 507 /** 508 * 509 */ 510 DECIMAL, 511 /** 512 * 513 */ 514 DEAD_DIAERESIS, 515 /** 516 * 517 */ 518 PLUS 519 } 520 521 }