示例#1
0
	def script_attachments(self, gesture):
		obj = api.getFocusObject()
		appVersionMaj = int(obj.appModule.productVersion.split('.')[0])
		
		try:
			if appVersionMaj >= 16: #Outlook 2016+
				attachmentsList,handle,namesGen,windowName = self.getAttachmentInfos2016()
			else:
				attachmentsList,handle,namesGen,windowName = self.getAttachmentInfos2013()
		except LookupError:
			self.errorBeep()
			return
		self.nAttachments = len(attachmentsList)
		if getLastScriptRepeatCount() == 1 and self.nAttachments > 0:
		# double press, set focus in field
			self.focusInfo['firstObj'].setFocus()
			winUser.setForegroundWindow(self.focusInfo['handle'])
		else:
		# single press
			self.focusInfo = {'handle': handle}
			try:
				self.focusInfo['firstObj'] = attachmentsList[0]
			except IndexError:
				self.focusInfo['firstObj'] = None
			#Launch the attachments announcement code in a different thread since it can take time in the case of numerous attachments (above 17 on my machine).
			#In this case, getLastScriptRepeatCount() after double press will return 0 instead of 1.
			def announceAttachments():
				msg = (
					windowName + ": " + str(self.nAttachments) + '. ' +  #Attachments number
					', '.join(namesGen))
				core.callLater(0, ui.message, msg)
			threading.Thread(target=announceAttachments).start()
示例#2
0
 def script_sent(self, gesture):
     global orig
     fg = api.getForegroundObject()
     try:
         handle = windowUtils.findDescendantWindow(
             fg.windowHandle, className="RichEdit20WPT", controlID=4098)
         if handle:
             # found handle
             w = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
                 handle, winUser.OBJID_CLIENT, 0)
             if scriptHandler.getLastScriptRepeatCount() == 2:
                 # trible press, copy to clipboard and set focus to original field
                 api.copyToClip(w.value)
                 ui.message(_("Copied to clipboard"))
                 api.setNavigatorObject(w, isFocus=True)
                 orig.setFocus()
             elif scriptHandler.getLastScriptRepeatCount() == 1:
                 # double press, set focus in field
                 winUser.setForegroundWindow(handle)
             else:
                 # single press
                 ui.message(" %s %s" % (w.name, w.value))
                 orig = api.getFocusObject()
     except LookupError:
         # for RSS mails
         try:
             handle = windowUtils.findDescendantWindow(
                 fg.windowHandle, className="RichEdit20WPT", controlID=4105)
             if handle:
                 # found handle
                 w = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
                     handle, winUser.OBJID_CLIENT, 0)
                 ui.message(" %s %s" % (w.name, w.value))
         except LookupError:
             tones.beep(440, 20)
示例#3
0
 def script_attachments(self, gesture):
     fg = api.getForegroundObject()
     try:
         obj = api.getFocusObject()
         appName = obj.appModule.productName
         appVersion = obj.appModule.productVersion
         if appVersion.startswith('15.'):
             ui.message(
                 "use tab or shift-tab to go to the attachments in Outlook 2013"
             )
             tones.beep(440, 20)
             return
         handle = windowUtils.findDescendantWindow(
             fg.windowHandle, className="rctrl_renwnd32", controlID=4306)
         if handle:
             # found handle
             w = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
                 handle, winUser.OBJID_CLIENT, 0)
             try:
                 wc = w.firstChild.firstChild.firstChild.firstChild.childCount
                 indexString = (" %s " % (wc))
                 children = w.firstChild.firstChild.firstChild.firstChild.children
                 for child in children:
                     ui.message(child.name)
             except:
                 indexString = 0
                 pass
             if scriptHandler.getLastScriptRepeatCount() == 1:
                 # double press, set focus in field
                 winUser.setForegroundWindow(handle)
             else:
                 # single press
                 ui.message(" %s %s" % (w.name, indexString))
     except LookupError:
         tones.beep(440, 20)
示例#4
0
 def script_message(self, gesture):
     fg = api.getForegroundObject()
     try:
         handle = windowUtils.findDescendantWindow(fg.windowHandle,
                                                   className="AfxWndA",
                                                   controlID=4159)
         if handle:
             # found handle
             winUser.setForegroundWindow(handle)
     except LookupError:
         tones.beep(440, 20)
