Is there an autohotkey solution to copy the end punctuation from the source and insert it at the end of a target segment?

Hello, I'm new to autohotkey but have created various solutions thanks to Nora Diaz's wonderful webinar. 

It seems it should be simple to write a script to copy end punctuation from source and insert it in target, but for some reason I can't figure it out. Part of the problem seems to be the behavior of F6 to switch from source to target.

Does anyone have a script?

Thanks!

Maria Danielson

ATA-certified Dutch > English Translator

Parents Reply
  • Hi Maria,

    I found your idea quite useful and couldn't help tinkering a bit further, so I added/modified the following:

    • Backup and restore the original content of the clipboard
    • Check if the last character in the source belongs to the punctuation marks defined between the square brackets in the first RegexMatch; if not, do nothing (you can of course adapt this list to your needs)
    • Check if the last character in the target belongs to the punctuation marks defined between the square brackets in the second RegexMatch; if yes, replace it with the punctuation mark from the source over it; if no, paste the punctuation mark from the source at the end of the target, not overwriting anything
    • Shortened "Sleep" times to 100

    !s::
    OriginalClipboard := clipboard
    clipboard := ""
    EndPunctuationS := ""
    EndPunctuationT := ""
    Send {F6}
    Sleep 100
    Send {End}
    Send +{Left}
    Sleep 100
    Send ^c
    EndPunctuationS := clipboard
    Send {Left}
    FoundPosS := RegExMatch(EndPunctuationS, "^[\.;,!?:]$", Result)
    If FoundPosS = 0
        Return
    Sleep 100
    Send {F6}
    Sleep 100
    Send {End}
    Send +{Left}
    clipboard := ""
    Send ^c
    EndPunctuationT := clipboard
    FoundPosT := RegExMatch(EndPunctuationT, "^[\.;,!?:]$")
    If FoundPosT = 0
        Send {End}
    Sleep 100
    Send, %EndPunctuationS%
    clipboard := OriginalClipboard
    Return


    I hope this is useful; please don't hesitate to let me know if anything isn't working as expected.

    Greetings from Brussels,
    Raphaël

Children
No Data