Topics

Code help with Python


Babbage - Ahmed
 

Hello dear developers, I would greatly appreciate some help with code. Here's the deal:

I have a dictionary, right below

__gestures = {
"some_gesture": someObject.someFunction(x,y),
"another_gesture": anotherObject.someFunction(x,y),
"final_gesture": finalObject.someFunction(x,y)
}

#this is my function, which performs a mouse click on specific coordinates on the screen
def someFunction(x,y):
  mouseClick(x,y)

#this is my object. The attributes, x and y, are coordinates
myObject = Object(20, 20)
otherObject = Object(30,40)


The point of this code is to perform someFunction() on a certain gesture on the keyboard, like "NVDA+shift+a". In this example, I have 3 different gestures, and I want them all to do the function of someFunction(x,y). Every object has different x and y coordinates, so every object will click the mouse on different parts of the screen. To illustrate another example, check this explanation:

__gestures = {
"when I press shift+a": "perform someFunction(30, 40",
"when I press shift+b": "perform someFunction(50, 30)",
"when I press shift+c": "perform someFunction(40, 40)"
}


Reef Turner
 

Hi Ahmed,

You will need to expand on this message a little bit. What aspect of this do you need help with?

I see what you are trying to do, but you'll need to describe the problem you are running into and what you have tried to solve the problem.

Kind regards,
Reef Turner
Software Developer - NV Access


On Thu, 19 Nov 2020 at 23:59, Babbage - Ahmed <ahmed@...> wrote:
Hello dear developers, I would greatly appreciate some help with code. Here's the deal:

I have a dictionary, right below

__gestures = {
"some_gesture": someObject.someFunction(x,y),
"another_gesture": anotherObject.someFunction(x,y),
"final_gesture": finalObject.someFunction(x,y)
}

#this is my function, which performs a mouse click on specific coordinates on the screen
def someFunction(x,y):
  mouseClick(x,y)

#this is my object. The attributes, x and y, are coordinates
myObject = Object(20, 20)
otherObject = Object(30,40)


The point of this code is to perform someFunction() on a certain gesture on the keyboard, like "NVDA+shift+a". In this example, I have 3 different gestures, and I want them all to do the function of someFunction(x,y). Every object has different x and y coordinates, so every object will click the mouse on different parts of the screen. To illustrate another example, check this explanation:

__gestures = {
"when I press shift+a": "perform someFunction(30, 40",
"when I press shift+b": "perform someFunction(50, 30)",
"when I press shift+c": "perform someFunction(40, 40)"
}


Babbage - Ahmed
 

Hi there Reef, here’s the problem I am encountering. I have several functions that have the @script decorator right above them. All of these functions only runs one statement, and I thought what if I made a dictionary for gestures, where instead of having lots of functions, I’ll simply have a dictionary that’s going to run a function to each corresponding gesture

 

So far, the problem I ran into is NVDA simply not doing anything when I press the gesture. That doesn’t surprise me much. However I notice that NVDA runs my code once, upon start. So I notice the mouse being clicked at the specified coordinates, so I know the code works

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Reef Turner
Sent: maandag 23 november 2020 02:09
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Code help with Python

 

Hi Ahmed,

 

You will need to expand on this message a little bit. What aspect of this do you need help with?

 

I see what you are trying to do, but you'll need to describe the problem you are running into and what you have tried to solve the problem.

 

Kind regards,

Reef Turner
Software Developer - NV Access

 

 

On Thu, 19 Nov 2020 at 23:59, Babbage - Ahmed <ahmed@...> wrote:

Hello dear developers, I would greatly appreciate some help with code. Here's the deal:

I have a dictionary, right below

__gestures = {
"some_gesture": someObject.someFunction(x,y),
"another_gesture": anotherObject.someFunction(x,y),
"final_gesture": finalObject.someFunction(x,y)
}

#this is my function, which performs a mouse click on specific coordinates on the screen
def someFunction(x,y):
  mouseClick(x,y)

#this is my object. The attributes, x and y, are coordinates
myObject = Object(20, 20)
otherObject = Object(30,40)


The point of this code is to perform someFunction() on a certain gesture on the keyboard, like "NVDA+shift+a". In this example, I have 3 different gestures, and I want them all to do the function of someFunction(x,y). Every object has different x and y coordinates, so every object will click the mouse on different parts of the screen. To illustrate another example, check this explanation:

__gestures = {
"when I press shift+a": "perform someFunction(30, 40",
"when I press shift+b": "perform someFunction(50, 30)",
"when I press shift+c": "perform someFunction(40, 40)"
}


Rui Fontes
 

Hello!


Firstly, to use a gestures dictionary, your function should be transformed in a script, so instead of having:

def someFunction(x,y):
  mouseClick(x,y)


you should have:

def script_someFunction(x,y, gesture):
  mouseClick(x,y)


Secondly, you must create a code for choosing an object in function of the gesture...


