Skip to content

Commit d3008ab

Browse files
committed
version 0.0.41: New typed version (fixed type_extensions dependency), improved LinuxWindow class to accept window object or window id (int/str), added acceptInput(), added getTopWindowAt(), fixed and improved sendBehind() on Ubuntu 22.04+ and Mint/Cinnamon, improved watchdog, added macOS AppScript alwaysOnTop() and alwaysOnBottom()
1 parent cf3ecc6 commit d3008ab

File tree

9 files changed

+43
-16
lines changed

9 files changed

+43
-16
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
0.0.42, 2022/12/09 -- Really fixed typing_extensions dependency and setup.py dependencies
12
0.0.41, 2022/12/09 -- Fixed requirements.txt with typing_extensions dependency
23
0.0.40, 2022/12/07 -- New typed version. Improved Window class to accept Window object or window id (int/str), added acceptInput(), added getTopWindowAt(), fixed and improved sendBehind() on Ubuntu 22.04+ and Mint/Cinnamon,
34
0.0.39, 2022/06/07 -- Improved watchdog, fixed Mint/Cinnamon sendBehind() method, added macOS AppScript alwaysOnTop() and alwaysOnBottom() methods

TODO.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@ Linux:
22
- Test other combinations (especially for sendBehind()). Tested OK: Ubuntu/GNOME and Mint/Cinnamon
33

