Exemplo n.º 1
0
 def browserUp(self, x, y, z):
     if self.hasBrowser:
         return self.enableUpdate or None
     elif not self.__isMouseDown:
         return
     else:
         self.__isMouseDown = False
         self.__browser.injectKeyEvent(
             BigWorld.KeyEvent(Keys.KEY_LEFTMOUSE, -1, 0, None, (x, y)))
         return
Exemplo n.º 2
0
 def browserUp(self, x, y, z):
     if not (self.hasBrowser and self.__enableUpdate):
         return
     elif not self.__isMouseDown:
         return
     else:
         self.__isMouseDown = False
         self.__browser.injectKeyEvent(
             BigWorld.KeyEvent(Keys.KEY_LEFTMOUSE, -1, 0, None, (x, y), 0))
         if self.__isWaitingForUnfocus:
             self.focus(False)
         return
Exemplo n.º 3
0
 def browserDown(self, x, y, z):
     if not (self.hasBrowser and self.__enableUpdate):
         return
     elif self.__isMouseDown:
         return
     else:
         if not self.isFocused:
             self.focus(True)
             self.__isMouseDown = True
             self.browserUp(x, y, z)
             self.browserMove(x, y, z)
         self.__isMouseDown = True
         self.__browser.injectKeyEvent(
             BigWorld.KeyEvent(Keys.KEY_LEFTMOUSE, 0, 0, None, (x, y), 0))
         return
Exemplo n.º 4
0
    def create(self):
        LOG_BROWSER('CREATE ', self.__baseUrl, self.__browserID)
        self.__browser = BigWorld.createBrowser(self.__browserID)
        if self.__browser is None:
            LOG_BROWSER('create() NO BROWSER WAS CREATED', self.__baseUrl)
            return
        else:
            self.__browser.script = EventListener()
            self.__browser.script.onLoadStart += self.__onLoadStart
            self.__browser.script.onLoadEnd += self.__onLoadEnd
            self.__browser.script.onDOMReady += self.__onReadyToShowContent
            self.__browser.script.onCursorUpdated += self.__onCursorUpdated
            self.__browser.script.onReady += self.__onReady

            def injectBrowserKeyEvent(me, e):
                LOG_BROWSER('injectBrowserKeyEvent',
                            (e.key, e.isKeyDown(), e.isAltDown(),
                             e.isShiftDown(), e.isCtrlDown()))
                me.__browser.injectKeyEvent(e)

            def injectKeyDown(me, e):
                injectBrowserKeyEvent(me, e)

            def injectKeyUp(me, e):
                injectBrowserKeyEvent(me, e)

            def resetBit(value, bitMask):
                return value & ~bitMask

            self.__browserKeyHandlers = (
                (Keys.KEY_LEFTARROW, True, True, None, None,
                 lambda me, _: me.__browser.goBack()),
                (Keys.KEY_RIGHTARROW, True, True, None, None,
                 lambda me, _: me.__browser.goForward()),
                (Keys.KEY_F5, True, None, None, None,
                 lambda me, _: me.__browser.reload()),
                (Keys.KEY_LSHIFT, False, None, True, None,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 1), None, e.
                                       cursorPosition))),
                (Keys.KEY_RSHIFT, False, None, True, None,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 1), None, e.
                                       cursorPosition))),
                (Keys.KEY_LCONTROL, False, None, None, True,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 2), None, e.
                                       cursorPosition))),
                (Keys.KEY_RCONTROL, False, None, None, True,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 2), None, e.
                                       cursorPosition))),
                (None, True, None, None, None,
                 lambda me, e: injectKeyDown(me, e)),
                (None, False, None, None, None,
                 lambda me, e: injectKeyUp(me, e)))
            return
