Browse Source

Update 'README.md'

天问 11 months ago
parent
commit
525285ec24
1 changed files with 14 additions and 3 deletions
  1. 14 3
      README.md

+ 14 - 3
README.md

@@ -7,6 +7,16 @@
 ```
 import pyautogui
 import time
+import pyperclip
+
+def type_chinese(text):
+    # 复制文本到剪贴板
+    pyperclip.copy(text)
+    # 在输入框中粘贴文本(Ctrl + V)
+    pyautogui.hotkey('ctrl', 'v')
+    # 等待一段时间,确保输入完成
+    time.sleep(1)
+
 
 # 移动鼠标到屏幕中央
 pyautogui.moveTo(pyautogui.size()[0] / 2, pyautogui.size()[1] / 2)
@@ -17,9 +27,10 @@ time.sleep(1)
 # 在当前位置点击鼠标
 pyautogui.click()
 
-# 不支持中文,可以 copy,parse 实现
-pyautogui.write("hello")
+pyautogui.write("胜多负少")
+# 调用函数输入中文
+type_chinese("你好,世界!")
 
-pyautogui.press('space')
+pyautogui.press('space') 
 ```