How to make button presser on Python - python

I have a question, is it possible to use python to make it so that when pressing the right mouse button, some key on the keyboard is pressed (for example, the G key)

Not sure if this is the best place to ask such question but I'll answer and whatever happens to the thread happens.
From my experience, I think the easiest and most accessible module for keyboard control would be 'keyboard' by BoppreH. I've used it and had no issues. Good cross-platform choice for Windows and Linux, if that's a consideration.
Here are a couple of resources. Should be easy enough to integrate.
A friendly suggestion for next time, friend. Please try looking online first. Happy Coding :)
https://pypi.org/project/keyboard/
https://github.com/boppreh/keyboard

Related

Can I make an autoclicker, only using the standard library?

I am new-ish to python, so bear with me here.
I would like to make an autoclicker that would work on any device with IDLE, if I copy/paste the code, whether or not it has extra libraries (modules?) tacked on.
If it helps, this is for a 2014 MacBook Air.
Ideally, it would look something like this:
if key is pressed:
active = True
while active is True:
(simulate mouse click)
I've seen a similar question, but everyone suggested PyAutoGUI, which is not in the standard library.
I'm not sure whether it's possible to do this, however.
It's pretty simple, except I have no idea how to actually do it.

Key repeat in browser from python code

Note : I am pretty surprised I did not see that same question on this forum, if I missed it please link in comment :)
I am writing a bot in python that would eventually be able to play a browser-based video game (HTML5 canvas game, not Flash). In order to do that I need to simulate the keyboard events from the python code.
I thought pyautogui would do the work, but unfortunately it seems the only way to repeat a key is to do pyautogui.press(key) in a loop, and it is not good at all for playing games as the move is not smooth at all.
I found some solutions for Windows, but I need a solution for macOSX.

Sound on [every global] keypress (linux)

im trying to find/write a simple daemon in python (preferably) to play a sound on every key pressed, for usability purposes. Something like this https://www.grc.com/freeware/clickey.htm but for Linux.
Ive found some codes around but still cannot put them together. If you guys could point me in the right direction, it would be great
Thanks for your help.
I think this will give you easiest work around:
http://www.speech.kth.se/snack/
After this you can use following code:
s = Sound()
s.read('mymusic.mp3')
s.play()
Good thing is that it works on both windows and linux.
I've found the Qwertickle typewriter sound scheme pretty easy to learn and modify for own needs. Here is my version with pc keyboard sounds :)

Is there a way I can use Python to control the size and position of a Mac Window?

Generally I want to write a program to run in the background on Mac and when I push a keyboard shortcut, the current active window would be resized and positioned to the way I have set.
Something similar to the tool called SizeUp on Mac. I think this shouldn't be difficult to implement and would be fun to take a try.
I would appreciate any resources you could point me to. Thanks.
I think you're going to have an easier time attacking this in applescript. Upon casual googling, this link seems to have more or less what you want. If you were more looking for a programming challenge in python, and less for a solution, then disregard this.

How to get in python the key pressed without press enter?

I saw here a solution, but i don't want wait until the key is pressed. I want to get the last key pressed.
The related question may help you, as #S.Lott mentioned: Detect in python which keys are pressed
I am writting in, though to give yu advice: don't worry about that.
What kind of program are you trying to produce?
Programas running on a terminal usually don't have an interface in which getting "live" keystrokes is interesting. Not nowadays. For programs running in the terminal, you should worry about a usefull command line User Interfase, using the optparse or other modules.
For interative programs, you should use a GUI library and create a decent UI for your users, instead of reinventing the wheel.Which wouldb eb etter for what you ar trying to do? Theuser click on an icon,a window opens on the screen, witha couple of buttons on it, and half a dozen or so menu options packed under a "File" menu as all the otehr windws on the screen - or - a black terminal opens up, with an 80's looking text interface with some blue-highlighted menu options and so on?. You can use Tkinter for simple windowed applications, as it comes pre-installed with Python + Windows, so that yoru users don't have to worry about installign aditional libraries.
Rephrasing it just to be clear: Any program that requires a user interface should either se a GUI library, or have a WEB interface. It is a waste of your time, and that of your users, to try and create a UI operating over the terminal - we are not in 1989 any more.
If you absolutely need a text interface, you should look at the ncurses library then. Better than trying to reinvent the wheel.
http://code.activestate.com/recipes/134892/
i think it's what you need
ps ooops, i didn't see it's the same solution you rejected...why, btw?
edit:
do you know:
from msvcrt import getch
it works only in windows, however...
(and it is generalised in the above link)
from here: http://www.daniweb.com/forums/thread115282.html

Categories