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 again!

    Thank you for the script!  I'd like the source punctuation copied to the end of the target segment and to delete the existing punctuation and add the copied punctuation. I'm using it for high fuzzies where only the punctuation is different. I edited the script to work to copy to the end ( "Send {End} after the last "Sleep 200") but I'm not sure how to configure the script to delete the punctuation in the target. Help appreciated!

    !s::
    Send {F6}
    Sleep 200
    Send {End}
    Sleep 200
    Send +{Left}
    Sleep 200
    Send ^c
    Sleep 200
    Send {F6}
    Sleep 200

    Send {End}

    Sleep 200

    Send ^v


    Return

Children
  • Me again!

    This script solves my problem of deleting the target end punctuation. The "sleeps" do make it a tad slow.

    !s::
    Send {End}
    Sleep 200
    Send +{Left}
    Sleep 200
    Send {Delete}
    Send {F6}
    Sleep 200
    Send {End}
    Sleep 200
    Send +{Left}
    Sleep 200
    Send ^c
    Sleep 200
    Send {F6}
    Sleep 200
    Send {End}
    Sleep 200
    Send ^v
    Return

  • It's great that you got it to work. You can always try and reduce the wait times, maybe to 100 or even lower, depending on how fast your computer is.

  • 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