Author Topic: Mouse position  (Read 2187 times)

leknes

  • Newbie
  • *
  • Posts: 4
Mouse position
« on: January 17, 2021, 06:18:55 PM »
hello :), anyone can help with this?

Is it possible to read mouse position (x,y) in a variable and thereafter execute a mouse VoiceAttack command and move to that position?
I wish to do this to input text into a database field by a genealogy scheme.

Else, Im no need of  any graphical commands as all others are keyboard shortcuts.

This is what I try to achieve:
Pointing and mousclick in any textfield on screen
Immediately after mouseclick, save that mousepos in a variable (x,y).
Move to a position in a MS Word document.
Write text in MS Word, using speech to text in my language. (Sadly its output adressing is limited)
Then I grab text  to clipboard.
Return to screen position, stored in above mentioned variable
Pasting text into that text field

I could, of coarse, use HotKey, but in close future I  will not be able to use mouse/keyboard without severe pain and effort and using VoiceAttack to command would be easier than execxuting shortcuts by hitting numkeys on my keyboard.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Mouse position
« Reply #1 on: January 17, 2021, 06:29:35 PM »
If you're only looking to store a single location, you could use the "Save current location" option built-into the mouse move action, after which the "Recall mouse cursor to saved location" option would move the cursor to that position.

For storing multiple locations, you'll need two variables per location (one for each axis). Integer variables seem logical, though if you have no need to perform math with the coordinates, you could use text variables instead, to skip the needless conversion.

To get the current mouse coordinates, you'll need to use the appropriate tokens; either "{MOUSESCREENX}" and "{MOUSESCREENY}", or "{MOUSEWINDOWX}" and "{MOUSEWINDOWY}", depending on what the coordinates should be relative to.
After storing the output of those tokens to variables, you can then use the appropriate token for the variable type you are using in the "Move to text / token-based coordinates" option of the mouse move action to move the cursor to the desired location.


For information on VoiceAttack's features, including tokens and variables, press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer.

These topics may also be of use:
Control flow (If, Else, ElseIf, Loop, Jump) basics
Variables and tokens summed up

leknes

  • Newbie
  • *
  • Posts: 4
Re: Mouse position
« Reply #2 on: January 17, 2021, 07:01:35 PM »
If you're only looking to store a single location, you could use the "Save current location" option built-into the mouse move action, after which the "Recall mouse cursor to saved location" option would move the cursor to that position.

For storing multiple locations, you'll need two variables per location (one for each axis). Integer variables seem logical, though if you have no need to perform math with the coordinates, you could use text variables instead, to skip the needless conversion.

To get the current mouse coordinates, you'll need to use the appropriate tokens; either "{MOUSESCREENX}" and "{MOUSESCREENY}", or "{MOUSEWINDOWX}" and "{MOUSEWINDOWY}", depending on what the coordinates should be relative to.
After storing the output of those tokens to variables, you can then use the appropriate token for the variable type you are using in the "Move to text / token-based coordinates" option of the mouse move action to move the cursor to the desired location.


For information on VoiceAttack's features, including tokens and variables, press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer.

These topics may also be of use:
Control flow (If, Else, ElseIf, Loop, Jump) basics
Variables and tokens summed up

Thank You. I just need 1 variable and token at a time. Text type as I dont need to manipulate the variable.

What I dont understand is howto write instructions to implement "store current mouse position,token, into a text-var" immediately after a left mouseclick, in one command
and he same with a "mouse move to, var" in another command. regards

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Mouse position
« Reply #3 on: January 17, 2021, 07:15:05 PM »
What I dont understand is howto write instructions to implement "store current mouse position,token, into a text-var" immediately after a left mouseclick, in one command
and he same with a "mouse move to, var" in another command. regards
Which part, specifically?

If you're looking to have a command wait until you click the mouse (as in, execute the command first, but have it do nothing until you click the mouse, so it doesn't trigger off of every mouse click), that can be done using the "Loop Start" action, E.G.
Code: [Select]
Start Loop While :  Left Mouse Button Is Not Pressed
End Loop
Start Loop While :  Left Mouse Button Is Pressed
End Loop
The first loop would wait until you press the button, the second until you release it (so as not to proceed while you're still holding the button down).


Storing the position is a matter of using the appropriate token in the "Text" field of the "Set a Text Value" action, as tokens are a substitute for literal text, as is noted in the second topic I linked.

Reading the documentation, and perhaps some experimenting, should allow you to understand how to put these components together.

leknes

  • Newbie
  • *
  • Posts: 4
Re: Mouse position
« Reply #4 on: January 17, 2021, 07:33:16 PM »
What I dont understand is howto write instructions to implement "store current mouse position,token, into a text-var" immediately after a left mouseclick, in one command
and he same with a "mouse move to, var" in another command. regards
Which part, specifically?

If you're looking to have a command wait until you click the mouse (as in, execute the command first, but have it do nothing until you click the mouse, so it doesn't trigger off of every mouse click), that can be done using the "Loop Start" action, E.G.
Code: [Select]
Start Loop While :  Left Mouse Button Is Not Pressed
End Loop
Start Loop While :  Left Mouse Button Is Pressed
End Loop
The first loop would wait until you press the button, the second until you release it (so as not to proceed while you're still holding the button down).


Storing the position is a matter of using the appropriate token in the "Text" field of the "Set a Text Value" action, as tokens are a substitute for literal text, as is noted in the second topic I linked.

Reading the documentation, and perhaps some experimenting, should allow you to understand how to put these components together.

Thanks. Ill look into them later today. I guess I have to write a function using variables (btwn function and VoiceAttack)?
Can function be written in C+ ?  Ill see if I can find some examplles around).

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Mouse position
« Reply #5 on: January 17, 2021, 07:36:58 PM »
Unless there is something very specific that isn't covered by the built-in actions, no, you don't need an (inline) function.

Assuming you mean "C++", theoretically that may be possible, but the languages the editor supports are C# and VB.NET


If all you need is to store a position after you click a mouse button, so you can then recall it using another command, aside from those loop actions mentioned previously, you don't need anything but a mouse move action with the "Save current location" option in the first command, and a mouse move action with the "Recall mouse cursor to saved location" in the second.

leknes

  • Newbie
  • *
  • Posts: 4
Re: Mouse position
« Reply #6 on: January 18, 2021, 08:47:59 AM »
Unless there is something very specific that isn't covered by the built-in actions, no, you don't need an (inline) function.

Assuming you mean "C++", theoretically that may be possible, but the languages the editor supports are C# and VB.NET


If all you need is to store a position after you click a mouse button, so you can then recall it using another command, aside from those loop actions mentioned previously, you don't need anything but a mouse move action with the "Save current location" option in the first command, and a mouse move action with the "Recall mouse cursor to saved location" in the second.

Thank You. I used the mouse move VA  command to save/recall mouseposition. Last one jumped to the position.