[[PageOutline]] = Zephyr = [[br]][[br]] = Zephyr in a Python Nutshell = == Classes Overview == * driver - this class is used to drive keyboard and mouse input. * image - provides functions for handling images. screencapture, image comparison. * image_search_result - all searches return this result class. it contains the result status, location, timings etc * input - key, mouse definition class. this is going to be refactored out into seperate keyboard/mouse classes. * stopwatch - helper clear for measuring time * utils - various utility functions * robot - this class uses to the above classes as building blocks to wrap some common automation functionality. === driver === * bool = isInitialized() * point = getMousePosition() * mouseClick(button, x, y) * mouseDoubleClick(button, x, y) * mouseDown(button, x, y) * mouseMove(button, x, y) * mouseUp(button, x, y) * mouseWheel(delta) * keyDown(key) * keyPress(key) * keyUp(key) * sendText(text) === image === * image_search_result = findImage(image) * image_search_result = findImage(image, x, y, tolerance=0) * int = getDepth(self) * int = getHeight(self) * int = getWidth(self) * bool = loadImage(filename) * bool = saveImage(filename, quality=100) * bool = takeScreenshot(display=0) * bool = takeScreenshot(x, y, width, height, display=0) === image_search_result === * bool found - was image found? True/False * int searchTime - how long it took to find image in milliseconds * int height - width of image * int width - width of image * int x - x location on screen where image was found * int y - y location on screen where image was found === input === * Mouse Buttons: * NO_BUTTON = 0 * RIGHT_BUTTON = 2 * LEFT_BUTTON = 1 * MIDDLE_BUTTON = 3 * Keycodes: * KEY_ADD = 40 * KEY_APPS = 28 * KEY_BACKSPACE = 1 * KEY_CAPSLOCK = 9 * KEY_CLEAR = 3 * KEY_CONTROL = 6 * KEY_DECIMAL = 43 * KEY_DELETE = 24 * KEY_DIVIDE = 44 * KEY_DOWN = 19 * KEY_END = 14 * KEY_ESCAPE = 10 * KEY_EXECUTE = 21 * KEY_F1 = 45 * KEY_F10 = 54 * KEY_F11 = 55 * KEY_F12 = 56 * KEY_F13 = 57 * KEY_F14 = 58 * KEY_F15 = 59 * KEY_F16 = 60 * KEY_F17 = 61 * KEY_F18 = 62 * KEY_F19 = 63 * KEY_F2 = 46 * KEY_F20 = 64 * KEY_F21 = 65 * KEY_F22 = 66 * KEY_F3 = 47 * KEY_F4 = 48 * KEY_F5 = 49 * KEY_F6 = 50 * KEY_F7 = 51 * KEY_F8 = 52 * KEY_F9 = 53 * KEY_HELP = 25 * KEY_HOME = 15 * KEY_INSERT = 23 * KEY_LCONTROL = 71 * KEY_LEFT = 16 * KEY_LMENU = 73 * KEY_LSHIFT = 69 * KEY_LWIN = 26 * KEY_MENU = 7 * KEY_MULTIPLY = 39 * KEY_NUMLOCK = 67 * KEY_NUMPAD0 = 29 * KEY_NUMPAD1 = 30 * KEY_NUMPAD2 = 31 * KEY_NUMPAD3 = 32 * KEY_NUMPAD4 = 33 * KEY_NUMPAD5 = 34 * KEY_NUMPAD6 = 35 * KEY_NUMPAD7 = 36 * KEY_NUMPAD8 = 37 * KEY_NUMPAD9 = 38 * KEY_PAGEDOWN = 13 * KEY_PAGEUP = 12 * KEY_PAUSE = 8 * KEY_PRINTSCREEN = 22 * KEY_RCONTROL = 72 * KEY_RETURN = 4 * KEY_RIGHT = 18 * KEY_RMENU = 74 * KEY_RSHIFT = 70 * KEY_RWIN = 27 * KEY_SCROLL = 68 * KEY_SELECT = 20 * KEY_SEPARATOR = 41 * KEY_SHIFT = 5 * KEY_SPACE = 11 * KEY_SUBTRACT = 42 * KEY_TAB = 2 * KEY_UP = 17 === robot === * robot(imageDirectory) - specify path to images. any image functions are expected to be relative to this directory * disableExceptions(self) - Disable exceptions when searching for images. Useful if have an if/else test * enableExceptions(self) - Enable exceptions when searching for images. Useful if have an if/else test * bool = getDisableExceptions(self) - Are exceptions disabled or not * setTimeout(seconds=30) - Set the default timeout in seconds for image searches * findImage(imagename, x=0, y=0) - searchs for image from top left to bottom right. You can specify a starting x,y. * findAndClick(imagename, x=0, y=0, button=LEFT_BUTTON, relativeX=0, relativeY=0) - Search for image and click on it. You can specify a start x/y location, what button to click. You can also speficy a relative location to click. * string = getImageFilename(imagename) - gets full pathname to relative imagename * saveScreenshot(imagename, waitMilliseconds=0, x=-1, y=-1,width=-1,height=-1) - Saves screenshot to imagename. You can specify how long to wait before taking screenshot, x, y width and height of screenshot. * mouseClick(button, x, y) * mouseDoubleClick(button, x, y) * mouseDown(button, x, y) * mouseMove(button, x, y) * mouseUp(button, x, y) * mouseWheel(delta) * keyDown(key) * keyPress(key) * keyUp(key) * sendText(text) * getScreenDepth(self) * getScreenHeight(self) * getScreenWidth(self) * string = getVersion() - Returns the version of Zephyr === stopwatch === * long = elapsed() - elapsed time in milliseconds * pause() - pause the timer * resume() - resume the timer * start() - start the time === utils === * File System: * bool = dirExists(filename) * bool = makeDir(filename) * bool = removeDir(filename) * bool = removeFile(filename) * bool = fileExists(filename) * long = execute(filename, waitToFinish=True) * Time/Date: * string = getDateTime() - gets friendly date/time * long = getEpoch() - returns current epoch * System info: * string = getHostname() * string = getOsDescription() * string = getOsVersion() * string = getUserHome() * string = getUsername() * General: * sleep(milliseconds) - sleep for n milliseconds * string = getVersion() - Returns the version of Zephyr