Last active
April 29, 2017 02:40
-
-
Save nishimotz/33cf91246043dbe208dc77326aa11b60 to your computer and use it in GitHub Desktop.
sendchars experimental NVDA global plugin. Japanese https://osdn.net/ticket/browse.php?group_id=4221&tid=36764
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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", | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment