Search code examples
pythonwinapihotkeys

Why is win32api.GetAsyncKeyState not a global hotkey?


I'm trying to make a bot that automatically moves the mouse to a specific location. Only problem now is that the function was global, but now isn't anymore for some reason.

import mouse  
import configparser   
import win32api


hexstring = config.get("keypress", "keypress")
an_int = int(hexstring, 16) 

if win32api.GetAsyncKeyState(an_int)  < 0:
   mouse._os_mouse.move_relative(int(xcoord), int(ycoord))

Solution

  • I found the error. I just needed to open the application as an administrator.