简体   繁体   English

如何使用 python 从另一个 window 读取文本

[英]How to read text from another window with python

Hi I need help to achieve this I have reviewed posts like this: How to read text from balloon popup window using python?您好,我需要帮助才能实现这一点,我已经查看了这样的帖子: 如何使用 python 从气球弹出窗口 window 中读取文本? But I have not been successful.但我没有成功。 I'm too new.我太新了。

What I actually need is very similar to this: https://stackoverflow.com/questions/54353050/can-i-read-text-from-another-window-using-java#:~:text=interface%20User32%20extends,Native.toString(lParamStr) )%3B%0A%20%7D我实际需要的与此非常相似: https://stackoverflow.com/questions/54353050/can-i-read-text-from-another-window-using-java#:~:text=interface%20User32%20extends ,Native.toString(lParamStr) )%3B%0A%20%7D

But in python但是在 python

Try this:尝试这个:

import time
import win32gui

while True:
  window = win32gui.GetForegroundWindow()
  title = win32gui.GetWindowText(window)
  control = win32gui.FindWindowEx(window, 0, "static", None)
  print ' ', win32gui.GetWindowText(control)
  time.sleep(1)

Source: Get text from popup window来源: 从弹出窗口中获取文本 window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM