激活telegram.exe

huangapple go评论89阅读模式
英文:

To activate the telegram.exe

问题

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)

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
please help me, thank you very much

I want to write code to activate telegram.exe on window 10 desktop

英文:

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

答案1

得分: 1

It's a simple basic Python error. You need a raw string: app = Application().start(cmd_line=r"C:\Users\User\AppData\Roaming\Telegram Desktop\Telegram.exe") because \r and \t are special escape sequences: \R is a new line caret return symbol, \T is a tabulation one.

P.S. General advice about Telegram automation: please use Python API client instead of GUI automation. It is a much more reliable way. Also, Telegram desktop window doesn't provide many automation capabilities. It seems by design.

英文:

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 \r and \t are special escape sequences: \R is a new line caret return symbol, \T is 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.

huangapple
  • 本文由 发表于 2023年4月11日 01:36:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979337.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定