Rui Fontes

NVDA portuguese team

-


Às 08:34 de 23/11/2020, Babbage - Ahmed escreveu:

Hi there Reef, here’s the problem I am encountering. I have several functions that have the @script decorator right above them. All of these functions only runs one statement, and I thought what if I made a dictionary for gestures, where instead of having lots of functions, I’ll simply have a dictionary that’s going to run a function to each corresponding gesture

 

So far, the problem I ran into is NVDA simply not doing anything when I press the gesture. That doesn’t surprise me much. However I notice that NVDA runs my code once, upon start. So I notice the mouse being clicked at the specified coordinates, so I know the code works

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Reef Turner
Sent: maandag 23 november 2020 02:09
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Code help with Python

 

Hi Ahmed,

 

You will need to expand on this message a little bit. What aspect of this do you need help with?

 

I see what you are trying to do, but you'll need to describe the problem you are running into and what you have tried to solve the problem.

 

Kind regards,

Reef Turner
Software Developer - NV Access

 

 

On Thu, 19 Nov 2020 at 23:59, Babbage - Ahmed <ahmed@...> wrote:

Hello dear developers, I would greatly appreciate some help with code. Here's the deal:

I have a dictionary, right below

__gestures = {
"some_gesture": someObject.someFunction(x,y),
"another_gesture": anotherObject.someFunction(x,y),
"final_gesture": finalObject.someFunction(x,y)
}

#this is my function, which performs a mouse click on specific coordinates on the screen
def someFunction(x,y):
  mouseClick(x,y)

#this is my object. The attributes, x and y, are coordinates
myObject = Object(20, 20)
otherObject = Object(30,40)


The point of this code is to perform someFunction() on a certain gesture on the keyboard, like "NVDA+shift+a". In this example, I have 3 different gestures, and I want them all to do the function of someFunction(x,y). Every object has different x and y coordinates, so every object will click the mouse on different parts of the screen. To illustrate another example, check this explanation:

__gestures = {
"when I press shift+a": "perform someFunction(30, 40",
"when I press shift+b": "perform someFunction(50, 30)",
"when I press shift+c": "perform someFunction(40, 40)"
}



Babbage - Ahmed
 

Hello, alright yes I have already changed the function name to start with script. I have also made objects in order to use the instance functions associated with the class. I’m not sure what else to do

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Rui Fontes
Sent: maandag 23 november 2020 12:50
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Code help with Python

 

Hello!

 

Firstly, to use a gestures dictionary, your function should be transformed in a script, so instead of having:

def someFunction(x,y):
  mouseClick(x,y)

 

you should have:

def script_someFunction(x,y, gesture):
  mouseClick(x,y)

 

Secondly, you must create a code for choosing an object in function of the gesture...

 

Rui Fontes

NVDA portuguese team

-

 

Às 08:34 de 23/11/2020, Babbage - Ahmed escreveu:

Hi there Reef, here’s the problem I am encountering. I have several functions that have the @script decorator right above them. All of these functions only runs one statement, and I thought what if I made a dictionary for gestures, where instead of having lots of functions, I’ll simply have a dictionary that’s going to run a function to each corresponding gesture

 

So far, the problem I ran into is NVDA simply not doing anything when I press the gesture. That doesn’t surprise me much. However I notice that NVDA runs my code once, upon start. So I notice the mouse being clicked at the specified coordinates, so I know the code works

 

From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Reef Turner
Sent: maandag 23 november 2020 02:09
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Code help with Python

 

Hi Ahmed,

 

You will need to expand on this message a little bit. What aspect of this do you need help with?

 

I see what you are trying to do, but you'll need to describe the problem you are running into and what you have tried to solve the problem.

 

Kind regards,

Reef Turner
Software Developer - NV Access

 

 

On Thu, 19 Nov 2020 at 23:59, Babbage - Ahmed <ahmed@...> wrote:

Hello dear developers, I would greatly appreciate some help with code. Here's the deal:

I have a dictionary, right below

__gestures = {
"some_gesture": someObject.someFunction(x,y),
"another_gesture": anotherObject.someFunction(x,y),
"final_gesture": finalObject.someFunction(x,y)
}

#this is my function, which performs a mouse click on specific coordinates on the screen
def someFunction(x,y):
  mouseClick(x,y)

#this is my object. The attributes, x and y, are coordinates
myObject = Object(20, 20)
otherObject = Object(30,40)


The point of this code is to perform someFunction() on a certain gesture on the keyboard, like "NVDA+shift+a". In this example, I have 3 different gestures, and I want them all to do the function of someFunction(x,y). Every object has different x and y coordinates, so every object will click the mouse on different parts of the screen. To illustrate another example, check this explanation:

__gestures = {
"when I press shift+a": "perform someFunction(30, 40",
"when I press shift+b": "perform someFunction(50, 30)",
"when I press shift+c": "perform someFunction(40, 40)"
}