Beispiel #1
0
 def event_gainFocus(self):
     global positionIndexInListBox, reportHintOnListBox
     if ct.STATE_PRESSED in self.states:
         return
     if not self.isManagedWindow(self.windowHandle):
         super(Bme2ListBoxItem, self).event_gainFocus()
         return
     if (winUser.getAsyncKeyState(winUser.VK_LCONTROL) <= 1
             and winUser.getAsyncKeyState(winUser.VK_RCONTROL) <= 1
             and ct.STATE_SELECTED not in self.states):
         self.setFocus()
         return
     positionInfo = self._get_positionInfo()
     try:
         s = self.getBme2ComObj().getSelectedText(self.windowHandle)
         if not positionIndexInListBox:
             positionIndexInListBox = positionInfo["indexInGroup"]
         if winUser.getAsyncKeyState(
                 winUser.VK_RCONTROL) > 1 or winUser.getAsyncKeyState(
                     winUser.VK_LCONTROL) > 1:
             case = positionInfo["indexInGroup"] != positionIndexInListBox
             text = (s, _("moved to position %d of %d") %
                     (positionInfo["indexInGroup"],
                      positionInfo["similarItemsInGroup"]))[case]
             self.sayText(text)
             positionIndexInListBox = positionInfo["indexInGroup"]
             return
         else:
Beispiel #2
0
def notify(signal):
    if not isRegistered():
        return
    with winreg.CreateKey(
            winreg.HKEY_CURRENT_USER,
            r"Software\Microsoft\Windows NT\CurrentVersion\AccessibilityTemp"
    ) as rkey:
        winreg.SetValueEx(rkey, APP_KEY_NAME, None, winreg.REG_DWORD, signal)
    keys = []
    # The user might be holding unwanted modifiers.
    for vk in winUser.VK_SHIFT, winUser.VK_CONTROL, winUser.VK_MENU:
        if winUser.getAsyncKeyState(vk) & 32768:
            keys.append((vk, False))
    keys.append((0x5B, True))  # leftWindows
    keys.append((0x55, True))  # u
    inputs = []
    # Release unwanted keys and press desired keys.
    for vk, desired in keys:
        input = winUser.Input(type=winUser.INPUT_KEYBOARD)
        input.ii.ki.wVk = vk
        if not desired:
            input.ii.ki.dwFlags = winUser.KEYEVENTF_KEYUP
        inputs.append(input)
    # Release desired keys and press unwanted keys.
    for vk, desired in reversed(keys):
        input = winUser.Input(type=winUser.INPUT_KEYBOARD)
        input.ii.ki.wVk = vk
        if desired:
            input.ii.ki.dwFlags = winUser.KEYEVENTF_KEYUP
        inputs.append(input)
    winUser.SendInput(inputs)
Beispiel #3
0
def notify(signal):
	if not isRegistered():
		return
	with winreg.CreateKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows NT\CurrentVersion\AccessibilityTemp") as rkey:
		winreg.SetValueEx(rkey, APP_KEY_NAME, None, winreg.REG_DWORD, signal)
	keys = []
	# The user might be holding unwanted modifiers.
	for vk in winUser.VK_SHIFT, winUser.VK_CONTROL, winUser.VK_MENU:
		if winUser.getAsyncKeyState(vk) & 32768:
			keys.append((vk, False))
	keys.append((0x5B, True)) # leftWindows
	keys.append((0x55, True)) # u
	inputs = []
	# Release unwanted keys and press desired keys.
	for vk, desired in keys:
		input = winUser.Input(type=winUser.INPUT_KEYBOARD)
		input.ii.ki.wVk = vk
		if not desired:
			input.ii.ki.dwFlags = winUser.KEYEVENTF_KEYUP
		inputs.append(input)
	# Release desired keys and press unwanted keys.
	for vk, desired in reversed(keys):
		input = winUser.Input(type=winUser.INPUT_KEYBOARD)
		input.ii.ki.wVk = vk
		if desired:
			input.ii.ki.dwFlags = winUser.KEYEVENTF_KEYUP
		inputs.append(input)
	winUser.SendInput(inputs)
Beispiel #4
0
def handleInputCompositionEnd(result):
    import speech
    import characterProcessing
    from NVDAObjects.inputComposition import InputComposition
    from NVDAObjects.behaviors import CandidateItem
    focus = api.getFocusObject()
    #nvdajp begin
    if config.conf["keyboard"]["nvdajpEnableKeyEvents"] and \
      config.conf["keyboard"]["speakTypedCharacters"]:
        if result == u'\u3000':
            speech.speakText(_('full shape space'))
            return
        elif result == u'\u0020':
            speech.speakText(_('space'))
            return
    #nvdajp end
    result = result.lstrip(u'\u3000 ')
    curInputComposition = None
    if isinstance(focus, InputComposition):
        curInputComposition = focus
        oldSpeechMode = speech.speechMode
        speech.speechMode = speech.speechMode_off
        eventHandler.executeEvent("gainFocus", focus.parent)
        speech.speechMode = oldSpeechMode
    elif isinstance(focus.parent, InputComposition):
        #Candidate list is still up
        curInputComposition = focus.parent
        focus.parent = focus.parent.parent
    if curInputComposition and not result:
        #nvdajp begin
        # when composition is finished,
        # (1) say 'clear' if following keys are pressed:
        # Escape, Shift+Escape, Ctrl+Z, Ctrl+[
        # (2) say the result, followed by 'clear' if Backspace is pressed.
        if config.conf["keyboard"]["nvdajpEnableKeyEvents"]:
            from NVDAObjects import inputComposition
            gesture = inputComposition.lastKeyGesture
            ctrl = (winUser.VK_CONTROL, False) in gesture.generalizedModifiers
            import ui
            if (gesture.vkCode == winUser.VK_ESCAPE) or \
              ctrl and gesture.vkCode in (0x5A, 0xDB):
                #. Translators: a message when the IME cancelation status
                speech.speakMessage(_("Clear"))
            else:
                result = curInputComposition.compositionString.lstrip(
                    u'\u3000 ')
                if winUser.getAsyncKeyState(winUser.VK_BACK) & 1:
                    #. Translators: a message when the IME cancelation status
                    result += " " + _("Clear")
        else:
            result = curInputComposition.compositionString.lstrip(u'\u3000 ')
        #nvdajp end
    if result:
        if not config.conf["inputComposition"]["announceSelectedCandidate"]:
            return  #nvdajp
        speech.speakText(result, symbolLevel=characterProcessing.SYMLVL_ALL)
Beispiel #5
0
 def _get_container(self):
     if winUser.getAsyncKeyState(winUser.VK_MENU) & 32768:
         return api.getDesktopObject()
     else:
         return super(MultitaskingViewFrameListItem, self).container
Beispiel #6
0
	def _get_container(self):
		if winUser.getAsyncKeyState(winUser.VK_MENU)&32768:
			return api.getDesktopObject()
		else:
			return super(MultitaskingViewFrameListItem,self).container
Beispiel #7
0
    def executeGesture(self, gesture):
        """Perform the action associated with a gesture.
		@param gesture: The gesture to execute.
		@type gesture: L{InputGesture}
		@raise NoInputGestureAction: If there is no action to perform.
		"""
        if watchdog.isAttemptingRecovery:
            # The core is dead, so don't try to perform an action.
            # This lets gestures pass through unhindered where possible,
            # as well as stopping a flood of actions when the core revives.
            raise NoInputGestureAction

        script = gesture.script
        focus = api.getFocusObject()
        if focus.sleepMode is focus.SLEEP_FULL or (
                focus.sleepMode
                and not getattr(script, 'allowInSleepMode', False)):
            raise NoInputGestureAction

        wasInSayAll = False
        if gesture.isModifier:
            if not self.lastModifierWasInSayAll:
                wasInSayAll = self.lastModifierWasInSayAll = sayAllHandler.isRunning(
                )
        elif self.lastModifierWasInSayAll:
            wasInSayAll = True
            self.lastModifierWasInSayAll = False
        else:
            wasInSayAll = sayAllHandler.isRunning()
        if wasInSayAll:
            gesture.wasInSayAll = True

        speechEffect = gesture.speechEffectWhenExecuted
        if speechEffect == gesture.SPEECHEFFECT_CANCEL:
            queueHandler.queueFunction(queueHandler.eventQueue,
                                       speech.cancelSpeech)
        elif speechEffect in (gesture.SPEECHEFFECT_PAUSE,
                              gesture.SPEECHEFFECT_RESUME):
            queueHandler.queueFunction(
                queueHandler.eventQueue, speech.pauseSpeech,
                speechEffect == gesture.SPEECHEFFECT_PAUSE)

        if log.isEnabledFor(log.IO) and not gesture.isModifier:
            log.io("Input: %s" % gesture.logIdentifier)

        if self._captureFunc:
            try:
                if self._captureFunc(gesture) is False:
                    return
            except:
                log.error("Error in capture function, disabling",
                          exc_info=True)
                self._captureFunc = None

        if gesture.isModifier:
            raise NoInputGestureAction

        if config.conf["keyboard"][
                "speakCommandKeys"] and gesture.shouldReportAsCommand:
            queueHandler.queueFunction(queueHandler.eventQueue,
                                       speech.speakMessage,
                                       gesture.displayName)
        # nvdajp begin
        if hasattr(gesture, "vkCode") and gesture.vkCode == winUser.VK_RETURN:
            dummy = winUser.getAsyncKeyState(winUser.VK_BACK)
        # nvdajp end

        gesture.reportExtra()

        # #2953: if an intercepted command Script (script that sends a gesture) is queued
        # then queue all following gestures (that don't have a script) with a fake script so that they remain in order.
        if not script and scriptHandler._numIncompleteInterceptedCommandScripts:
            script = lambda gesture: gesture.send()

        if script:
            scriptHandler.queueScript(script, gesture)
            return

        raise NoInputGestureAction