zhmiscellany 5.9.2__py3-none-any.whl → 5.9.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
zhmiscellany/gui.py CHANGED
@@ -176,4 +176,25 @@ class StateIndicator:
176
176
  if isinstance(xy_tuple, tuple) and len(xy_tuple) == 2 and all(isinstance(n, (int, float)) and n > 0 for n in xy_tuple):
177
177
  self._size = xy_tuple
178
178
  if self._root and self._root.winfo_exists():
179
- self._root.after(0, self._update_size_internal)
179
+ self._root.after(0, self._update_size_internal)
180
+
181
+ import ctypes
182
+ from ctypes import wintypes
183
+ user32 = ctypes.windll.user32
184
+
185
+ def get_focused_window():
186
+ """Return the window that currently has the keyboard focus."""
187
+ return user32.GetForegroundWindow()
188
+
189
+ def get_window_rect(hwnd):
190
+ """Return the bounding rectangle of a window."""
191
+ HWND = wintypes.HWND
192
+ RECT = wintypes.RECT
193
+ rect = RECT()
194
+ user32.GetWindowRect(hwnd, ctypes.byref(rect))
195
+ return rect
196
+
197
+ def set_window_pos(hwnd, x: int, y: int, w: int, h: int):
198
+ """Move (and optionally resize) a window."""
199
+ # 0x0040 == SWP_NOACTIVATE | 0x0020 == SWP_SHOWWINDOW
200
+ user32.SetWindowPos(hwnd, 0, x, y, w, h, 0x0040 | 0x0020)
@@ -279,4 +279,19 @@ if __name__=="__main__":
279
279
  yield var[1]
280
280
  proc.stdout.close()
281
281
  proc.wait()
282
- cleanup()
282
+ cleanup()
283
+
284
+
285
+ class thread_join_return(threading.Thread):
286
+ def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
287
+ super().__init__(group, target, name, args, kwargs)
288
+ self._return = None
289
+
290
+ def run(self):
291
+ if self._target is not None:
292
+ self._return = self._target(*self._args, **self._kwargs)
293
+
294
+ # A custom 'join' that also returns the value
295
+ def join(self, *args):
296
+ super().join(*args)
297
+ return self._return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zhmiscellany
3
- Version: 5.9.2
3
+ Version: 5.9.4
4
4
  Summary: A collection of useful/interesting python libraries made by zh.
5
5
  Home-page: https://discord.gg/ThBBAuueVJ
6
6
  Author: zh
@@ -41,7 +41,7 @@ Introduction
41
41
 
42
42
  Can be installed with `pip install zhmiscellany`
43
43
 
44
- Currently, the package stands at 141 functions/classes/bindings across 15 modules.
44
+ Currently, the package stands at 146 functions/classes/bindings across 15 modules.
45
45
 
