(If you enjoy this scipt, download it, or find it interesting in any way please conisder giving the repo a star. It will help more people find it, and help the community in improving it.)
[v1.1] - 2024-05-07 Added
1.Modularized the code into smaller functions for better organization and readability. 2.Added error handling to gracefully handle potential exceptions during image processing. 3.Added documentation comments (docstrings) to explain the functionality of each function. 4.Optimized certain parts of the code for better performance.
Changed
1.Refactored the main loop to improve readability and maintainability. 2.Cleaned up unnecessary comments and redundant code.
Removed
3.Removed redundant comments and unnecessary print statements.
This Python script searches for specific images on the screen and clicks on them if found. It can be useful for automating tasks where specific images need to be located and interacted with on the screen, such as in game automation or UI testing.
IMPORTANT NOTE:This Python code is compatible with the Windows operating system. This is because it relies on the win32gui and win32con modules, which are specific to Windows. Additionally, it utilizes the pyautogui library, which is compatible with Windows, macOS, and Linux, but the specific functionality used in this code (screen capturing and clicking) is primarily intended for Windows. Therefore, while the script may technically run on other operating systems, its functionality may be limited or behave differently on non-Windows platforms.
- Python 3.x
- OpenCV (
cv2
) - NumPy (
numpy
) - PyAutoGUI (
pyautogui
) - Keyboard (
keyboard
) - Win32gui (
win32gui
) - Win32con (
win32con
)
- Clone the repository to your local machine. (Or click on code, then download zip.)
- Ensure you have all the required libraries installed. You can install them using pip: pip install opencv-python numpy pyautogui keyboard pywin32
- Replace the paths in the
image_paths
list with the paths to your actual images. - Run the script using command prompt
- Press the 'q' key to stop the script at any time.
- Make sure the images you want to search for are available in the specified paths.
- Adjust the threshold value as needed for accurate template matching.
- This script may require adjustments based on the specific requirements of your task.
Contributions are welcome! Feel free to open an issue or submit a pull request.
Made by 2cz5. For any questions or suggestions, you can reach out to me on Discord:2cz5