0

So I have a shortcut for a script on my desktop that can also be activated by a keybind (ctrl+shift+1).

The script is a python autoclicker that utilizes threading & pyautogui.

This keybind works if I'm doing something in firefox for example, but for whatever reason when I try to use the same keybind in Gmod, it doesn't run at all.

I have tried other keybinds for it like ctrl+alt+1 and that didn't work either. I also wanted to add that I don't think its anything with the game trying to block the script from running, cause if I run the same script manually and then alt tab to Gmod it works just fine.

Edit: in case it helps this is the script

from threading import Thread
import time
import pyautogui

#defines a bunch of 'blocks' that click 10 times

def opauto101():
    for i in range(10):
        pyautogui.click()

def opauto102():
    for i in range(10):
        pyautogui.click()

def opauto103():
    for i in range(10):
        pyautogui.click()

def opauto104():
    for i in range(10):
        pyautogui.click()

def opauto105():
    for i in range(10):
        pyautogui.click()

def opauto106():
    for i in range(10):
        pyautogui.click()

def opauto107():
    for i in range(10):
        pyautogui.click()

def opauto108():
    for i in range(10):
        pyautogui.click()

def opauto109():
    for i in range(10):
        pyautogui.click()

def opauto110():
    for i in range(10):
        pyautogui.click()

def opauto111():
    for i in range(10):
        pyautogui.click()

def opauto112():
    for i in range(10):
        pyautogui.click()

def opauto113():
    for i in range(10):
        pyautogui.click()

def opauto114():
    for i in range(10):
        pyautogui.click()

def opauto115():
    for i in range(10):
        pyautogui.click()

def opauto116():
    for i in range(10):
        pyautogui.click()

def opauto117():
    for i in range(10):
        pyautogui.click()

def opauto118():
    for i in range(10):
        pyautogui.click()

def opauto119():
    for i in range(10):
        pyautogui.click()

def opauto120():
    for i in range(10):
        pyautogui.click()


#-------------------------------------------

#this was originally based on a prompt to click 10, 100, 1000 etc times so i just changed it to if 1 = 1

true = 1
if true == 1:


#this calls the 'blocks' defined earlier through multithreading
    Thread(target = opauto101).start()
    Thread(target = opauto102).start()
    Thread(target = opauto103).start()
    Thread(target = opauto104).start()
    Thread(target = opauto105).start()
    Thread(target = opauto106).start()
    Thread(target = opauto107).start()
    Thread(target = opauto108).start()
    Thread(target = opauto109).start()
    Thread(target = opauto110).start()
    Thread(target = opauto111).start()
    Thread(target = opauto112).start()
    Thread(target = opauto113).start()
    Thread(target = opauto114).start()
    Thread(target = opauto115).start()
    Thread(target = opauto116).start()
    Thread(target = opauto117).start()
    Thread(target = opauto118).start()
    Thread(target = opauto119).start()
    Thread(target = opauto120).start()

  • what is `Gmod` ? – D.L Sep 26 '22 at 11:43
  • also, you could reduce the example to just two or three functions: https://stackoverflow.com/help/minimal-reproducible-example – D.L Sep 26 '22 at 11:44
  • `Gmod` is shorthand for a game, Garry's Mod. Have you see this answer? https://stackoverflow.com/questions/45295482/pyautogui-dont-work-in-game-window Pyautogui doesn't work well with DirectX games. – Cold Fish Sep 26 '22 at 21:26

1 Answers1

0

have u checked this answer ? pydirectinput module

another answer

this is all i could find about making actions in DirectX games sometimes some games run in administrator mode make sure ur script do it too!

Basem Ayad
  • 19
  • 5