46
46
  The git repository for this package can be found [here](https://github.com/zen-ham/zhmiscellany). The docs also look nicer on github.
47
47
 
@@ -1348,6 +1348,15 @@ Very efficiently deduplicates an iterable such as a list and returns a list.
1348
1348
 
1349
1349
  #
1350
1350
 
1351
+ `zhmiscellany.processing.thread_join_return()`
1352
+ ---
1353
+
1354
+ `zhmiscellany.processing.thread_join_return()`
1355
+
1356
+ Just a thread, but it returns whatever value was returned by the function inside it when .join() is called so you can use the data.
1357
+
1358
+ #
1359
+
1351
1360
  ---
1352
1361
  `zhmiscellany.string`
1353
1362
  ---
@@ -1527,6 +1536,15 @@ keyboard.wait() requires a clean press of the specified key, and concurrent key
1527
1536
 
1528
1537
  #
1529
1538
 
1539
+ `zhmiscellany.macro.record_actions_to_code()`
1540
+ ---
1541
+
1542
+ `zhmiscellany.macro.record_actions_to_code(RECORD_MOUSE_MOVEMENT=False, STOP_KEY='f9')`
1543
+
1544
+ Records keyboard and mouse events and generates zhmiscellany.macro code to emulate them, I'm so tired..
1545
+
1546
+ #
1547
+
1530
1548
  ---
1531
1549
  `zhmiscellany.cpp`
1532
1550
  ---
@@ -1634,3 +1652,30 @@ Sends data to a named pipe asynchronously using a background thread.
1634
1652
  A lightweight Python class that displays a customizable, semi-transparent, click-through colored rectangle overlay on the screen for visual status indication, such as if you had a complex macro/automation script and wanted to be able to see what step it's currently on.
1635
1653
 
1636
1654
  #
1655
+
1656
+ `zhmiscellany.gui.get_focused_window()`
1657
+ ---
1658
+
1659
+ `zhmiscellany.gui.get_focused_window()`
1660
+
1661
+ Return the window that currently has the keyboard focus.
1662
+
1663
+ #
1664
+
1665
+ `zhmiscellany.gui.get_window_rect()`
1666
+ ---
1667
+
1668
+ `zhmiscellany.gui.get_window_rect(hwnd)`
1669
+
1670
+ Return the bounding rectangle of a window.
1671
+
1672
+ #
1673
+
1674
+ `zhmiscellany.gui.set_window_pos()`
1675
+ ---
1676
+
1677
+ `zhmiscellany.gui.set_window_pos(hwnd, x: int, y: int, w: int, h: int)`
1678
+
1679
+ Move (and optionally resize) a window.
1680
+
1681
+ #
@@ -9,7 +9,7 @@ zhmiscellany/cpp.py,sha256=XEUEoIKCDCdY5VgwNWE5oXrGjtsmGdz_MnaVwQmi2dk,179
9
9
  zhmiscellany/dict.py,sha256=0BZJ5eK-MurAHYV1OPa0jdGTr-QEWos7ZM0npb-tN9I,81
10
10
  zhmiscellany/discord.py,sha256=bq4fBBIykQrwBKWeJ_Ia5ZtMjP9RfRheOa7fyWZBNjo,19338
11
11
  zhmiscellany/fileio.py,sha256=KmRnWWZJWBc5Or3_mKcRY2ehE_Fuk870iS-imtyERyg,18169
12
- zhmiscellany/gui.py,sha256=VgT5j5UIr-wWyL2P1qCHSNL7RrvZWDlm0TX00JGWmKo,7404
12
+ zhmiscellany/gui.py,sha256=htzIzEg_Ub_q9VMlt4nHHoV9Zr5KaEa-P1VIGw1KTDE,8076
13
13
  zhmiscellany/image.py,sha256=qUjxiYpc2VVZp2vwr1vN36O2PVQ7YlMKzhegQ1u4c0M,8198
14
14
  zhmiscellany/list.py,sha256=S8Z85bLJEP9lk2JkGpzUcG6kpRB7a-NWDIHMPiF5bKo,1473
15
15
  zhmiscellany/macro.py,sha256=IHkIDUgRqciD9-p9vF0j_Qfzir0mIIueax8MwQIZmOY,25996
@@ -18,10 +18,10 @@ zhmiscellany/misc.py,sha256=BsTbRWlXI5LZBG7Bl2MgLzHESyCMJnr_KNZAf2wY_H4,29689
18
18
  zhmiscellany/netio.py,sha256=GTamo5cJn4P6u8V_kgZ9kL8qeMUE7OQAmYkmj9Sp_GA,2236
19
19
  zhmiscellany/pastebin.py,sha256=TbZ3DqFYXo5qt5d95ugrofYoptlzKkjXUr7VnEqa6ks,6357
20
20
  zhmiscellany/pipes.py,sha256=PxO4aykFzC60xbTQuc66KzZYIxiW0KPebXZbncD2HcU,3795
21
- zhmiscellany/processing.py,sha256=srwlV8FZ--svF5e6rZZxhIs_6ZjOAwq2OcQEf6T2Le8,10410
21
+ zhmiscellany/processing.py,sha256=sDKIbzG9TNFyT6yJ4TJL59taG-59_v3CBLekVSLrwgE,10899
22
22
  zhmiscellany/rust.py,sha256=znN6DYNoa_p-braTuDZKvUnXX8reWLFu_dG4fv2vLR0,442
23
23
  zhmiscellany/string.py,sha256=xyqE6V5YF2nieZDcg5ZrXTIrH2D9oDRbZ5vQGz8rPys,4787
24
- zhmiscellany-5.9.2.dist-info/METADATA,sha256=L9yJYmR9aLlil_sbCyAfXXOWqsM96VMG6NcA74o_ktg,42153
25
- zhmiscellany-5.9.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
- zhmiscellany-5.9.2.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
- zhmiscellany-5.9.2.dist-info/RECORD,,
24
+ zhmiscellany-5.9.4.dist-info/METADATA,sha256=gQVvQ6X6gm-kpK0-FER9QALP7YWshQVkZ40qtbWlKZM,43117
25
+ zhmiscellany-5.9.4.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
+ zhmiscellany-5.9.4.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
+ zhmiscellany-5.9.4.dist-info/RECORD,,