zhmiscellany 6.2.9__py3-none-any.whl → 6.3.0__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/macro.py +21 -12
- {zhmiscellany-6.2.9.dist-info → zhmiscellany-6.3.0.dist-info}/METADATA +1 -1
- {zhmiscellany-6.2.9.dist-info → zhmiscellany-6.3.0.dist-info}/RECORD +5 -5
- {zhmiscellany-6.2.9.dist-info → zhmiscellany-6.3.0.dist-info}/WHEEL +0 -0
- {zhmiscellany-6.2.9.dist-info → zhmiscellany-6.3.0.dist-info}/top_level.txt +0 -0
zhmiscellany/macro.py
CHANGED
|
@@ -367,26 +367,35 @@ def get_mouse_buttons():
|
|
|
367
367
|
bool(GetAsyncKeyState(VK_MBUTTON) & 0x8000)
|
|
368
368
|
]
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
|
|
371
|
+
def better_wait_for(key, wait_for_release=False):
|
|
371
372
|
import threading
|
|
372
373
|
import keyboard
|
|
373
374
|
import time
|
|
374
|
-
|
|
375
|
+
|
|
375
376
|
key_name = key.lower()
|
|
376
|
-
|
|
377
|
-
_last_press_time_map.setdefault(key_name, 0)
|
|
377
|
+
event_signal = threading.Event() # Event to signal when the key event occurs
|
|
378
|
+
_last_press_time_map.setdefault(key_name, 0) # Initialize last press time for this key
|
|
378
379
|
|
|
379
380
|
def _on_key_event(e):
|
|
380
|
-
if e.name == key_name
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
if e.name == key_name:
|
|
382
|
+
if wait_for_release and e.event_type == keyboard.KEY_UP:
|
|
383
|
+
event_signal.set() # Signal that the key was released
|
|
384
|
+
elif not wait_for_release and e.event_type == keyboard.KEY_DOWN:
|
|
385
|
+
current_time = time.time()
|
|
386
|
+
_last_press_time_map[key_name] = current_time # Update last press time
|
|
387
|
+
event_signal.set() # Signal that the key was pressed
|
|
388
|
+
|
|
389
|
+
# Register the appropriate listener based on wait_for_release
|
|
390
|
+
if wait_for_release:
|
|
391
|
+
hook_id = keyboard.on_release(_on_key_event)
|
|
392
|
+
else:
|
|
393
|
+
hook_id = keyboard.on_press(_on_key_event)
|
|
384
394
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
keyboard.unhook(hook_id) # Clean up the listener after key is detected
|
|
395
|
+
event_signal.wait() # Block execution until the event is set
|
|
396
|
+
keyboard.unhook(hook_id) # Clean up the listener after key is detected
|
|
388
397
|
|
|
389
|
-
def toggle_function(func, key='f8', blocking=True):
|
|
398
|
+
def toggle_function(func, key='f8', blocking=True, hold=False):
|
|
390
399
|
import kthread
|
|
391
400
|
import threading
|
|
392
401
|
# better_wait_for is in the same module, no import needed
|
|
@@ -12,7 +12,7 @@ zhmiscellany/fileio.py,sha256=-W1A_sEymfaqxhiEY-y6h_owBlAyVWNm4PSFn7LVoBI,21991
|
|
|
12
12
|
zhmiscellany/gui.py,sha256=OVwuZ_kWHJlgKPeYR7fAAyomNmU-OnxOgXZelVNPm1w,10409
|
|
13
13
|
zhmiscellany/image.py,sha256=6Hz5sfym_o7FHokGUKeXRsjl89VY_ZMSLnvuSam1icI,8265
|
|
14
14
|
zhmiscellany/list.py,sha256=BnbYG-lpHmi0C4v8jLfaeXqQdc3opmNgkvY6yz4pasg,1475
|
|
15
|
-
zhmiscellany/macro.py,sha256=
|
|
15
|
+
zhmiscellany/macro.py,sha256=7qUZ7LFzWl8gD2K-uAxf3l3Qc2Wskezo7XAKKoqdowA,28263
|
|
16
16
|
zhmiscellany/math.py,sha256=nNsrg4le3XIt1y36lQv5xNCjUoIu7Q1lV5BdpmyD_wk,2530
|
|
17
17
|
zhmiscellany/misc.py,sha256=0vJFa0MRdKXjLLVeFfMx1Q-b-qrKqpdaq6FzWKz6SMY,32489
|
|
18
18
|
zhmiscellany/netio.py,sha256=rN17uIbsWqDG9ssmouD7VZqOtlgWObaCsvn2Hrq-k6w,2413
|
|
@@ -21,7 +21,7 @@ zhmiscellany/pipes.py,sha256=RlHxsW_M_R6UJUIDgYVS_zfqUwO8kXG8j-0YG5qByjo,4637
|
|
|
21
21
|
zhmiscellany/processing.py,sha256=S0Rb6ndTC6N23-kz4hLEeRNgAaWjcMAtt8QNDE8x4v4,11350
|
|
22
22
|
zhmiscellany/rust.py,sha256=cHkSpdtq7QQW3yzBEAYL9lZxLW0h4wal2tsxIOnyTrA,494
|
|
23
23
|
zhmiscellany/string.py,sha256=A4ilBWSYlrJ0AJ0axvepSSjYCYwYk5X-vRrHNphi_ow,4809
|
|
24
|
-
zhmiscellany-6.
|
|
25
|
-
zhmiscellany-6.
|
|
26
|
-
zhmiscellany-6.
|
|
27
|
-
zhmiscellany-6.
|
|
24
|
+
zhmiscellany-6.3.0.dist-info/METADATA,sha256=wfTYRCFcsryY7Lsh7KyLlieRexUdE5d_aAobSlCLmLM,43872
|
|
25
|
+
zhmiscellany-6.3.0.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
|
|
26
|
+
zhmiscellany-6.3.0.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
|
|
27
|
+
zhmiscellany-6.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|