I'm trying to call a Python code from AHK for processing the YouTube transcript on my clipboard, remove those time stamps, fuse them back into one string, and then substitute the original texts with the new processed string so I can paste it out.
AHK code:
^x::
clipboard =
Send, ^c
Run "directory\try.py"
Return
Python code (the try.py):
import pyperclip
content = pyperclip.paste()
lines = content.split('\r\n')
new_lines = []
for line in lines:
for i,x in enumerate(line):
if x.isalpha():
position = i
break
new_line = line[position:]
new_lines.append(new_line)
# print('Preview', '\n', ' '.join(new_lines))
pyperclip.copy(' '.join(new_lines))
Sometimes this system works, but sometimes it doesn't. Sometimes, when it didn't work, if I went back to the YouTube page and pressed ctrl + x again, it worked. I'm pretty sure the issue is in the AHK part, since I have manually been using the Python code for months without any error. Thanks to anyone can help.