Is there a way to run Python? If I don't press the program when I'm playing a game, is there a way to press a certain button, for example, to play a screen or to play a song? Like a shortcut. Is this the right way to do things in the background?
What I want is to be able to create a program that runs [e.g. playing a song] when I press a certain key that I set in my Python code while using another program Also, is it possible to run it and not let it fall into another program, but just play the song that I've done?
python
There is a method, but it should be viewed as a system programming area.
In other words, you should use the function provided by os, not the Python function.
For Windows, use ctypes to register using the Register HotKey function of user32.dll and release it using Unregister HotKey.
Moreover, there is a problem if you set it incorrectly.
In other words, if you are using a program called A and you set the shortcut used in the program called A, the shortcut using the Register Hot Key will be ignored. Of course, it performs the shortcut of program A.
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registerhotkey
Refer to the above link.
© 2024 OneMinuteCode. All rights reserved.