[nvda-addons] Re: Executing NVDA commands programmatically

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <nvda-addons@xxxxxxxxxxxxx>
  • Date: Sat, 11 Jul 2015 18:58:11 -0700

Hi,
If you want to announce only time, then there's no need to invoke global
commands. You can just use GetTimeFormat function from Windows API and pass
on the string from that to NVDA.
Cheers,
Joseph

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx] On Behalf Of Pranav Lal
Sent: Saturday, July 11, 2015 6:18 PM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Executing NVDA commands programmatically

Hi Joseph,

I am looking at executing NVDA commands from other programs. My idea is to
build a com server with routines that execute NVDA commands
programmatically. The dateTime script appears to be a simple one I can try.
In this case, can I pass None as a gesture parameter assuming I only want
the time spoken?

Pranav

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx]
On Behalf Of Joseph Lee
Sent: Saturday, July 11, 2015 10:01 PM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Executing NVDA commands programmatically

Hi,
Few things:
* You need to say:
globalCommands.GlobalCommands.script_dateTime(gesture)
* Are you looking at enhancing how date and time are announced? If so, it
might be better to hijack the date and time script (i.e. assign NVDA+F12 to
your add-on script) and do something with it, or call routines defined in
winKernel.py (wrapper around kernel32.dll of Windows API) where some of the
most useful Windows API functions are defined (most are Unicode (widechar
(variant).
Tip: At one point in add-on development, you may need to learn some Windows
API functions, as Windows API is used by NVDA for various things. Although
NVDA provides wrappers for some, not all are defined in wrapper modules. In
case of time and date, you use kernel32::GetTimeFormat (in NVDA,
winKernel.getTimeFormat) for time and kernel32::GetDateFormat
(winKernel.getDateFormat) and pass in what you want Windows to return (NVDA
core uses NOSECONDS macro to announce just hours and minutes).
Cheers,
Joseph

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx] On Behalf Of Pranav Lal
Sent: Saturday, July 11, 2015 7:07 AM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Executing NVDA commands programmatically

Hi Joseph,

I found most of the commands I wanted in globalCommands.py. I have tried to
create a very small add-on to execute the function to speak the current
time. My problem is that I am not sure what to do about the gesture
parameter that the date and time script wants. I want to execute it
programmatically and not with a gesture so the gesture parameter will be
blank.
The script has been defined as
def script_ Time(self,gesture):

My add-on is below

import globalPluginHandler
import globalCommands
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
def script_announceDT(self, gesture):
dateTime(gesture)
Pranav

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx]
On Behalf Of Joseph Lee
Sent: Saturday, July 11, 2015 10:46 AM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Executing NVDA commands programmatically

Hi,
Yes, you do need to look at NVDA source code itself. In fact, some of the
community add-ons have borrowed ideas and user interface mechanics from NVDA
core.
Cheers,
Joseph

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx] On Behalf Of Pranav Lal
Sent: Friday, July 10, 2015 10:05 PM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Executing NVDA commands programmatically

Hi Joseph,

Thanks for this. Where can I go to get a list of scripts that are globally
available? I am guessing I have to look at the code.

Pranav

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx]
On Behalf Of Joseph Lee
Sent: Friday, July 10, 2015 9:03 PM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: Executing NVDA commands programmatically

Hi,
For global commands, yes. You need to use:
globalCommands.GlobalCommands.script_name(gesture)
For apps, you need to test if the script can be found by using "has
attribute"
function like so:
hasattr(object, "script")
Same goes with other attributes you wish to test. One useful way is to test
NVDA version indirectly by testing for presence of specific attributes in a
module.
Cheers,
Joseph


-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx] On Behalf Of Pranav Lal
Sent: Friday, July 10, 2015 6:51 AM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Executing NVDA commands programmatically

Hi all,

Is it possible to execute NVDA commands programmatically from within a NVDA
add-on? For example, if I wrote an add-on for Microsoft Word that did
something and I wanted it to read the current line, could I execute this
command from within the add-on? One way would be to execute the relevant key
combination but keys can be changed. Could I perhaps scroll through a
dictionary of gestures and or commands, find the one I want and then execute
it?

Pranav

----------------------------------------------------------------
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

----------------------------------------------------------------
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

----------------------------------------------------------------
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

----------------------------------------------------------------
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: