Win32 transparent rectangle9/2/2023 I'm fairly new to coding, and know little at all about MSDN and the Windows API, but I really thought that LWA_COLORKEY would be the way to go, which has made the evening's repeated failures quite frustrating. Trying LWA_COLORKEY, which _should_ act more like chromakeying in video, has so far failed utterly and the window remains fully opaque. My tests with LWA_ALPHA are working well for making the window semi-transparent, but the content's themselves are also semi-transparent as LWA_ALPHA affects the entire window. While this is certainly a step in the right direction towards what I'm trying to achieve, I was curious if any of you might suggest how to make the window itself transparent while keeping it's contents opaque (preferably 100% visible)? Please see my second post, below, for example screenshots.Īfter viewing the information at &, I have managed to produce a semi-transparent window with semi-transparent contents. In short: How would I alter the example code below to use LWA_COLORKEY to achieve a transparent window with opaque contents, assuming that my Camera is set to clear a Solid Color (in this case, Green). so that you get a block of code.Moved from the Scripting forums as this seemed the better, proper place for such a question: Self.hm.MouseLeftDown = self._OnMouseEventĮnclose the program with a pair of triple backticks.Įtc. If self.refresh_frames > self.refresh_after: InvalidateRect(self.hwnd, self.monitor, True) Self.refresh_after = 10 def _draw_rect_func(self): Self.b1.CreateSolidBrush(GetSysColor(255)) Self.monitor = (0, 0, GetSystemMetrics(0), GetSystemMetrics(1)) Requires: PyHook3 (download swigwin first and add it to PATH), pywin32 and ctypes.įrom win32gui import GetDC, WindowFromPoint, SetPixel, InvalidateRectįrom win32ui import CreateDCFromHandle, CreateBrushįrom win32api import GetSystemMetrics, GetSysColor I am intending it for a game cheat i am working on (single player game) to to select a minigame area. Also the rectangle can only draw left to right (although this can be fixed quite easily by flipping the list) Would like help on these points if possible. The Rectangle boarder is too thin and the update period is slow causing the mouse to slow and redraw to take too long leaing previous frames in place. You can change FrameRect to FillRect if you want a solid rectangle and change CreateSolidBrush() int value to change to contrast (0= white, 255=black) This can be used for screenshot applications (like snipping tool) if you add a frame of somekind underneath to prevent content interaction. Took me ages to create as win32 docs are extreamly bad and there was no pre-exiting solution.Ĭode is simple: on mouse down create a rectangle to whereever the mouse is dragged, when mouse is release return the start and end positions of the drag, Introduction to Programming with Python (from Microsoft Virtual Academy)./r/git and /r/mercurial - don't forget to put your code in a repo!./r/pyladies (women developers who love python). /r/coolgithubprojects (filtered on Python projects)./r/pystats (python in statistical analysis and machine learning)./r/inventwithpython (for the books written by /u/AlSweigart)./r/pygame (a set of modules designed for writing games)./r/django (web framework for perfectionists with deadlines)./r/pythoncoding (strict moderation policy for 'programming only' articles).NumPy & SciPy (Scientific computing) & Pandas.Transcrypt (Hi res SVG using Python 3.6 and turtle module).Brython (Python 3 implementation for client-side web programming).PythonAnywhere (basic accounts are free).(Evolved from the language-agnostic parts of IPython, Python 3).The Python Challenge (solve each level through programming).Problem Solving with Algorithms and Data Structures.Invent Your Own Computer Games with Pythonįive life jackets to throw to the new coder (things to do after getting a handle on python) Please use the flair selector to choose your topic.Īdd 4 extra spaces before each line of code def fibonacci(): Reddit filters them out, so your post or comment will be lost. If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat. North Bay Python, 29 July – 30 July 2023.News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python Current Events
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |