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