Exemplo n.º 5
0
    def create(self):
        _logger.info('CREATE %s id: %s', self.__baseUrl, self.__browserID)
        self.__browser = BigWorld.createWebView(self.__browserID)
        if self.__browser is None:
            _logger.error('create() NO BROWSER WAS CREATED: %s',
                          self.__baseUrl)
            return False
        else:
            self.__browser.script = EventListener(self)
            self.__browser.script.onLoadStart += self.__onLoadStart
            self.__browser.script.onLoadEnd += self.__onLoadEnd
            self.__browser.script.onLoadingStateChange += self.__onLoadingStateChange
            self.__browser.script.onDOMReady += self.__onReadyToShowContent
            self.__browser.script.onCursorUpdated += self.__onCursorUpdated
            self.__browser.script.onReady += self.__onReady
            self.__browser.script.onJsHostQuery += self.__onJsHostQuery
            self.__browser.script.onTitleChange += self.__onTitleChange
            self.__browser.script.onDestroy += self.__onDestroy
            self.__browser.script.onAudioStatusChanged += self.__onAudioStatusChanged
            self.__browser.script.onConsoleMessage += self.__onConsoleMessage
            self.__browser.script.isBrowserPlayingAudio = False

            def injectBrowserKeyEvent(me, e):
                if _BROWSER_KEY_LOGGING:
                    _logger.debug('injectBrowserKeyEvent: %s',
                                  (e.key, e.isKeyDown(), e.isAltDown(),
                                   e.isShiftDown(), e.isCtrlDown()))
                me.__browser.injectKeyEvent(e)

            def injectKeyDown(me, e):
                injectBrowserKeyEvent(me, e)

            def injectKeyUp(me, e):
                injectBrowserKeyEvent(me, e)

            def resetBit(value, bitMask):
                return value & ~bitMask

            self.__specialKeyHandlers = (
                (Keys.KEY_LEFTARROW, True, True, None, None,
                 lambda me, _: me.__browser.goBack()),
                (Keys.KEY_RIGHTARROW, True, True, None, None,
                 lambda me, _: me.__browser.goForward()),
                (Keys.KEY_F5, True, None, None, None,
                 lambda me, _: me.__browser.reload()))
            self.__browserKeyHandlers = (
                (Keys.KEY_LSHIFT, False, None, True, None,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 1), None, e.
                                       cursorPosition))),
                (Keys.KEY_RSHIFT, False, None, True, None,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 1), None, e.
                                       cursorPosition))),
                (Keys.KEY_LCONTROL, False, None, None, True,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 2), None, e.
                                       cursorPosition))),
                (Keys.KEY_RCONTROL, False, None, None, True,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 2), None, e.
                                       cursorPosition))),
                (None, True, None, None, None,
                 injectKeyDown), (None, False, None, None, None, injectKeyUp))
            self.__disableKeyHandlers = []
            return True
Exemplo n.º 6
0
    def create(self):
        LOG_BROWSER('Create id:{}'.format(self.__browserId))
        clientLanguage = ''
        self.__browser = BigWorld.createBrowser(self.__browserId,
                                                clientLanguage)
        if self.__browser is None:
            LOG_BROWSER('create() NO BROWSER WAS CREATED')
            return False
        else:
            self.__browser.script = EventListener(self)
            self.__browser.script.onLoadStart += self.__onLoadStart
            self.__browser.script.onLoadEnd += self.__onLoadEnd
            self.__browser.script.onLoadingStateChange += self.__onLoadingStateChange
            self.__browser.script.onDOMReady += self.__onReadyToShowContent
            self.__browser.script.onCursorUpdated += self.__onCursorUpdated
            self.__browser.script.onReady += self.__onReady
            self.__browser.script.onJsHostQuery += self.__onJsHostQuery
            self.__browser.script.onTitleChange += self.__onTitleChange

            def injectBrowserKeyEvent(me, e):
                if _BROWSER_KEY_LOGGING:
                    LOG_BROWSER(
                        'injectBrowserKeyEvent key:{} isKeyDown:{} isAltDown:{} isShiftDown:{} isCtrlDown:{}'
                        .format(e.key, e.isKeyDown(), e.isAltDown(),
                                e.isShiftDown(), e.isCtrlDown()))
                me.__browser.injectKeyEvent(e)

            def injectKeyDown(me, e):
                injectBrowserKeyEvent(me, e)

            def injectKeyUp(me, e):
                injectBrowserKeyEvent(me, e)

            def resetBit(value, bitMask):
                return value & ~bitMask

            self.__specialKeyHandlers = (
                (Keys.KEY_LEFTARROW, True, True, None, None,
                 lambda me, _: me.__browser.goBack()),
                (Keys.KEY_RIGHTARROW, True, True, None, None,
                 lambda me, _: me.__browser.goForward()),
                (Keys.KEY_F5, True, None, None, None,
                 lambda me, _: me.__browser.reload()))
            self.__browserKeyHandlers = (
                (Keys.KEY_LSHIFT, False, None, True, None,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 1), None, e.
                                       cursorPosition, 0))),
                (Keys.KEY_RSHIFT, False, None, True, None,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 1), None, e.
                                       cursorPosition, 0))),
                (Keys.KEY_LCONTROL, False, None, None, True,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 2), None, e.
                                       cursorPosition, 0))),
                (Keys.KEY_RCONTROL, False, None, None, True,
                 lambda me, e: injectKeyUp(
                     me,
                     BigWorld.KeyEvent(e.key, e.repeatCount,
                                       resetBit(e.modifiers, 2), None, e.
                                       cursorPosition, 0))),
                (None, True, None, None, None,
                 lambda me, e: injectKeyDown(me, e)),
                (None, False, None, None, None,
                 lambda me, e: injectKeyUp(me, e)))
            self.__disableKeyHandlers = []
            return True