0

I'm checking if the game is active and If it is I'm trying to hide the mouse cursor just for comfort reasons since it annoys me. But I can't find any way to do it... Any suggestions? I'm pretty new to Python.

import psutil
def isRunning(name):
    for pid in psutil.pids():
        prcs = psutil.Process(pid)
        if name in prcs.name():
            return True

while(isRunning("Brawlhalla")):
    # do stuff here
miike3459
  • 1,431
  • 2
  • 16
  • 32
Omer H.
  • 1
  • 1

1 Answers1

0

You could do this using an external program. If you are under Linux, check unclutter (https://packages.ubuntu.com/bionic/x11/unclutter for example - if you are using ubuntu).

This answer lists other ways to hide the mouse cursor more or less permanently.

By the way this is not strictly speaking a Python question, and using a python script is probably not the proper way to achieve what you want... You'd better launch unclutter or one of its friends from a console and be done with it.

But assuming you really insist on using Python and your isRunning() code is correct, one naive way to implement what you want in python could look like this (leaving aside corner cases handling):

from time import sleep
import subprocess

(your isRunning code here)

proc = subprocess.Popen(["unclutter", "-root", "-idle", "0"])
while (isRunning("Brawlhalla")):
    sleep(1)
proc.terminate()
Seb
  • 26
  • 3