I was messing around in a Roblox game testing out a simple click script I made using Python that just repeatedly clicked while the player was in the game. I noticed that even though the mouse went to the desired location, the mouse icon didn’t change to indicate that the button was clickable and it didn’t appear to be clicking the button. I tried clicking multiple times without moving my mouse but it still didn’t process. After a bit, I moved my mouse and clicked it and it worked. I wondered why this had happened and tried it again. Same result, only working after I moved it myself. To see if this was something happening only on the Roblox client or Windows, I tried it on another app and it worked.
Does Roblox have anti-automation to detect whether keypresses are legitimate? I tried writing a script that randomized mouse movements on a path to the destination and It still wasn’t able to click.
from pynput.mouse import Listener
import pyautogui
import keyboard
import random
import time
x, y = pyautogui.size()
def on_click(mx, my, button, pressed):
global x, y
print(x/mx, y/my)
def get_location():
with Listener(on_click=on_click) as listener:
listener.join()
def click_ratio(xr, yr):
global x, y
time.sleep(0.05)
mx, my = pyautogui.position()
slope = (abs(abs(y/yr)-my))/(abs(x/xr)-mx)
y_intercept = my-(slope*mx)
print(f'Slope: {slope}\nY-Intercept: {y_intercept}')
ratio = (abs(x/xr)-mx) / 10
print(f'Ratio: {ratio}\nEnd Coordinates: ({(x/xr)}, {(y/yr)})')
points = []
c = 1
for i in range(10):
if my < y / 2:
yl = slope*(mx+(c*ratio))+(y_intercept+float(f'0.{random.randint(1, 9)}'))
else:
yl = slope*(mx-(c*ratio))+(y_intercept+float(f'0.{random.randint(1, 9)}'))
points.append((mx+(c*ratio), yl))
c += 1
for point in points:
xloc, yloc = point
pyautogui.moveTo(xloc, yloc)
for i in range(10):
pyautogui.click(x/xr+random.randint(-2,2), y/yr+random.randint(-2,2))
time.sleep(0.05)
def surface():
click_ratio(1.0491803278688525, 1.6981132075471699)
if __name__ == '__main__':
# get_location()
while True:
try:
if keyboard.is_pressed('z'):
break
except KeyError: pass
# main loop
time.sleep(0.5)
surface()