[nvda-addons] Re: Executing NVDA commands programmatically

  • From: "Pranav Lal" <pranav.lal@xxxxxxxxx>
  • To: <nvda-addons@xxxxxxxxxxxxx>
  • Date: Tue, 12 Jul 2016 22:34:27 +0530

Hi all,

I now have some revised code but as far as I can tell, the commands are not
being executed. The way I checked this was to set the logging level to input
output and then restart NVDA with my plugin. I checked the logs but did not find
any entries relating to the say battery status command which is what I am trying
to execute as a test.

import globalPluginHandler
import keyboardHandler
from globalCommands import commands
import tones
from logHandler import log
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
    def makeKeyName(self,knm):
        colonSplit=knm.split(":")
        tk=colonSplit[1]
        nvm="insert"
        if(tk.startswith("NVDA")):

            tKey=tk.replace("NVDA",nvm)

        else:
            tKey=tk
        return tKey
    "take commands from speech-recognition and send them to NVDA"
    def execCommand(self,action):
            log.info("exec method running")
            for key in commands._GlobalCommands__gestures:
                funcName=commands._GlobalCommands__gestures[key]

#                log.info("the key name is " + key + " value is " +
commands._GlobalCommands__gestures[key])

                if(key.startswith("kb:")):
                    if (action=="sayline") and (funcName=="say_battery_status"):
                        tones.beep(550 , 100)
                        log.info("match found")
 
keyboardHandler.KeyboardInputGesture.fromName(self.makeKeyName(key))








    def    __init__(self):
        super(GlobalPlugin, self).__init__()

        self.execCommand("sayline")

 
-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx [mailto:nvda-addons-bounce@xxxxxxxxxxxxx]
On Behalf Of James Scholes
Sent: Monday, July 13, 2015 3:00 PM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Executing NVDA commands programmatically

Pranav Lal wrote:

PL] Thanks for the pointers. I tried your commands but strangely was  
unable to set focus to the speech viewer to check.

You'll need to use object nav.  IMO this is one of the most bizarre design
decisions made in NVDA, that for the average keyboard user the speech viewer is
made so difficult to access, but it was implemented for sighted users so there
you go.  As I understand it, it's a floating window that stays on the screen at
all times, and the window style used in its creation doesn't cause  it to appear
in the Alt+Tab order.

I am working on a desktop so battery status may not be available.

Running the battery status script will still result in some text being spoken,
even if it's to inform you of what you already know.  Press
NVDA+Shift+B (the default gesture), and you'll probably hear "No battery
status available" or something similar.  Running the script via the Python
console or your COM server should result in the same behaviour.
--
James Scholes
http://twitter.com/JamesScholes
----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting bugs.


Community addons are available from: http://addons.nvda-project.org To send a
message to the list: nvda-addons@xxxxxxxxxxxxx To change your list
settings/unsubscribe: //www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting 
bugs. 

Community addons are available from: http://addons.nvda-project.org
To send a message to the list: nvda-addons@xxxxxxxxxxxxx
To change your list settings/unsubscribe: 
//www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

Other related posts: