質問

Just having some problems with xdotool here - great program, but unfortunately hasn't been behaving.

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()

The program is supposed to render a window with a button in it. When the button is clicked, the cursor changes and you move the mouse off the window and click on the window behind it (eg GIMP). Then the mouse goes back to over the button, but clicks through to the program behind. However, it is not doing that. Apologies in advance, it is a hard idea to describe.

I would be really greatful for any help you can provide.

Cheers!

役に立ちましたか?

解決

In line "xdotool click --window $window", it must be written as "xdotool click --window $window 1" 1 for the mousebutton to click.

他のヒント

You can't use popen to run an arbitrary list of commands. popen requires you give it a single command to run.

The documentation for popen is here: http://docs.python.org/2/library/os.html#os.popen

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top