Hello I have problems in running the code below:
import pywinauto,time
from pywinauto.application import Application
from pywinauto.keyboard import send_keys
app = Application().start(cmd_line= "C:\Users\User\AppData\Roaming\Telegram Desktop\Telegram.exe" )
time.sleep(1)
------------------------------------------------------------------------
File "c:\Users\User\Desktop\Python\project", line 5
app = Application().start(cmd_line= "C:\Users\User\AppData\Roaming\Telegram Desktop\Telegram.exe" )
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
PS C:\Users\User\Desktop\Python>
please help me, thank you very much
I want to write code to activate telegram.exe on window 10 desktop
It's a simple basic Python error. You need raw string:
app = Application().start(cmd_line=r"C:\Users\User\AppData\Roaming\Telegram Desktop\Telegram.exe")because\rand\tare special escape sequences:\Ris a new line caret return symbol,\Tis a tabulation one.P.S. General advise about Telegram automation: please use Python API client instead of GUI automation. It is much more reliable way. Also Telegram desktop window doesn't provide many automation capabilities. It seems by design.