Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #3
0
 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
Beispiel #4
0
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)
Beispiel #5
0
 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
Beispiel #6
0
 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
Beispiel #7
0
 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])
Beispiel #8
0
 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])
Beispiel #9
0
 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
Beispiel #10
0
 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
Beispiel #11
0
 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)
Beispiel #12
0
 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)
Beispiel #13
0
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)
Beispiel #14
0
 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)
Beispiel #15
0
 def setFocus(self):
     """Clicks on the center of this window's title bar."""
     _LOGGER.debug('setFocus: %s', self.title)
     SCREEN.click(self.titlebar_region)
Beispiel #16
0
 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)
Beispiel #17
0
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"
Beispiel #18
0
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'
Beispiel #19
0
 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)
Beispiel #20
0
 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)
Beispiel #21
0
 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)
Beispiel #22
0
 def setFocus(self):
     """Clicks on the center of this window's title bar."""
     _LOGGER.debug('setFocus: %s', self.title)
     SCREEN.click(self.titlebar_region)
Beispiel #23
0
 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)