# coding: UTF-8 # sendchars.py by Takuya Nishimoto import globalPluginHandler import globalCommands import winUser import wx import gui import api #import addonHandler #addonHandler.initTranslation() def sendInput(chars): inputs = [] for ch in chars: for direction in (0,winUser.KEYEVENTF_KEYUP): input = winUser.Input() input.type = winUser.INPUT_KEYBOARD input.ii.ki = winUser.KeyBdInput() input.ii.ki.wScan = ord(ch) input.ii.ki.dwFlags = winUser.KEYEVENTF_UNICODE|direction inputs.append(input) winUser.SendInput(inputs) class ScDialog(gui.SettingsDialog): # Translators: The title of the dialog. title = _("SendChars") def __init__(self, parent, focus): super(ScDialog, self).__init__(parent) self.focus = focus def makeSettings(self, sizer): textSizer = wx.BoxSizer(wx.HORIZONTAL) # Translators: the label of the edit field. textLabel = wx.StaticText(self, label=_("Enter text")) textSizer.Add(textLabel) self._textEdit = wx.TextCtrl(self, -1) textSizer.Add(self._textEdit) sizer.Add(textSizer) def postInit(self): self._textEdit.SetFocus() def onOk(self, event): super(ScDialog, self).onOk(event) chars = self._textEdit.GetValue() api.setFocusObject(self.focus) wx.CallLater(1000, sendInput, chars) class GlobalPlugin(globalPluginHandler.GlobalPlugin): scriptCategory = globalCommands.SCRCAT_INPUT def __init__(self): super(GlobalPlugin, self).__init__() def script_sendChars(self, gesture): focus = api.getFocusObject() gui.mainFrame.prePopup() d = ScDialog(gui.mainFrame, focus=focus) d.Show() gui.mainFrame.postPopup() # Translators: Describes a command. script_sendChars.__doc__ = _("sendChars") __gestures = { "kb:NVDA+k": "sendChars", }