def take(self): if self.takeSS: # wait for overlay to disapare # there should be a better way to do this... time.sleep(0.5) if self.area[0] != 0 and self.area[1] != 0: x = int(min(self.origin[0], self.origin[0] + self.area[0])) y = int(min(self.origin[1], self.origin[1] + self.area[1])) w = int(abs(self.area[0])) h = int(abs(self.area[1])) kntool.screenshot(x, y, w, h)
# Original single window ss code from # https://gist.github.com/s1n4/1459140 # Calculate the size of the whole screen screenw = gtk.gdk.screen_width() screenh = gtk.gdk.screen_height() # Get the root and active window root = gtk.gdk.screen_get_default() if root.supports_net_wm_hint("_NET_ACTIVE_WINDOW") and root.supports_net_wm_hint("_NET_WM_WINDOW_TYPE"): active = root.get_active_window() # You definately do not want to take a screenshot of the whole desktop, see entry 23.36 for that # Returns something like ('ATOM', 32, ['_NET_WM_WINDOW_TYPE_DESKTOP']) if active.property_get("_NET_WM_WINDOW_TYPE")[-1][0] == '_NET_WM_WINDOW_TYPE_DESKTOP' : print False # Calculate the size of the wm decorations relativex, relativey, winw, winh, d = active.get_geometry() w = winw + (relativex*2) h = winh + (relativey+relativex) # Calculate the position of where the wm decorations start (not the window itself) screenposx, screenposy = active.get_root_origin() else: print False kntool.screenshot(screenposx, screenposy, w, h)