Python - Passing keyboard input to a process - python

Alright, so I got a question and hopefully you guys will be able to help me out with this.
Basically what I'm trying to do is this:
Read what users write in Skype (using the Skype4Py lib).
Convert specific lines from users into a keyboard event.
Pass keyboard events to another (non-python-related) process (.exe) running locally.
Now the first two bullets are definitely doable but I'm not really sure how one would go about the last one. I'm assuming it's possible but I have absolutely no clue which module(s) I would need. If anyone has suggestions, modules or even examples for the last bullet I would very much appreciate it.

Related

Is it possible to write a program that checks if a pinned comment is present under a Youtube video every certain period of time? (using python?)

I'm not asking for someone to write out specific codes for me, but rather just point me towards the general direction.
Sometimes after writing and pinning a comment under a Youtube video, it disappears!
It may happen hours later, it may happen a few minutes later, all randomly. Then re-appears hours later, not sure why.
Since I am currently learning programming (python), I might as well try to tackle the problem myself. I want to make a program that regularly checks if the pinned comment is still present, and if not, send me an alert in whatever way so I can go write and pin a new comment for the time being. (and maybe learn a few things during the process)
So far I learned some basic stuff like how to get source code from a webpage, output it to somewhere like a txt file, and also searching with Regex. However when I check out the source code of a Youtube video, the comments text aren't there. Where do I begin learning about the necessary things needed to make this program work?

Run a counter in the background

Im trying to create an upgrader/tycoon game and realised to have the money continuously going up, I would have to start a different process so I can have my GUI which can be used as the money goes up without either stopping the other from working.
What is the best way to do this?
I've looked around on this site and nothing I could find has helped me!
(If you need any more information just let me know!)
Use threading.
Python has a module named threading, and you need
threading.Thread(target=somefunc).start()
My old answer in the same topic: Here.
If you consider adding some code to your question, I am happy to help in threading! Also, if you need help in designing the code, feel free to ask, threads can be messy.

Create a Program in Python with a Node conection GUI

I want to create a program with a GUI using Python. This program should show a list of nodes somewhere and allow me to insert them on a working diagram. I also need this nodes connected in some sequence. The following image is similar to what I need, it's from Orange3.
I come from a web development background and I've used Python for some Data Science but all using Terminal so right now I feel a little lost on where to get started.
I would much appreciate some help on where to look. Also I would like to use, if possible, existing tools instead of having to develop everything from scratch. Maybe there even is a project that does what I need and I could fork it from Github.
Thanks a lot for the help.
Check out Tkinter. Its great for GUI. Hard to add in images though. You could use Base64 to add in images.
There are plenty but it's best to create it yourself. There are infinite tutorials. Besides its gonna be full of bugs if you try to alter code that isn't yours.

Python - try for a set period

I Apologise for being a noob - both to asking questions, and python.
I've writen a program, which will be running full time. I have that working ok. It uses the try function to look for an input from a touchscreen.
I now wish to try for 30s,and if there is no input, jump to a blackscreen routine (screensaver), from which it will be looking for any touch to go back to the original try
I think i need an except routine, but i'm tying myself up in knots working out with where to put everything.
Any guidance appreciated
edit
this is Python for use on a raspberry PI.
all i have in code now, is the basic try as follows.
while(True):
try:
get_call()
except SystemExit:
the get_call() routine, sets up some pygame screens, then looks to an on_click() routine for touchscreen input.
I wish to try to get_call() for 30s, and if nothing happens from that, go to screensave()
I know its not much to go on, my code is that of a self taught noob, with no knowledge of best practices, or decent formatting. If anyone wants to look through what i've done, i'll happily zip it all up, and send it through.

Use Python script to check whether or not a program is hung/crashed in Windows? Also, Pipes

I have 2 questions, so I figured I would cram them into 1 single post instead of filling the board up with useless information
Simple description of situation: I am attempting to create a python script that opens an executable for a simple C++ program with an unknown number of inputs in a windows environment, sends some data into that program, and then check to see if it has crashed / rinse and repeat.
Question 1: This is a pipes question. Bear with me, I am still learning about pipes, so I may have a misunderstanding of exactly how they work. Forgive me if I do. Is it possible to detect how many inputs a program has? Basically what I'm attempting to do is open an executable using my python script, that I personally know nothing about, and send in garbage data into each available input. If it is NOT possible to detect how many inputs there are: would there be an adverse reaction (like crashing the program Im sending the data into) if I send more arguments into it than there are inputs? As in the C++ program takes 3 inputs and I send in 6 arguments?
Question 2: Does anyone know if it possible using a python script to detect whether a program has hung or not? So far the best information on this I've been able to find is simply detecting whether the program is running or not via FindWindow, and then I suppose I could monitor the CPU usage to see if it continues to rise... but that is hardly an ideal method (and may not even work properly!) If there are any better known methods out there I would be thrilled!
Thanks for your time :)
An Answer to Question 2
You should look into investigating psutil, hosted # https://github.com/giampaolo/psutil . I don't know whether you'll find what you're looking for, but pusutil is a decent API, offering access to info such as number of CPUs in addition to process information, which is what you want.

Categories