Author Topic: Adjusting an in sim Map  (Read 4364 times)

Hazza

  • Guest
Adjusting an in sim Map
« on: February 23, 2019, 04:50:32 PM »
I have created commands to show the in sim map (CLOD) and hide map, as well as zoom in and out. However as I use joystick on my right side I need to remove hand from joystick to adjust the map position at times to find an airfield or my aircraft.

Is it possible to code a command to effectively move the map display (which is a popup window) around? Manually it is done with mouse and click hold of left mouse button.

I can see that you can record the mouse position. But really not sure if this is just too complex.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #1 on: February 24, 2019, 09:33:32 AM »
Is there another option to move this map popup besides clicking and dragging it?

Manipulating the mouse is possible in many games(though not all), however as you're dealing with a window that may be in any given location on screen, you'd have to pass at least a rough location to the command(by including that information when you speak the command, E.G. saying "move map from upper right to center left".

If the window always starts in the same position when first opened, you could attempt to keep track of where VoiceAttack will have moved it.


If the game allows absolute positioning of the mouse cursor, you can have it move the the starting coordinates directly, otherwise you'll have to "home" the cursor by moving it to the edges of the screen, as far as it will go, and work from that known position.

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #2 on: February 24, 2019, 07:16:17 PM »
Thanks Pfiel

I did get something working. I place map window where I want and normally not moved so that side is covered.

I can get it to move up on most occasions but not sure if code is best structure and not sure if I need "Save current mouse location".

Also I know I can build nested commands that could take both the direction as well as the number of pixels. However, it may be better to have separate commands for the direction. Could you comment?

Here is what I have built to date:

Code: [Select]
Move mouse cursor to Active Window Screen Center
Save current mouse location
Hold left mouse button down
Move mouse up [50] pixel(s) (from cursor position)
Recall saved mouse location

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #3 on: February 24, 2019, 07:41:15 PM »
I can get it to move up on most occasions but not sure if code is best structure and not sure if I need "Save current mouse location".
If you don't need the cursor to return to the center of the screen(which would be the saved location, as you're centering the cursor first), there's no point in using save/recall actions.

You may want to add a "Release left mouse button" action to the end of your command, otherwise it'll keep the button held after it's finished executing.

Also I know I can build nested commands that could take both the direction as well as the number of pixels. However, it may be better to have separate commands for the direction.
Not sure what you mean by "nested commands", but you can use the "{CMD}" token to get the spoken direction and/or number of pixels and use conditions to run the appropriate actions.

Separate commands mean any change to the action list must be manually made to all commands, which gets tiresome quickly, in my opinion.

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #4 on: February 24, 2019, 07:55:57 PM »
Quote
You may want to add a "Release left mouse button" action to the end of your command, otherwise it'll keep the button held after it's finished executing.

Not sure what happened there. It was there but obviously I deleted by mistake when I was trying to build "{CMD}" token.

Quote
Not sure what you mean by "nested commands", but you can use the "{CMD}" token to get the spoken direction and/or number of pixels and use conditions to run the appropriate actions.

Yes that's what I meant "{CMD}" token to get the spoken direction and/or number of pixels.

Ok will try and build the"{CMD}" token to get the spoken direction and/or number of pixels.

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #5 on: February 25, 2019, 06:09:22 AM »
I have tried to build the code and VA recognises commands but nothing happens. I guess I have something wrong. Appreciate some help.

Code: [Select]
Set Text [direction] to '{CMD}'
Begin Text Compare : [direction] Equals 'up'
    Move mouse cursor to Active Window Screen Center
    Hold left mouse button down
    Set Text [loop] to '{CMD}'
    Set integer [loop] value to the converted value of {TXTNUM:loop}
    Start Loop While : [loop] Is Greater Than 0
        Move mouse up [1] pixel(s) (from cursor position)
        Set integer [loop] to [loop] minus 1
    End Loop
    Release left mouse button
