Giter VIP home page Giter VIP logo

Comments (11)

9001 avatar 9001 commented on May 19, 2024 1

just bumped into your project through mss, cool stuff :>
noticed this issue and gave it a try since i had a mac nearby.

encountered somewhat similar behavior on 0.1.10:

  • the red border is painted on startup, however the menu bar is on a layer above the border and renders over it
  • capturing contents inside the menu bar is impossible; normcap reports that nothing was captured
  • the dummy window appears when initiating the selection (click/drag)

can confirm that 0.1.11 mostly fixes both of these in my case;

  • the red border is still covered by the menu bar until the left mouse button is clicked, this immediately makes the border top-level
  • ...so capturing contents inside the menu bar is now possible by starting a selection right below it
  • the dummy window no longer appears at all

this was using the system-provided python 3.8 and tkinter on catalina 10.15.7

from normcap.

y4rr avatar y4rr commented on May 19, 2024 1

@dynobo I'm not a super expert in developing for MacOS, but I think I may have here something interesting for you. Here's an example of how to use Python and the PyObjC library to draw a window which in the fullscreen mode will render over the menu bar:

import objc
from Foundation import NSObject
from AppKit import NSApp, NSApplication, NSWindow, NSScreen, NSNormalWindowLevel, NSFloatingWindowLevel, NSTitledWindowMask, NSResizableWindowMask, NSClosableWindowMask, NSBorderlessWindowMask, NSBackingStoreBuffered, NSWindowCollectionBehaviorFullScreenPrimary
from PyObjCTools import AppHelper


class MyWindow(NSObject):
    def __new__(cls, *args, **kwargs):
        return cls.alloc().init()

    def __init__(self):
        frame = ((0.0, 0.0), (640.0, 480.0))
        mask = NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask | NSBorderlessWindowMask
        screen = NSScreen.mainScreen()
        #level = NSFloatingWindowLevel
        # It's just an integer, you can set it for something ridiculously high, so for example in the full screen mode the window will render over the menu bar and the dock
        level = 999999
        self._window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_screen_(frame, mask, NSBackingStoreBuffered, False, screen)
        self._window.setTitle_("Hello World")
        self._window.setLevel_(level)
        self._window.setDelegate_(self)
        self._window.setCollectionBehavior_(NSWindowCollectionBehaviorFullScreenPrimary)
        self._window.makeKeyAndOrderFront_(self)
        self._window.retain()


def main():
    app = NSApplication.sharedApplication()

    win = MyWindow()

    NSApp.activateIgnoringOtherApps_(True)

    AppHelper.runEventLoop()

if __name__ == "__main__":
    main()

I hope this might be useful for this issue. I think that you could try to use the same Objective-C APIs with tcl/tk.

from normcap.

dynobo avatar dynobo commented on May 19, 2024 1

In the new beta release 0.2.0-b1 I got completely rid of the "dummy window". In general it should provide a much nicer experience on MacOS (still not perfect, e.g. it still is behind the application menu and dock).

Please help by testing and providing feedback.

from normcap.

dynobo avatar dynobo commented on May 19, 2024

Thanks for the report, @tcptps ! 👍
I actually didn't test on MacOS for quite a while (I don't have a Mac myself), but I try to take a look at it next weekend.

from normcap.

dynobo avatar dynobo commented on May 19, 2024

Hi @tcptps,

today I installed Sierra in a VM and tried to reproduce the issue, but without success. To me, it seems like everything's working as expected.

Can you please provide additional information?

  1. Do you have a multi-monitor setup or only one display?
  2. You wrote "useful Application Window never appeared.". Are you sure? The "application window" is barely visible, because it shows only a screenshot from your current desktop. The red border it draws (see screenshot) is basically the only thing visible:
    2021-03-20_18-25
    If you see the red border, try selecting a portion of the screen with text using the mouse to trigger the recognition process.
  3. I'm not so familiar with MacOS, but I know there are some options how application windows show up. I think you can configure Mac to always maximize windows or something. Do you have something like that configure?

Thanks!

from normcap.

tcptps avatar tcptps commented on May 19, 2024

Hi,

  1. one Display
  2. No red border for me.
  3. Thats a weird one I have to say, because the Menu bar is hidden which is normally a sign that an application is in full Screen mode but on the other hand there is the little window. Using python 3.9 I think I used the Installer from the python website.
    Since my Setup is weird sometimes and it works in your VM I would suggest to wait if somebody else experiences the same Problem and assume my Setup is just broken somehow. If there is any test I can run let me know. I tried using the development Environment: https://github.com/dynobo/normcap#setup-environment but no luck either:

Bildschirmfoto 2021-03-20 um 20 31 56

Thank you very much for taking care.

from normcap.

dynobo avatar dynobo commented on May 19, 2024

You observations are quite interesting!

What technically should happen is, that normcap opens two windows:

  1. A "dummy" window, which seems to be necessary to receive keyboard shortcuts. This is the small window you see that prompts you to report the bug.
  2. Window 1) should never be visible, because a child window should open fullscreen in front of it showing the screenshot with red border. (In multi-monitor setup, one child window per screen is spawned)

Setting window 2) to fullscreen was quite difficult, because the behavior is different across the operation systems and because I also wanted multi-monitor setup. Especially on MacOS it was a struggle. The best I could come up with so far is a certain combination of options. If you are familiar with Python, this would be the section of code to experiment with.

Now the interesting part for me:
While I read, that the options I use for Mac should result in a fullscreen and topmost window, in my tests it never really was topmost: menubar and dock always were in front of it (in my screenshot above, you the red border end below menubar). I thought this might be the MacOS way, not allowing a real top-most window. In your screenshot on the other hand, it seems like menubar and dock are somehow hidden, which is quite interesting.

It looks a bit like in your case fullscreen mode is somehow enabled, but window 2) just not visible. Maybe it is not at the correct position/size...

In any case, I'd be happy about help or hints anyone.

from normcap.

dynobo avatar dynobo commented on May 19, 2024

I tried a change which might fix this problem. Could anyone affected by this issue please try v0.1.11 and report back?

pip install normcap==0.1.11

from normcap.

dynobo avatar dynobo commented on May 19, 2024

@9001 Thanks for your valuable feedback! This seems like updating to v0.1.11 is a good workaround for people on MacOS affected by this issue,

I leave this ticket open, because it still doesn't behave as it should (menu bar should be covered, too.)

I'm currently experimenting with a different GUI-Framework (Kivy) that hopefully fixes this issue and makes other things more easier for me, too. I'll drop a notice here, as soon as it's ready for testing.

from normcap.

dynobo avatar dynobo commented on May 19, 2024

@y4rr Thanks a lot for your efforts and this information. I'm currently working hard on a switch from Tk to Qt (see the respective branch), which hopefully makes it more easy to maintain NormCap for multiple platforms.

Interestingly, showing the fullscreen already works quite well with Qt on MacOS, but there are some other Mac-specific issues I have to sort out, e.g. I can't change the cursor to crosshair yet and the window doesn't get focused to receive keypress events... But maybe objc can be of use here, too! :-)

from normcap.

dynobo avatar dynobo commented on May 19, 2024

The issue with "dummy window" is solved with #116 and has been published in the new v0.2.0b3.

For the problem that the window stay below the menubar, I created Issue #119

from normcap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.