def getWinId self Get Window id by clicking using xwininfo tool wininf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def getWinId(self):
"""
Get Window id by clicking using xwininfo tool
"""
wininfo = subprocess.Popen('xwininfo', shell=True, stdout=subprocess.PIPE).stdout
for line in wininfo:
if line.find('Window id: ') > -1:
return line[21:30]
return 0
def getWinSnap(self):
"""
Get snapshot of window
"""
id = self.getWinId()
snap = QtGui.QPixmap.grabWindow(id)
print id