Else If Text Compare : [direction] Equals 'down'
    Move mouse cursor to Active Window Screen Center
    Hold left mouse button down
    Set Text [loop] to '{CMD}'
    Set integer [loop] value to the converted value of {TXTNUM:loop}
    Start Loop While : [loop] Is Greater Than 0
        Move mouse down [1] pixel(s) (from cursor position)
        Set integer [loop] to [loop] minus 1
    End Loop
    Release left mouse button
Else If Text Compare : [direction] Equals 'left'
    Move mouse cursor to Active Window Screen Center
    Hold left mouse button down
    Set Text [loop] to '{CMD}'
    Set integer [loop] value to the converted value of {TXTNUM:loop}
    Start Loop While : [loop] Is Greater Than 0
        Move mouse left [1] pixel(s) (from cursor position)
        Set integer [loop] to [loop] minus 1
    End Loop
    Release left mouse button
Else If Text Compare : [direction] Equals 'right'
    Move mouse cursor to Active Window Screen Center
    Hold left mouse button down
    Set Text [loop] to '{CMD}'
    Set integer [loop] value to the converted value of {TXTNUM:loop}
    Start Loop While : [loop] Is Greater Than 0
        Move mouse right [1] pixel(s) (from cursor position)
        Set integer [loop] to [loop] minus 1
    End Loop
    Release left mouse button
End Condition

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #6 on: February 25, 2019, 09:54:51 AM »
I see you're trying to get both the direction and the pixel count from the spoken phrase, but you're comparing that phrase to literal string for the direction.

If you're speaking something like "up 15", comparing "{CMD}" to "up" will return false, as "up 15" is not the same string as "up".
You'll want to use "Contains" instead of "Equals".


There are a few other alteration you could make, though they're not required for the command to function correctly:
Code: [Select]
Set Text [direction] to '{CMD}'
Move mouse cursor to Active Window Screen Center
Hold left mouse button down
Set integer [loop] value to the converted value of {TXTNUM:"{CMD}"}
Begin Text Compare : [direction] Contains 'up'
    Start Loop : Repeat [loop] Times
        Move mouse up [1] pixel(s) (from cursor position)
    End Loop
Else If Text Compare : [direction] Contains 'down'
    Start Loop : Repeat [loop] Times
        Move mouse down [1] pixel(s) (from cursor position)
    End Loop
Else If Text Compare : [direction] Contains 'left'
    Start Loop : Repeat [loop] Times
        Move mouse left [1] pixel(s) (from cursor position)
    End Loop
Else If Text Compare : [direction] Contains 'right'
    Start Loop : Repeat [loop] Times
        Move mouse right [1] pixel(s) (from cursor position)
    End Loop
End Condition
Release left mouse button

The non-unique actions have been moved outside the conditional blocks so they're not duplicated(you could do the direction check inside the loop as well and do away with the multiple start and end loops, but in theory it is more efficient not to do the check each time the loop comes around).

The "{TXTNUM:}" token is now passed the "{CMD}" token directly, without an intermediate variable(tokens are processed and replaced by literal text, so you can use double quotes to indicate "{TXTNUM:}" should treat the input as such, rather than looking for an integer variable with that name).
You could also use "{CMD}" directly in the text compares, which is arguably more readable, but it is theoretically more efficient to only parse the token once and read from a variable instead.

The while loops have been replaced by for loops(which will do the counting for you, instead of having to manually decrement the variable).


I also notice you're not using relative units for mouse movement(as the application doesn't need them); Have you tried moving the cursor the desired amount of pixels directly, rather than one pixel at a time?
That doesn't work in some applications, but it's worth trying as it should be quicker.

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #7 on: February 25, 2019, 03:36:50 PM »
I also notice you're not using relative units for mouse movement(as the application doesn't need them); Have you tried moving the cursor the desired amount of pixels directly, rather than one pixel at a time?
That doesn't work in some applications, but it's worth trying as it should be quicker.

