1

I have been working on an experiment in cv2 (openCV) where a window displays multiple overlays of the screen and overlaps them. I was wondering how to make the window always on top of other applications. I have checked posts here and here, but since my window is not under the cv2.namedWindow() class, I can't find a way that works. My code is below:

import time
import cv2
import mss
import numpy

with mss.mss() as sct:
    # Part of the screen to capture
    monitor = {'top': 40, 'left': 100, 'width': 1200, 'height': 840}

while 'Screen capturing':
    last_time = time.time()+time.time()

    # Get raw pixels from the screen, save it to a Numpy array
    img = numpy.array(sct.grab(monitor))

    # Display the picture
    cv2.imshow('ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ', img)

    # Press "Q" to quit
    if cv2.waitKey(25) & 0xFF == ord('Q'):
        cv2.destroyAllWindows()
        break

This is what it should look like:Screengrab

I don't want to install external libraries.

Any help with making the window topmost would be greatly appreciated

Andereoo
  • 834
  • 1
  • 8
  • 24
  • I'm pretty sure this is a duplicate (similar questions have been asked many times before). However, the concept of a window being "always on top" would seem to be in conflict with the desire for many windows to stack on top of each other. Do you just want a window to come to the foreground *once* and then other windows can go on top of it? – Daniel Pryden May 09 '19 at 20:47
  • A useful thought exercise with this kind of thing is [What if two programs did this?](https://blogs.msdn.microsoft.com/oldnewthing/20050607-00/?p=35413/) – Daniel Pryden May 09 '19 at 20:50
  • I still can't find a solution that works. – Andereoo May 11 '19 at 11:19

0 Answers0