44
Windows:
5+
- alwaysOnTop(): Working with GDI, not with windows using DirectDraw exclusive mode (is it possible with Python, or combining C++ and Python???)
6+
https://stackoverflow.com/questions/7009080/detecting-full-screen-mode-in-windows
7+
https://stackoverflow.com/questions/7928308/displaying-another-application-on-top-of-a-directdraw-full-screen-application
8+
https://www.codeproject.com/articles/730/apihijack-a-library-for-easy-dll-function-hooking?fid=1267&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&select=116946&fr=73&prof=True
9+
https://guidedhacking.com/threads/d3d9-hooking.8481/
10+
https://stackoverflow.com/questions/25601362/transparent-window-on-top-of-immersive-full-screen-mode
511
- sendBehind(False): Find a smarter way to update window (now it's minimize/restore)
612
- SendBottom(): Find a way to filter user vs. system apps. It should be doable like in Task Manager!!!
713
- alwaysOnBottom(): Try to find other smarter methods to keep window at the bottom (now it's a thread)
814

915
macOS / AppleScript:
1016
- In general, find a way to optimize all appScript calls in terms of time and resources
11-
https://discussions.apple.com/thread/1877444
12-
https://discussions.apple.com/thread/2189505
17+
https://discussions.apple.com/thread/1877444
18+
https://discussions.apple.com/thread/2189505
1319
- getAllWindows()/getAllTitles(): Find a way to return windows in same stack order than on screen
1420
- alwaysOnTop(): Try to find other smarter methods to keep window at the top (now it's a thread)
1521
- alwaysOnBottom(): Try to find other smarter methods to keep window at the bottom (now it's a thread)
1622
- sendBehind(): Is it even possible???
1723
- acceptInput(): Is it even possible???
1824

1925
General:
20-
- Create type stubs or add to base library
26+
- PyRect: Create type stubs or add to base library
-66.1 KB
Binary file not shown.
66.2 KB
Binary file not shown.

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@
3535
package_data={"pywinctl": ["src/pywinctl/py.typed"]},
3636
test_suite='tests',
3737
install_requires=[
38-
"PyRect>=0.1",
38+
"PyRect>=0.2",
3939
"pywin32>=302; sys_platform == 'win32'",
4040
"xlib>=0.21; sys_platform == 'linux'",
4141
"ewmh>=0.1; sys_platform == 'linux'",
42-
"pynput>=1.6.0; sys_platform == 'linux'",
4342
"pyobjc>=8.1; sys_platform == 'darwin'"
4443
],
4544
keywords="gui window control menu title name geometry size position move resize minimize maximize restore "

src/pywinctl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
if sys.platform == "darwin":
2626
__all__ += ["NSWindow"]
2727

28-
__version__ = "0.0.41"
28+
__version__ = "0.0.42"
2929

3030
class Box(NamedTuple):
3131
left: int

src/pywinctl/_pywinctl_linux.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
import time
1414
import tkinter as tk
1515
from collections.abc import Callable
16-
from typing import Iterable
16+
from typing import Iterable, TYPE_CHECKING
17+
if TYPE_CHECKING:
18+
from typing_extensions import TypedDict
19+
else:
20+
# Only needed if the import from typing_extensions is used outside of annotations
21+
from typing import TypedDict
1722

1823
import ewmh
1924
import Xlib.display
@@ -22,14 +27,13 @@
2227
import Xlib.X
2328
import Xlib.Xatom
2429
import Xlib.Xutil
25-
from typing_extensions import TypedDict
2630
from Xlib.xobject.drawable import Window
2731

2832
from pywinctl import BaseWindow, Point, Re, Rect, Size, _WinWatchDog, pointInRect
2933

3034
DISP = Xlib.display.Display()
3135
SCREEN = DISP.screen()
32-
ROOT = SCREEN.root
36+
ROOT: Window = SCREEN.root
3337
EWMH = ewmh.EWMH(_display=DISP, root=ROOT)
3438

3539
# WARNING: Changes are not immediately applied, specially for hide/show (unmap/map)
@@ -93,6 +97,10 @@ def getActiveWindow():
9397
win_id = EWMH.getActiveWindow()
9498
if win_id:
9599
return LinuxWindow(win_id)
100+
# ret = ROOT.get_full_property(DISP.get_atom('_NET_ACTIVE_WINDOW', False), Xlib.X.AnyPropertyType)
101+
# if ret and ret.value:
102+
# win_id = ret.value[0]
103+
# return LinuxWindow(win_id)
96104
return None
97105

98106

@@ -128,6 +136,7 @@ def getAllWindows():
128136
"""
129137
windows = EWMH.getClientListStacking()
130138
return [window for window in __remove_bad_windows(windows)]
139+
# return [window for window in __remove_bad_windows(ROOT.get_full_property(DISP.get_atom('_NET_CLIENT_LIST_STACKING', False), Xlib.X.AnyPropertyType).value)]
131140

132141

133142
def getAllTitles() -> list[str]:
@@ -424,6 +433,7 @@ def _rect(self):
424433

425434
def __init__(self, hWnd: Window | int | str):
426435
super().__init__()
436+
print(type(hWnd))
427437
if isinstance(hWnd, int):
428438
self._hWnd = DISP.create_resource_object('window', hWnd)
429439
elif isinstance(hWnd, str):

src/pywinctl/_pywinctl_macos.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@
1616
import threading
1717
import time
1818
from collections.abc import Callable, Iterable
19-
from typing import Any, overload, cast, Sequence
20-
from typing_extensions import TypeAlias, TypedDict, Literal
19+
from typing import Any, AnyStr, overload, cast, Sequence, TYPE_CHECKING
20+
21+
if TYPE_CHECKING:
22+
from typing_extensions import TypeAlias, TypedDict, Literal
23+
else:
24+
# Only needed if the import from typing_extensions is used outside of annotations
25+
TypeAlias = Any
26+
from typing import TypedDict
27+
Literal = AnyStr
2128

2229
import AppKit
2330
import Quartz

src/pywinctl/_pywinctl_win.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@
1212
import time
1313
from collections.abc import Callable, Sequence
1414
from ctypes import wintypes
15-
from typing import TYPE_CHECKING, cast, overload
15+
from typing import cast, overload, AnyStr, TYPE_CHECKING
16+
if TYPE_CHECKING:
17+
from typing_extensions import Literal, NotRequired, TypedDict
18+
from win32.lib.win32gui_struct import _MENUITEMINFO
19+
else:
20+
# Only needed if the import from typing_extensions is used outside of annotations
21+
Literal = AnyStr
22+
NotRequired = dict
23+
from typing import TypedDict
1624

1725
import win32api
1826
import win32con
1927
import win32gui
2028
import win32gui_struct
2129
import win32process
22-
from typing_extensions import Literal, NotRequired, TypedDict
2330
from win32com.client import GetObject
2431

2532
from pywinctl import BaseWindow, Point, Re, Rect, Size, _WinWatchDog, pointInRect
2633

27-
if TYPE_CHECKING:
28-
from win32.lib.win32gui_struct import _MENUITEMINFO
29-
3034
# WARNING: Changes are not immediately applied, specially for hide/show (unmap/map)
3135
# You may set wait to True in case you need to effectively know if/when change has been applied.
3236
WAIT_ATTEMPTS = 10

0 commit comments

Comments
 (0)