def PutWindowOnForeground(hwnd, sleepNb, sleepTime):
	winUser.setForegroundWindow(hwnd)
	for i in [sleepTime]*(sleepNb-1):
		time.sleep(i)
		if winUser.getForegroundWindow() == hwnd:
			return True
	# last chance
	KeyboardInputGesture.fromName("alt+Tab").send()
	time.sleep(sleepTime)
	if winUser.getForegroundWindow() == hwnd:
		return True
	return False
def checkWindowListAddonInstalled():
	h = winUser.getForegroundWindow()
	addonCheckList = [
		"fakeClipboardAnouncement",
		"listDesFenetres",
		"ListeIconesZoneNotification",
		"DitDossierOuvrirEnregistrer"]
	for addon in addonHandler.getRunningAddons():
		if addon.manifest["name"] in addonCheckList:
			# Translators: message of message box
			msg = _("Attention, you must uninstall %s addon because it is now included in this addon.")  # noqa:E501
			gui.messageBox(msg % addon.manifest["name"])
			break
	winUser.setForegroundWindow(h)
示例#7
0
	def reportObject(self, obj, nRepeat):
		if nRepeat == 0:
		# single press
			self.speakObject(obj)
			self.lastFocus= api.getFocusObject()
		elif nRepeat == 1:
		# double press, set focus in field
			handle = obj.windowHandle
			winUser.setForegroundWindow(handle)
		else:
		# trible press (or more), copy to clipboard and set focus to original focused object
			api.copyToClip(obj.value)
			# Translators: When user double press Alt+Number to copy a header's field to clipboard
			ui.message(_("Copied to clipboard"))
			api.setNavigatorObject(obj,isFocus=True)
			self.lastFocus.setFocus()
示例#8
0
def putWindowOnForeground(hwnd, sleepNb=10, sleepTime=0.1):
    winUser.setForegroundWindow(hwnd)
    try:
        winUser.setForegroundWindow(hwnd)
    except:
        pass
    for i in [sleepTime] * (sleepNb - 1):
        time.sleep(i)
        if winUser.getForegroundWindow() == hwnd:
            return True
    # last chance
    keyboardHandler.KeyboardInputGesture.fromName("alt+Tab").send()
    keyboardHandler.KeyboardInputGesture.fromName("alt+Tab").send()
    time.sleep(sleepTime)
    if winUser.getForegroundWindow() == hwnd:
        return True
    return False
示例#9
0
	def onSwitchToButton(self, evt):
		index = self.windowsListBox.GetSelection()
		self.Close()
		if self.activeWindows[index][0] == api.getDesktopObject().name:
			# it is the desktop window, all other windows are minimized
			time.sleep(0.3)
			KeyboardInputGesture.fromName("windows+m").send()
			return

		# handle of the window to put on foreground
		hwnd = self.activeWindows[index][1]
		# we put it on foreground with the focus
		winUser.setForegroundWindow(hwnd)
		time.sleep(0.1)
		winUser.setFocus(hwnd)
		from ..utils import maximizeWindow
		maximizeWindow(hwnd)
示例#10
0
 def callback():
     h = winUser.getForegroundWindow()
     obj = api.getFocusObject()
     if gui.messageBox(
             # Translators: message to ask the user if he want quit RadioSure.
             _("Are you sure you want  to quit RadioSure?"),
             # Translators: dialog's title.
             _("Warning"),
             wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING) == wx.YES:
         oldSpeechMode = getSpeechMode()
         setSpeechMode_off()
         winUser.setForegroundWindow(h)
         obj.setFocus()
         eventHandler.queueEvent("gainFocus", obj)
         time.sleep(0.1)
         api.processPendingEvents()
         clickButton("exitButton")
         setSpeechMode(oldSpeechMode)
     else:
         winUser.setForegroundWindow(h)
         time.sleep(0.5)
         obj.setFocus()
         eventHandler.queueEvent("gainFocus", obj)
示例#11
0
 def moveFocusTo(self, handle):
     #winUser.sendMessage(api.getForegroundObject().windowHandle, 40, handle, 1)
     winUser.setForegroundWindow(handle)
示例#12
0
def focus(hwnd):
	"""Try whatever we can to focus this window."""
	if user32.IsIconic(hwnd):
		user32.ShowWindow(hwnd, 9) #SW_RESTORE
	winUser.setForegroundWindow(hwnd)