zhmiscellany 5.9.0__py3-none-any.whl → 5.9.2__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 CHANGED
@@ -258,7 +258,7 @@ def type_string(text=None, delay=None, key_hold_time=None, vk_codes=None, combin
258
258
  press_key(vk_code, False, act_start=False, act_end=True, key_hold_time=key_hold_time)
259
259
 
260
260
 
261
- def scroll(amount, delay=None):
261
+ def scroll(amount, delay=None, post_scroll_delay=None):
262
262
  def raw_scroll(amount):
263
263
  # Constants for mouse input
264
264
  INPUT_MOUSE = 0
@@ -305,6 +305,8 @@ def scroll(amount, delay=None):
305
305
  for _ in range(amount):
306
306
  raw_scroll(direction)
307
307
  zhmiscellany.misc.high_precision_sleep(delay/amount)
308
+ if post_scroll_delay:
309
+ zhmiscellany.misc.high_precision_sleep(post_scroll_delay)
308
310
 
309
311
 
310
312
  def get_mouse_buttons():
@@ -425,6 +427,7 @@ def record_actions_to_code(RECORD_MOUSE_MOVEMENT=False, STOP_KEY='f9'):
425
427
  "mouse_move_dly = 1/60",
426
428
  "key_down_time = 1/30",
427
429
  "scroll_dly = 1/30",
430
+ "post_scroll_dly = 1/10",
428
431
  "",
429
432
  "pre_click_wiggle = True",
430
433
  "",
@@ -436,10 +439,10 @@ def record_actions_to_code(RECORD_MOUSE_MOVEMENT=False, STOP_KEY='f9'):
436
439
  ]
437
440
 
438
441
  last_time = start_time
439
- skip_next = False
442
+ skip_next = 0
440
443
  for i, event in enumerate(events):
441
444
  if skip_next:
442
- skip_next = False
445
+ skip_next -= 1
443
446
  continue
444
447
  current_time = event['time']
445
448
  try:
@@ -476,7 +479,7 @@ def record_actions_to_code(RECORD_MOUSE_MOVEMENT=False, STOP_KEY='f9'):
476
479
 
477
480
  if next_event and next_event['action'] == 'click' and (next_event['x'], next_event['y']) == (x, y):
478
481
  action_str = ''
479
- skip_next = True
482
+ skip_next = 1
480
483
 
481
484
  code_lines.append(f"m(({x}, {y}), {button_str}{action_str}click_duration=click_down_time, click_end_duration=click_release_time, pre_click_wiggle=pre_click_wiggle, animation_time=animation_time)")
482
485
 
@@ -485,8 +488,22 @@ def record_actions_to_code(RECORD_MOUSE_MOVEMENT=False, STOP_KEY='f9'):
485
488
  code_lines.append(f"m(({x}, {y}), click_end_duration=mouse_move_dly)")
486
489
 
487
490
  elif action == 'scroll':
488
- dx, dy = event['dx'], event['dy']
489
- code_lines.append(f"s({dy}, scroll_dly)")
491
+ x, y, dx, dy = event['x'], event['y'], event['dx'], event['dy']
492
+ j = i
493
+ count = 0
494
+ while True:
495
+ count += 1
496
+ j += 1
497
+ try:
498
+ t_event = events[j]
499
+ except:
500
+ t_event = None
501
+ if t_event and t_event['action'] == 'scroll' and t_event['dy'] == dy and (t_event['x'], t_event['y']) == (x, y):
502
+ skip_next += 1
503
+ else:
504
+ break
505
+ code_lines.append(f"m(({x}, {y}), click_end_duration=mouse_move_dly)")
506
+ code_lines.append(f"s({dy*count}, scroll_dly, post_scroll_dly)")
490
507
 
491
508
  elif action in ('key_press', 'key_release'):
492
509
  key = event['key']
@@ -549,8 +566,7 @@ def record_actions_to_code(RECORD_MOUSE_MOVEMENT=False, STOP_KEY='f9'):
549
566
  events.append({'action': 'click', 'x': x, 'y': y, 'button': button, 'pressed': pressed, 'time': time.time()})
550
567
 
551
568
  def on_scroll(x, y, dx, dy):
552
- # pynput scroll listener reports the mouse position at time of scroll, which we don't need for replay
553
- events.append({'action': 'scroll', 'dx': dx, 'dy': dy, 'time': time.time()})
569
+ events.append({'action': 'scroll', 'x': x, 'y': y, 'dx': dx, 'dy': dy, 'time': time.time()})
554
570
 
555
571
  def on_press(key):
556
572
  events.append({'action': 'key_press', 'key': key, 'time': time.time()})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zhmiscellany
3
- Version: 5.9.0
3
+ Version: 5.9.2
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
@@ -12,7 +12,7 @@ zhmiscellany/fileio.py,sha256=KmRnWWZJWBc5Or3_mKcRY2ehE_Fuk870iS-imtyERyg,18169
12
12
  zhmiscellany/gui.py,sha256=VgT5j5UIr-wWyL2P1qCHSNL7RrvZWDlm0TX00JGWmKo,7404
13
13
  zhmiscellany/image.py,sha256=qUjxiYpc2VVZp2vwr1vN36O2PVQ7YlMKzhegQ1u4c0M,8198
14
14
  zhmiscellany/list.py,sha256=S8Z85bLJEP9lk2JkGpzUcG6kpRB7a-NWDIHMPiF5bKo,1473
15
- zhmiscellany/macro.py,sha256=wFJ_vr_fyO89Za7r4-yhFbfzwF9lJmXCwpZ0rUFwd2Y,25292
15
+ zhmiscellany/macro.py,sha256=IHkIDUgRqciD9-p9vF0j_Qfzir0mIIueax8MwQIZmOY,25996
16
16
  zhmiscellany/math.py,sha256=btOQTe_GvqP0A7Zz84tmN_c8j1NGe_mKnhmAt40lhLU,2482
17
17
  zhmiscellany/misc.py,sha256=BsTbRWlXI5LZBG7Bl2MgLzHESyCMJnr_KNZAf2wY_H4,29689
18
18
  zhmiscellany/netio.py,sha256=GTamo5cJn4P6u8V_kgZ9kL8qeMUE7OQAmYkmj9Sp_GA,2236
@@ -21,7 +21,7 @@ zhmiscellany/pipes.py,sha256=PxO4aykFzC60xbTQuc66KzZYIxiW0KPebXZbncD2HcU,3795
21
21
  zhmiscellany/processing.py,sha256=srwlV8FZ--svF5e6rZZxhIs_6ZjOAwq2OcQEf6T2Le8,10410
22
22
  zhmiscellany/rust.py,sha256=znN6DYNoa_p-braTuDZKvUnXX8reWLFu_dG4fv2vLR0,442
23
23
  zhmiscellany/string.py,sha256=xyqE6V5YF2nieZDcg5ZrXTIrH2D9oDRbZ5vQGz8rPys,4787
24
- zhmiscellany-5.9.0.dist-info/METADATA,sha256=OUhSHqhda-rSgLQk3SdBge-BwJ33E9wto2U-grM0ucA,42153
25
- zhmiscellany-5.9.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
- zhmiscellany-5.9.0.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
- zhmiscellany-5.9.0.dist-info/RECORD,,
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,,