我试图找到当前正在gedit窗口中编辑的整个文本。首先,我试图通过使用Xlib.显示. 现在我有了一个Xlib.display.window对象。现在我想用这个window对象找出特定窗口/小部件中的文本
我的代码是这样的
import gtk, gobject, Xlib.display
currentFocus=''
def current_focused:
global currentFocus
display = Xlib.display.Display()
window = display.get_input_focus().focus
wmname = window.get_wm_name()
wmclass = window.get_wm_class()
if wmclass is None and wmname is None:
window = window.query_tree().parent
wmname = window.get_wm_name()
if currentFocused!=wmname:
if window.get_wm_class()[0]=='gedit':
print "\nNow you are in : < %s >" % (wmname,)
# Here i have to find the text of the gedit's widget
currentFocused=wmname
return True
gobject.timeout_add(1000, current_focused)
gtk.main()
有没有API可以使用Xlib.display.window 请帮帮我。我对这个领域完全陌生
谢谢你
WM_CLASS/WM_NAME属性仅用于向窗口管理器(因此是WM prefix)提供信息,通常不在子窗口上设置。检查GTK source code是否编辑小部件设置了类似的属性,但一般情况下外部进程不可能读取编辑控件文本
相关问题 更多 >
编程相关推荐