Thanks Pfiel
I did use move the cursor x pixels when I tested to see if I could get it to move. But was unsure how to do that in this larger code.

Was not sure on "realtive" pixels and it's use either.

Do I have to give the "X" number of pixels as a "[CMD]"?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #8 on: February 25, 2019, 04:05:17 PM »
Was not sure on "realtive" pixels and it's use either.
As VoiceAttackHelp.pdf notes on page 96, some games don't respond when the cursor is moved normally, so the relative option offers compatibility with those games(you'll likely encounter this with console ports).


Do I have to give the "X" number of pixels as a "[CMD]"?
...You don't have to, if you don't need to change the distance the cursor moves.

The textboxes for "Adjust the Mouse Cursor Location" take literal numbers, tokens, or integer variables, so you can do
Code: [Select]
Move mouse up [{TXTNUM:"{CMD}"}] pixel(s) (from cursor position)
or just enter a number directly.

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #9 on: February 25, 2019, 06:42:36 PM »
Pfeil thanks for help.

I have recoded (just to cover "UP" at this point. It does not seem to mater (for now) if I use "relative or not I am getting same reaction. I place cursor over map manually (I cannot get it to move there and have tried numerous ways) and give command. The cursor does flash but that is it.

I can place the cursor over map and give the "map zoom in" command and it will do it, so I know the map will react. I have got the actual cursor to move in sim but it only seems to want to move on 1st command and subsequent commands do not work (it could be trying to move cursor from it's original point but I am not sure. I am not sure if this is important or not but cursor will disappear in sim after approx 8 seconds if not moved.

Code done is:
Code: [Select]
Set Text [direction] to '{CMD}'
Move mouse cursor to Cursor Screen Center
Hold left mouse button down
Set integer [loop] value to the converted value of {TXTNUM:"{CMD}"}
Begin Text Compare : [direction] Contains 'up'
    Start Loop : Repeat [loop] Times
        Move mouse up [[{TXTNUM:"{CMD}"}}] relative mickey(s) (from cursor position)
    End Loop
End Condition
Release left mouse button

I have even disabled line 2 of code and get same reaction so it seems that "move cursor commands" do nothing in sim. I can see the move cursor commands work in windows ok.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #10 on: February 25, 2019, 06:57:43 PM »
I have got the actual cursor to move in sim but it only seems to want to move on 1st command and subsequent commands do not work

Have you tried something without any added logic like
Code: [Select]
Hold left mouse button down
Move mouse up [100] pixel(s) (from cursor position)
Release left mouse button

Does that work multiple times?


Code: [Select]
Move mouse up [[{TXTNUM:"{CMD}"}}] relative mickey(s) (from cursor position)
Why have you added a "[" character before the "{TXTNUM:}" token and a "}" character after it? That won't work.

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #11 on: February 25, 2019, 07:26:38 PM »
Have you tried something without any added logic like
Code: [Select]
Hold left mouse button down
Move mouse up [100] pixel(s) (from cursor position)
Release left mouse button

Yes I have and got map to move originally with this:
Code: [Select]
Move mouse cursor to Active Window Screen Center
Hold left mouse button down
Move mouse up [5] pixel(s) (from cursor position)
Release left mouse button

Does that work multiple times?
yes

Code: [Select]
Move mouse up [[{TXTNUM:"{CMD}"}}] relative mickey(s) (from cursor position)
Why have you added a "[" character before the "{TXTNUM:}" token and a "}" character after it? That won't work.

I did not understand that VA added brackets along with type error. Is this correct now:
Code: [Select]
Move mouse up [{TXTNUM:"{CMD}"}] relative mickey(s) (from cursor position)

Sorry edited:
It now works map moves.

Just cannot get cursor to move to map location!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #12 on: February 25, 2019, 07:42:39 PM »
How are you trying to move the cursor to the map window's location? What isn't working exactly?

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #13 on: February 25, 2019, 07:55:27 PM »
I have tried lots it seems.

I have tried:
Move to location "X" and "Y"
Move to all of the "Specific Locations"

The only movement I have achieved is with the original move map command I built.

If I do not place mouse over map but just have it on screen it will move with 1st command. The 2nd command causes it to flash from original position and then appear at the position it moved to after 1st command. Then sim seems to cause mouse to disappear as the 8 seconds are up!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #14 on: February 25, 2019, 08:25:45 PM »
The game may not support absolute positioning of the mouse cursor, meaning you can't make it move to specific coordinates, just relative to its current position.

If that is the case, the only way to get accurate positioning is to move the cursor into a corner until it can't go any further, so you can use that corner as a known point of reference, and make your movements from there(provided the amount the cursor moves ingame is consistent each time).

Hazza

  • Guest
Re: Adjusting an in sim Map
« Reply #15 on: February 25, 2019, 09:03:49 PM »
Yes it appears that u r correct. Just trying to get to the screen corners to achieve a solid location does noting. It appears only to move in relation to current cursor position.

Is it feasible to get cursor moving right until it can no longer move and then down until it can no longer move then I have it in a set location to move from there?

I guess that may entail a lot of tests and not be efficient?

I have found I can get the cursor into bottom right corner with the following:
Code: [Select]
Move mouse right [3000] relative mickey(s) (from cursor position)
Move mouse down [1425] relative mickey(s) (from cursor position)

Got it moving.

The move is not always consistent and sometimes moves e.g. right instead of left (VA has recognised left command). Also sometimes the command grabs the corner of the map window and drags it. So I have tried to add a "Save Location and "Recall Location". but still not getting it right.

Code: [Select]
Set Text [direction] to '{CMD}'
Move mouse right [3000] relative mickey(s) (from cursor position)
Move mouse down [1430] relative mickey(s) (from cursor position)
Move mouse left [360] relative mickey(s) (from cursor position)
Move mouse up [355] relative mickey(s) (from cursor position)
Save current mouse location
Hold left mouse button down
Set integer [loop] value to the converted value of {TXTNUM:"{CMD}"}
Begin Text Compare : [direction] Contains 'up'
    Start Loop : Repeat [loop] Times
        Move mouse up [{TXTNUM:"{CMD}"}] relative mickey(s) (from cursor position)
    End Loop
Else If Text Compare : [direction] Contains 'down'
    Start Loop : Repeat [loop] Times
        Move mouse down [{TXTNUM:"{CMD}"}] relative mickey(s) (from cursor position)
    End Loop
Else If Text Compare : [direction] Contains 'left'
    Start Loop : Repeat [loop] Times
        Move mouse left [{TXTNUM:"{CMD}"}] pixel(s) (from cursor position)
    End Loop
Else If Text Compare : [direction] Contains 'right'
    Start Loop : Repeat [loop] Times
        Move mouse right [{TXTNUM:"{CMD}"}] pixel(s) (from cursor position)
    End Loop
End Condition
Release left mouse button
Recall saved mouse location
« Last Edit: February 25, 2019, 10:22:46 PM by Hazza »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Adjusting an in sim Map
« Reply #16 on: February 26, 2019, 08:37:48 AM »
Is it feasible to get cursor moving right until it can no longer move and then down until it can no longer move then I have it in a set location to move from there?
...That's something you'll have to determine for yourself. You have the game and can test whether this works.

If you want to make sure the cursor reaches the edge of the screen, you'll have to move it at least as many pixels as your screen's horizontal and vertical resolution(as you're using mickeys it my not translate 1:1 though).

The move is not always consistent and sometimes moves e.g. right instead of left (VA has recognised left command).
Have you tried retraining your speech recognition profile(more than once, if necessary; Each training session should improve recognition more)?

Also sometimes the command grabs the corner of the map window and drags it. So I have tried to add a "Save Location and "Recall Location". but still not getting it right.
If you can't position the cursor at absolute coordinates, save/recall shouldn't work either...