Jan-16-2024, 02:42 AM
Much thanks for your replies. It was my lack Python of coding practice that was the error. I corrected the Autokey script pasted below and is working fine.
I must apply Title Case to the text to be displayed as Small Caps in Wikisource/wikipedia, but the connecting words must be reverted to lowercase.
I must apply Title Case to the text to be displayed as Small Caps in Wikisource/wikipedia, but the connecting words must be reverted to lowercase.
# [ alt + s ] title and small case selected text # 240115_2129 - *alt-s-title-with-small-caps.py - /home/ineuw/.config/autokey/data/english - Geany # clear clipboard clipboard.fill_clipboard('') time.sleep(0.05) # small caps wiki template set open_ = '{{sc|' close_ = '}}' copy_ = '<ctrl>+<insert>' paste_ = '<shift>+<insert>' time.sleep(0.05) try: keyboard.send_keys(copy_) time.sleep(0.05) text_ = clipboard.get_clipboard() except: time.sleep(0.05) else: text_ = text_.title() time.sleep(0.05) text_=text_=text_.replace(" A "," a ") time.sleep(0.05) text_=text_.replace(" An "," an ") time.sleep(0.05) text_=text_.replace(" And "," and ") time.sleep(0.05) text_=text_.replace(" As "," as ") time.sleep(0.05) text_=text_.replace(" At "," at ") time.sleep(0.05) text_=text_.replace(" De "," de ") time.sleep(0.05) text_=text_.replace(" Du "," du ") time.sleep(0.05) text_=text_.replace(" For "," for ") time.sleep(0.05) text_=text_.replace(" In "," in ") time.sleep(0.05) text_=text_.replace(" Is "," is ") time.sleep(0.05) text_=text_.replace(" It "," it ") time.sleep(0.05) text_=text_.replace(" Not "," not ") time.sleep(0.05) text_=text_.replace(" Of "," of ") time.sleep(0.05) text_=text_.replace(" On "," on ") time.sleep(0.05) text_=text_.replace(" The ", " the ") time.sleep(0.05) text_=text_.replace(" To "," to ") time.sleep(0.05) combined_ = open_ + text_ + close_ time.sleep(0.8) clipboard.fill_clipboard(combined_) time.sleep(0.05) keyboard.send_keys(paste_)
Linux Mint Cinnamon 21.3 - Python 3.10.12 - Autokey-gtk 0.96.0 as of 2024-01-13.