【问题标题】:XDOTOOL won't pass clicks to a particular windowXDOTOOL 不会将点击传递到特定窗口
【发布时间】:2013-08-18 16:49:40
【问题描述】:

只是在使用 xdotool 时遇到了一些问题 - 很棒的程序,但不幸的是没有表现出来。

from Tkinter import *
import os

class Ed:
 def __init__(self,parent):
    self.button = Button(parent,command=self.passthrough)
    self.button.pack()
    parent.geometry('+100+100')

 def passthrough(self):
     print 'clicked'
     os.popen("""
     window=$(xdotool selectwindow click)
     xdotool mousemove 110 140
     xdotool click --window $window
     """)

root = Tk()
app = Ed(root)
root.mainloop()

该程序应该渲染一个带有按钮的窗口。单击按钮时,光标会发生变化,您将鼠标移出窗口并单击其后面的窗口(例如 GIMP)。然后鼠标回到按钮上方,但点击进入后面的程序。但是,它没有这样做。提前道歉,这很难描述。

如果您能提供任何帮助,我将不胜感激。

干杯!

【问题讨论】:

    标签: python tkinter xdotool


    【解决方案1】:

    在"xdotool click --window $window" 行中,必须写成"xdotool click --window $window 1" 1 才能点击鼠标。

    【讨论】:

      【解决方案2】:

      您不能使用 popen 来运行任意命令列表。 popen 要求你给它一个命令来运行。

      popen 的文档在这里:http://docs.python.org/2/library/os.html#os.popen

      【讨论】:

      • 谢谢,我不太清楚这一点。但它似乎确实贯穿了所有代码行?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多