def finish_key(self): """Presses the Finish button using the keyboard.""" self._ensure(running=True) self._ensure_button('Finish') _LOGGER.info('closing installer') self.setFocus() SCREEN.type('f', KEY_ALT) sleep(1) self.running = False
def finish_key(self): """Presses the Finish button using the keyboard.""" self._ensure(running = True) self._ensure_button('Finish') _LOGGER.info('closing installer') self.setFocus() SCREEN.type('f', KEY_ALT) sleep(1) self.running = False
def wrapped(*args, **kwargs): original_location = Env.getMouseLocation() original_move_delay = Settings.MoveMouseDelay Settings.MoveMouseDelay = 0 move_mouse(Location(SCREEN.getW()-1, SCREEN.getH()-1)) result = func(*args, **kwargs) move_mouse(original_location) Settings.MoveMouseDelay = original_move_delay return result
def typeKeys(keys, modifiers = NO_MODIFIER, repeat = 1, region = None): """Types a sequence of keys. If repeat is greater than 1, types the same sequence repeatedly. If region is not None, clicks on the region first. """ if repeat < 1: return # click on the region only once SCREEN.type(region, keys, modifiers) for i in range(repeat - 1): SCREEN.type(keys, modifiers)
def install_key(self): """Presses the install button using the keyboard. Raises Exception if the installer is not on the 'Ready to Install' page. """ self._ensure(running = True) self._ensure_button('Install') self.setFocus() SCREEN.type('i', KEY_ALT) sleep(1) self.page = self.installing_page self.installing = True self.buttons_valid = False
def install_key(self): """Presses the install button using the keyboard. Raises Exception if the installer is not on the 'Ready to Install' page. """ self._ensure(running=True) self._ensure_button('Install') self.setFocus() SCREEN.type('i', KEY_ALT) sleep(1) self.page = self.installing_page self.installing = True self.buttons_valid = False
def back_key(self): """Presses the Back button using the keyboard. Raises Exception if the Back button is not enabled. """ self._ensure(running = True) self._ensure_button('Back') self._ensure_button_enabled('Back') self.setFocus() SCREEN.type('b', KEY_ALT) sleep(1) self.page -= 1 self.buttons_valid = False _LOGGER.info('now on %s page', self.pages[self.page])
def back_key(self): """Presses the Back button using the keyboard. Raises Exception if the Back button is not enabled. """ self._ensure(running=True) self._ensure_button('Back') self._ensure_button_enabled('Back') self.setFocus() SCREEN.type('b', KEY_ALT) sleep(1) self.page -= 1 self.buttons_valid = False _LOGGER.info('now on %s page', self.pages[self.page])
def cancel_key(self): """Presses the Cancel button and confirms using the keyboard. Raises Exception if the Cancel button is not enabled. """ self._ensure(running=True) self._ensure_button('Cancel') self._ensure_button_enabled('Cancel') self.setFocus() SCREEN.type(Key.ESC) sleep(1) SCREEN.type('y') sleep(1) self.page = self.cancelled_page self.installing = False self.buttons_valid = False
def cancel_key(self): """Presses the Cancel button and confirms using the keyboard. Raises Exception if the Cancel button is not enabled. """ self._ensure(running = True) self._ensure_button('Cancel') self._ensure_button_enabled('Cancel') self.setFocus() SCREEN.type(Key.ESC) sleep(1) SCREEN.type('y') sleep(1) self.page = self.cancelled_page self.installing = False self.buttons_valid = False
def _close(self, button_id=None): """Closes the actual confirmation dialogue represented by this instance. """ if button_id is None: DialogueWindow._close(self, button_id) return if button_id not in self.button_ids: raise Exception("confirm dialogue '%s' does not contain a button with id %s" % (self.name, button_id)) if self.keys is not None: SCREEN.type(self.keys[button_id]) sleep(1) else: button = self.buttons[button_id] if isinstance(button, list): clickAny(button) else: SCREEN.click(button) sleep(1)
def _close(self, button_id = None): """Closes the actual confirmation dialogue represented by this instance. """ if button_id is None: DialogueWindow._close(self, button_id) return if button_id not in self.button_ids: raise Exception("confirm dialogue '%s' does not contain a button with id %s" % (self.name, button_id)) if self.keys is not None: SCREEN.type(self.keys[button_id]) sleep(1) else: button = self.buttons[button_id] if isinstance(button, list): clickAny(button) else: SCREEN.click(button) sleep(1)
def capture_screenshot(name, path, widget=None): accepted = False while not accepted: if widget: print "Preparing to select '%s' state of '%s'" % (name, str(widget)) else: print "Preparing to select '%s' region" % name raw_input("Press enter when ready!") temp_uri = SCREEN.capture("Select '%s' region" % name) if not temp_uri: print "Unable to save screenshot!" response = raw_input("Would you like to try again? ") if not response.startswith('y'): accepted = True else: accepted = True dest_uri = os.path.join(path, "%s.png" % name) shutil.move(temp_uri, dest_uri)
def maximize(self): """Clicks on the maximize button in this window's title bar.""" _LOGGER.debug('maximize window: %s', self.title) SCREEN.click(self.maximize_button)
def setFocus(self): """Clicks on the center of this window's title bar.""" _LOGGER.debug('setFocus: %s', self.title) SCREEN.click(self.titlebar_region)
def click(self, name): """Clicks the specified button. """ i, match = self._button_matches[name] _LOGGER.info("%sclick '%s': %s", self._debugprefix, name, str(match)) SCREEN.click(match, NO_MODIFIER)
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ # TODO: copied from windowsxp.py, need to fix! from sikuli.Region import Region from sikuli.Sikuli import SCREEN """Window theme """ WINDOW_TITLEBAR_HEIGHT = 30 WINDOW_TITLEBAR_MINIMIZE_BUTTON_OFFSET = -62 WINDOW_TITLEBAR_MAXIMIZE_BUTTON_OFFSET = -39 WINDOW_TITLEBAR_CLOSE_BUTTON_OFFSET = -16 """Windows task bar """ WINDOWS_TASKBAR_REGION = Region(0, SCREEN.getH() - 31, SCREEN.getW(), 31) """Paths """ INTERNET_EXPLORER_PATH = r"C:\Program Files\Internet Explorer\IEXPLORE.EXE" MSOFFICE_ROOT_PATH = r"C:\Program Files\Microsoft Office" WINDOWS_EXPLORER_PATH = r"C:\WINDOWS\explorer.exe" CONTROL_PANEL_PATH = r"C:\WINDOWS\system32\control.exe" NOTEPAD_PATH = r"C:\WINDOWS\system32\notepad.exe"
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ # TODO: copied from windowsxp.py, need to fix! from sikuli.Region import Region from sikuli.Sikuli import SCREEN """Window theme """ WINDOW_TITLEBAR_HEIGHT = 30 WINDOW_TITLEBAR_MINIMIZE_BUTTON_OFFSET = -62 WINDOW_TITLEBAR_MAXIMIZE_BUTTON_OFFSET = -39 WINDOW_TITLEBAR_CLOSE_BUTTON_OFFSET = -16 """Windows task bar """ WINDOWS_TASKBAR_REGION = Region(0, SCREEN.getH() - 31, SCREEN.getW(), 31) """Paths """ INTERNET_EXPLORER_PATH = r'C:\Program Files\Internet Explorer\IEXPLORE.EXE' MSOFFICE_ROOT_PATH = r'C:\Program Files\Microsoft Office' WINDOWS_EXPLORER_PATH = r'C:\WINDOWS\explorer.exe' CONTROL_PANEL_PATH = r'C:\WINDOWS\system32\control.exe' NOTEPAD_PATH = r'C:\WINDOWS\system32\notepad.exe'
def close(self): """Clicks on the close button in this window's title bar.""" _LOGGER.debug('close window: %s', self.title) SCREEN.click(self.close_button)