from pynput.mouse import Listener, Button
import pyautogui
import time
# Global variable to store the click coordinates
click_coordinates = None
# Function called on a mouse click
def on_click(x, y, button, pressed):
global click_coordinates
# Check if the left button was pressed
if pressed and button == Button.left:
# Store the click coordinates
click_coordinates = (x, y)
print(f'Click position set at: {click_coordinates}')
# Initialize the Listener to monitor mouse clicks
with Listener(on_click=on_click) as listener:
# Wait for the user to perform a manual click
listener.join()
# Check if the click_coordinates are set
if click_coordinates:
# Get the click coordinates
x, y = click_coordinates
# Perform 100 clicks at the specified position
for _ in range(100):
pyautogui.click(x, y)
time.sleep(0.01) # 10 milliseconds between clicks
print('Spamming complete.')
else:
print('No click coordinates set.') Mouse Click Bot | Pyhton kod düzeltme
4
●264
- 23-02-2024, 19:37:28
- 23-02-2024, 20:51:06Koddan bağımsız olarak şunu söylemeliyim ki; genelde böyle hızlı alımlar için borsaların sağladıkları API'lar kullanılır. API kullanırsan her zaman daha önde olursun. Bunun haricinde, eğer ki tarayıcı üzerinden bu işi yapacaksan da selenium gibi web otomasyonları kullanarak yapman yine bu koda göre seni öne geçirecektir.
- 24-02-2024, 15:12:50bir denermisiniz
from pynput.mouse import Listener, Button import pyautogui import time if __name__ == "__main__": # Global variable to store the click coordinates click_coordinates = None def on_click(x, y, button, pressed): global click_coordinates # Check if the left button was pressed if pressed and button == Button.left: # Store the click coordinates click_coordinates = (x, y) print(f'Click position set at: {click_coordinates}') return False with Listener(on_click=on_click) as listener: # Wait for the user to perform a manual click listener.join() x, y = click_coordinates # Perform 100 clicks at the specified position for _ in range(100): pyautogui.click(x, y) time.sleep(0.01) # 10 milliseconds between clicks print('Spamming complete.')