Can the segment filter drop-down list be used without a mouse?

I am trying to use Dragon with the segment filter drop-down list, specifically I am trying to use a Dragon script to work with the filter.

If I try to use an Alt sequence of keys, i.e. starting with Alt R to open the "Review" ribbon, then I have to follow this with "L" if "All segments" is showing in the ribbon, but I have to use "D2" if the filter is set to "Draft" segments. (This is rather "daft" in my opinion.) So it is not possible to open the drop-down list in a script this way.

Even if you do open the drop-down list this way, none of the entries in the list has been assigned a key to select it -- which means that once you have the list open you have to use the mouse for the final step anyway.

You can, of course, use "Ctrl-Shift-F6" to open the drop-down list, regardless of whether the filter is currently showing "All segments", or "Draft" or something else. But then you find that the arrow keys do not move you up and down in the list -- which means you have to use the mouse for the final step of selecting an entry from the list.

Why this drop-down list has to be different from all the other drop-down lists in the ribbon is a mystery, but it is the only drop-down list that doesn't allow you to use the arrow keys.

I can, of course, emulate a mouse click at a specific location, which is what I have done in my script, but then I have to make sure the Studio window is maximised on one of my 24 inch displays, because changing the window size or moving the window to my 19 inch display changes the location of the drop-down list. (Yes, I do sometimes move the window around or resize it.)

Does anyone know of a way to use the segment filter drop-down list without a mouse?

Regards,

Bruce

26 Replies Latest Replies: 27 Apr 2016 9:49 PM by Nora Díaz < 1   2   3   4   5   6  >
  • Hi Bruce,

    I'm also using a SetMousePosition argument for this, but you're right, it's dependent on the window being maximized. I tried finding a way to use keystrokes instead, but, like you've mentioned, not even the arrow keys work with that list.

    This is what I'm using (in KnowBrainer), for Show All reps, for instance:

    Sub Main
    SendKeys "^+{F6}"
    Wait .2
    SetMousePosition 1,1040,438
    Wait 0.1
    ButtonClick 1,1
    End Sub

    I have separate commands for each of the various filters, as the mouse position varies.

    I guess, if it doesn't make a difference for you whether the window is maximized or not, you could add a line to the script to maximize the window before the first SendKeys line.

    Nora

  • In reply to Nora Díaz:

    Thank you Nora,

    That is essentially what I am doing :-)

    I took a bit of code from another KnowBrainer script so that the mouse cursor would end up back where it was before the script was run, and I added a check to see what the window size is. It now works on all my displays as long as the window is not too narrow. If it is too narrow, I just abort the script.

    I also use a list (i.e. "<segmentType>") in the script name, which is "display <segmentType>", and define the list as containing all of the entries in the segment filter drop-down list. Then I use a case statement in the script to check what argument is present and set the "y" coordinate appropriately. So I can say "display translation approved", for example, to display all the translation approved segments. Judging from the x and y values you use in your SetMousePosition command, the text on your display is a different size from mine. On my display, the y position for all reps is around 513 instead of 438.

    I also added "source", "target", "selection" and "no selection" to the <segmentType> list. As a result, "display selection" will copy the current selection to the filter search box and display only segments containing that string. And "display no selection" deletes the string in the search box. I wanted "display source" and "display target" to use "Alt-F6" and "Alt-Shift-F6" to change between "In Target" and "In Source" in the filter, but "Alt-F6" and "Alt-Shift-F6" don't appear to work in Studio on my computer. Maybe I broke something with my scripts.

    Do "Alt-F6" and "Alt-Shift-F6" do what they are supposed to on your computer?

    Anyway, here is what the script looks like:

    Option Explicit Off

    Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type

    Type POINTAPI
    x As Long
    y As Long
    End Type

    ' declare Win32 API functions

    Declare Function GetCursorPos Lib "user32" _
    Alias "GetCursorPos" (lpPoint As POINTAPI) As Long

    Declare Function GetWindowRect Lib "user32" _
    Alias "GetWindowRect" (ByVal hwnd As Long, _
    lpRect As RECT) As Long

    Declare Function GetForegroundWindow& Lib "user32" ()


    Function GetCurrentPosition() As POINTAPI

    Dim hwind As Long
    Dim pt As POINTAPI
    Dim wRect As RECT
    Dim curPos As POINTAPI

    GetCursorPos pt

    hwnd = GetForegroundWindow

    GetWindowRect hwnd, wRect

    curPos.x = pt.x - wRect.Left
    curPos.y = pt.y - wRect.Top

    GetCurrentPosition = curPos
    End Function


    Function DisplaySelection() As Boolean

    Dim S as String

    DisplaySelection = True

    Select Case ListVar1
    Case "source"
    SendKeys "!{F6}" ' does not seem to work
    Case "target"
    SendKeys "!+{F6}" ' does not seem to work
    Case "selection"
    Clipboard "" ' clear the clipboard in case nothing is actually selected
    Wait 0.1
    SendKeys "^c"
    Wait 0.5
    SendKeys "^{F6}"
    Wait 0.1
    SendKeys "{Del}"
    Wait 0.1
    Sendkeys Clipboard()
    Wait 0.1
    SendKeys "{Enter}"
    Case "no selection"
    SendKeys "^{F6}"
    Wait 0.1
    Sendkeys "{Del}"
    Wait 0.1
    SendKeys "{Enter}"
    Case Else
    DisplaySelection = False
    End Select

    End Function


    Sub ClickListPosition()

    Dim hwind As Long
    Dim wRect As RECT
    Dim listPos As POINTAPI

    hwnd = GetForegroundWindow

    GetWindowRect hwnd, wRect

    If wRect.Right - wRect.Left < 1264 then end ' abort if the window is not wide enough

    Select Case ListVar1
    Case "all segments" : n = 0
    Case "all content" : n = 1

    Case "new translated content" : n = 3
    Case "100% matches" : n = 4
    Case "context matches and perfect match" : n = 5
    Case "fuzzy matches" : n = 6
    Case "automatically translated" : n = 7
    Case "unconfirmed" : n = 8
    Case "not translated" : n = 9
    Case "draft" : n = 10

    Case "all" : n = 12
    Case "first occurrences" : n = 13
    Case "excluding first occurrences" : n = 14

    Case "translated" : n = 16
    Case "translation approved" : n = 17
    Case "translation rejected" : n = 18
    Case "signed off" : n = 19
    Case "sign off rejected" : n = 20

    Case "with messages" : n = 22
    Case "with comments" : n = 23
    Case "with tracked changes" : n = 24

    Case "locked" : n = 26
    Case "unlocked" : n = 27

    Case "number only" : n = 29
    Case "excluding number only" : n = 30
    End Select

    listPos.x = 900 ' this works on my displays for all windows sizes from 1264 up
    listPos.y = 206 + n*25.63 ' this works on my displays

    SendKeys "^+{F6}"
    Wait 0.1
    SetMousePosition 1,listPos.x,listPos.y
    Wait 0.1
    ButtonClick 1,1

    End Sub


    Sub Main

    Dim savePos As POINTAPI

    savePos = GetCurrentPosition

    if Not DisplaySelection then ClickListPosition

    SetMousePosition 1,savePos.x,savePos.y
    End Sub
  • In reply to Bruce Campbell:

    Wow Bruce! Thank you for sharing this, which is lightyears beyond what I am able to achieve at the moment with my very limited scripting skills. I will be borrowing this for sure to consolidate all those commands into one! I currently have separate commands for each of the filter views, for filtering by (dictation) and for resetting the filter.

    "Alt-F6" and "Alt-Shift-F6" do work for me, but I believe certain conditions apply, i.e., there has to be some text in the filter field first, and while the filter results can be seen changing in the Editor as you cycle through the two shortcuts, the actual button in the ribbon doesn't change. Sorry if you've already noted this and I'm just stating the obvious. Regarding your script, I think the issue may be with the modifier, maybe this would work:

    SendKeys "%{F6}"
    SendKeys "%+{F6}"

    Nora
  • In reply to Nora Díaz:

    Hi Nora,

    That's brilliant! No I did not notice that something had to be in the filter field, and I did not notice that the shortcuts were working even though the ribbon button does not change.

    I just assumed it was another bug in the interface. Thank you for being so clever :-)

    I made a few more changes to the script: added "display filter list", which activates the drop-down list so I can see the entries (I still forget what the options are) and then use the appropriate "display" command. I also added "display reset", which resets the filters.

    And I also changed the check for the width of the window, which wasn't working as well as it should have.

    The <segmentType> list now contains:

    filter list
    reset
    source
    target
    selection
    no selection
    all segments
    all content
    new translated content
    100% matches
    context matches and perfect match
    fuzzy matches
    automatically translated
    unconfirmed
    not translated
    draft
    all
    first occurrences
    excluding first occurrences
    translated
    translation approved
    translation rejected
    signed off
    sign off rejected
    with messages
    with comments
    with tracked changes
    locked
    unlocked
    number only
    excluding number only

    And the script looks like the following (there are a few numbers hardcoded into the script that will have to be changed depending on your display resolution):

    Option Explicit Off

    Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type

    Type POINTAPI
    x As Long
    y As Long
    End Type

    ' declare Win32 API functions

    Declare Function GetCursorPos Lib "user32" _
    Alias "GetCursorPos" (lpPoint As POINTAPI) As Long

    Declare Function GetWindowRect Lib "user32" _
    Alias "GetWindowRect" (ByVal hwnd As Long, _
    lpRect As RECT) As Long

    Declare Function GetForegroundWindow& Lib "user32" ()

    Function GetCurrentPosition() As POINTAPI

    Dim hwind As Long
    Dim pt As POINTAPI
    Dim wRect As RECT
    Dim curPos As POINTAPI

    GetCursorPos pt

    hwnd = GetForegroundWindow

    GetWindowRect hwnd, wRect

    curPos.x = pt.x - wRect.Left
    curPos.y = pt.y - wRect.Top

    GetCurrentPosition = curPos
    End Function


    Function DisplaySelection() As Boolean

    Dim S as String

    DisplaySelection = True

    Select Case ListVar1
    Case "filter list"
    Sendkeys "^+{F6}" ' show the filter drop-down list
    Case "reset"
    Sendkeys "^%{F6}" ' reset filters
    Case "source"
    SendKeys "%{F6}"
    Case "target"
    SendKeys "%+{F6}"
    Case "selection"
    Clipboard "" ' clear the clipboard in case nothing is actually selected
    Wait 0.1
    SendKeys "^c"
    Wait 0.5
    SendKeys "^{F6}"
    Wait 0.1
    SendKeys "{Del}"
    Wait 0.1
    Sendkeys Clipboard()
    Wait 0.1
    SendKeys "{Enter}"
    Case "no selection"
    SendKeys "^{F6}"
    Wait 0.1
    Sendkeys "{Del}"
    Wait 0.1
    SendKeys "{Enter}"
    Case Else
    DisplaySelection = False
    End Select

    End Function


    Sub ClickListPosition()

    Dim hwind As Long
    Dim wRect As RECT
    Dim listPos As POINTAPI

    hwnd = GetForegroundWindow

    GetWindowRect hwnd, wRect

    Select Case wRect.Right - wRect.Left
    Case Is <= 1316 : listPos.x = 750 ' these numbers will depend on your display resolution
    Case Else : listPos.x = 900 ' this number will depend on your display resolution
    End Select

    Select Case ListVar1
    Case "all segments" : n = 0
    Case "all content" : n = 1

    Case "new translated content" : n = 3
    Case "100% matches" : n = 4
    Case "context matches and perfect match" : n = 5
    Case "fuzzy matches" : n = 6
    Case "automatically translated" : n = 7
    Case "unconfirmed" : n = 8
    Case "not translated" : n = 9
    Case "draft" : n = 10

    Case "all" : n = 12
    Case "first occurrences" : n = 13
    Case "excluding first occurrences" : n = 14

    Case "translated" : n = 16
    Case "translation approved" : n = 17
    Case "translation rejected" : n = 18
    Case "signed off" : n = 19
    Case "sign off rejected" : n = 20

    Case "with messages" : n = 22
    Case "with comments" : n = 23
    Case "with tracked changes" : n = 24

    Case "locked" : n = 26
    Case "unlocked" : n = 27

    Case "number only" : n = 29
    Case "excluding number only" : n = 30
    End Select

    listPos.y = 206 + n*25.63 ' these numbers will depend on your screen resolution

    SendKeys "^+{F6}"
    Wait 0.1
    SetMousePosition 1,listPos.x,listPos.y
    Wait 0.1
    ButtonClick 1,1

    End Sub


    Sub Main

    Dim savePos As POINTAPI

    savePos = GetCurrentPosition

    if Not DisplaySelection then ClickListPosition

    SetMousePosition 1,savePos.x,savePos.y
    End Sub
  • In reply to Bruce Campbell:

    Thank you Bruce! Now I just need to get the mouse positions for my 27-inch display and for my Surface Pro 3 to get it working on both. A little fun project for the weekend. : )
< 1   2   3   4   5   6  >
Related