optimisewait 0.1.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.
@@ -0,0 +1,66 @@
1
+ import pyautogui
2
+ from time import sleep
3
+
4
+ _default_autopath = r'C:\\'
5
+
6
+ def set_autopath(path):
7
+ global _default_autopath
8
+ _default_autopath = path
9
+
10
+ def optimiseWait(filename, dontwait=False, specreg=None, clicks=1, xoff=0, yoff=0, autopath=None):
11
+ global _default_autopath
12
+ autopath = autopath if autopath is not None else _default_autopath
13
+
14
+ if not isinstance(filename, list):
15
+ filename = [filename]
16
+ if not isinstance(clicks, list):
17
+ clicks = [clicks] + [1] * (len(filename) - 1)
18
+ elif len(clicks) < len(filename):
19
+ clicks = clicks + [1] * (len(filename) - len(clicks))
20
+
21
+ clicked = 0
22
+ while True:
23
+ findloc = None
24
+ for i, fname in enumerate(filename):
25
+ try:
26
+ if specreg is None:
27
+ loc = pyautogui.locateCenterOnScreen(fr'{autopath}\{fname}.png', confidence=0.9)
28
+ if loc and clicked == 0:
29
+ findloc = loc
30
+ clicked = i + 1
31
+ else:
32
+ loc = pyautogui.locateOnScreen(fr'{autopath}\{fname}.png', region=specreg, confidence=0.9)
33
+ if loc:
34
+ findloc = loc
35
+ clicked = i + 1
36
+ except pyautogui.ImageNotFoundException:
37
+ continue
38
+
39
+ if dontwait is False:
40
+ if findloc:
41
+ break
42
+ else:
43
+ if not findloc:
44
+ return {'found': False, 'image': None}
45
+ else:
46
+ return {'found': True, 'image': filename[clicked - 1]}
47
+ sleep(1)
48
+
49
+ if findloc is not None:
50
+ if specreg is None:
51
+ x, y = findloc
52
+ else:
53
+ x, y, width, height = findloc
54
+ xmod = x + xoff
55
+ ymod = y + yoff
56
+ sleep(1)
57
+
58
+ click_count = clicks[clicked - 1] if clicked > 0 else 0
59
+ if click_count > 0:
60
+ for _ in range(click_count):
61
+ pyautogui.click(xmod, ymod)
62
+ sleep(0.1)
63
+
64
+ return {'found': True, 'image': filename[clicked - 1]}
65
+
66
+ return {'found': False, 'image': None}
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 AMA Mazing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.1
2
+ Name: optimisewait
3
+ Version: 0.1.0
4
+ Summary: A Python utility for automated image detection and clicking
5
+ Home-page: https://github.com/yourusername/optimisewait
6
+ Author: Alex M
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: pyautogui>=0.9.53
14
+
15
+ # OptimiseWait
16
+
17
+ A Python utility function for automated image detection and clicking using PyAutoGUI.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ # Install from PyPI
23
+ pip install optimisewait
24
+
25
+ # Or install from source
26
+ git clone https://github.com/yourusername/optimisewait.git
27
+ cd optimisewait
28
+ pip install .
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ from optimisewait import optimiseWait, set_autopath
35
+
36
+ # Set default path for all subsequent optimiseWait calls
37
+ set_autopath(r'D:\Images')
38
+
39
+ # Basic usage - wait for image and click
40
+ result = optimiseWait('button') # Looks for button.png in D:\Images
41
+ # Returns {'found': True, 'image': 'button'} if found
42
+ ```
43
+
44
+ ## Usage Examples
45
+
46
+ ```python
47
+ # Override default path for specific call
48
+ result = optimiseWait('button', autopath=r'D:\OtherImages')
49
+
50
+ # Don't wait for image (check if image exists)
51
+ result = optimiseWait('button', dontwait=True)
52
+ # Returns {'found': False, 'image': None} if not found
53
+
54
+ # Multiple click options
55
+ optimiseWait('button', clicks=2) # Double click
56
+ optimiseWait('button', clicks=3) # Triple click
57
+ optimiseWait('button', clicks=0) # No click, just wait for image
58
+
59
+ # Multiple images to search for
60
+ result = optimiseWait(['button', 'alt1', 'alt2']) # Will click first image found
61
+ # Returns {'found': True, 'image': 'alt1'} if alt1 was found first
62
+
63
+ # Different clicks per image
64
+ optimiseWait(['button', 'alt1', 'alt2'], clicks=[2, 3, 1]) # Different clicks per image
65
+
66
+ # Offset clicking
67
+ optimiseWait('button', xoff=10, yoff=20) # Click 10px right, 20px down from center
68
+ ```
69
+
70
+ ## Functions
71
+
72
+ ### set_autopath(path)
73
+ Sets the default path for image files that will be used by all subsequent optimiseWait calls.
74
+ - `path`: String. Directory path where image files are located.
75
+
76
+ ### optimiseWait(filename, ...)
77
+ Main function for image detection and clicking.
78
+
79
+ ## Parameters
80
+
81
+ - `filename`: String or list of strings. Image filename(s) without .png extension
82
+ - `dontwait`: Boolean (default False). If True, don't wait for image to appear
83
+ - `specreg`: Tuple (default None). Specific region to search in (x, y, width, height)
84
+ - `clicks`: Integer or list (default 1). Number of clicks per image (0 = no click, 1 = single, 2 = double, 3 = triple)
85
+ - `xoff`: Integer (default 0). X offset from center for clicking
86
+ - `yoff`: Integer (default 0). Y offset from center for clicking
87
+ - `autopath`: String (optional). Directory containing image files. If not provided, uses path set by set_autopath()
88
+
89
+ ## Return Value
90
+
91
+ Returns a dictionary with:
92
+ - `found`: Boolean indicating if any image was found
93
+ - `image`: String name of the found image, or None if no image was found
94
+
95
+ ## Notes
96
+
97
+ - All image files should be PNG format
98
+ - Images are searched with 90% confidence level
99
+ - Function will wait indefinitely until image is found (unless dontwait=True)
100
+ - When using multiple images, it will try each in order until one is found
101
+ - If clicks is a single integer, it applies to the first found image (others default to 1 click)
102
+ - If clicks is a list shorter than filename list, remaining images default to 1 click
103
+ - Click offsets are calculated from the center of the found image
104
+ - Default image path can be set once using set_autopath() and reused across multiple calls
105
+
106
+ ## Dependencies
107
+
108
+ - PyAutoGUI >= 0.9.53
109
+
110
+ ## License
111
+
112
+ MIT License
@@ -0,0 +1,6 @@
1
+ optimisewait/__init__.py,sha256=C9WfDggY86W8RuRWuZWbe4xmsIFYNhs2l_JxPq9nEYo,2184
2
+ optimisewait-0.1.0.dist-info/LICENSE,sha256=tcT39tGBCeHTMvE5xATcYGe0sqX56uIpk0YzZU8Lb9w,1087
3
+ optimisewait-0.1.0.dist-info/METADATA,sha256=u0me4Qi94Tu2o9tXj51eccYKS3KSfPsQ-3nVq6wIqNY,3810
4
+ optimisewait-0.1.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
5
+ optimisewait-0.1.0.dist-info/top_level.txt,sha256=M9B9FIYnTW9ksN5-M4JEuGSnJ4twcSqL9PAeiEB2o5U,13
6
+ optimisewait-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ optimisewait