Whats the best Python library to automate an external program
We have accounting software where we need to upload many files into for a particular reason. To do this we search for the relevant menu item right click it and then import. This is time consuming. It would be useful to be able to automate this. Ive looked at pyautogui but it needs the screen to be active and the user cant do anything else on their machine while it is running.
Of course ideally I would like to use the accounting software's API (if there is one) or find out if the upload is running a stored procedure at the back end taking the filepath as a parameter and then calling this procedure myself.
In the absence of those would anyone know if there is a way to automate this in Python without the limitations above or if not in Python what other language would be good for this?
Many thanks
I haven't done such thing. So I do not have proof of concept. But
You have at least 2 options, more or less complicated:
install virtualbox/vmware, and create virtual operating system (windows or Linux) on it. Then run your pyautogui script in this virtual operating system. You operating system is available in window-like container - so you can minimize this window with running script, and you system where you can interact as a user. (long tutorial: https://www.virtualbox.org/manual/ch01.html)
If you are Linux user, then you may be familiar with virtual screen. I think many people are using this virtual screen with automating web testing in sellenium (How do I run Selenium in Xvfb?). So probably, I say probably, there is chance to run pyautogui in virtual screen: How to attach pyautogui to the virtual display? - this is similar, but not answered question.
Related
I am unfortunately an absolute beginner in programming.
First of all, I'm programming with the PyCharm IDE on a Windows computer, but the script will later run on a RaspberryPi.
I want to turn on my TV with a Python script via HDMI-CEC and I came across libcec.
However, I can't figure out the setup instructions for Windows.
https://github.com/trainman419/python-cec
Can anyone give me a step by step guide on what exactly I need to do to use the CEC commands in Python?
Or should I program with PyCharm directly on the RaspberryPi? This one is way too slow for this task in my opinion. Then I could install the CEC library very easily.
Thanks for your help.
I know this is too greedy, but i want to make python interact with a program´s user interface but on the background, so that i can still use my computer while the code runs. I am currently using pywinauto and pyautogui. So I can´t work while the code is running because my mouse and keybord are being manipulated. Does someone know how to make my code manipulate a "second" mouse and keyboard on the background while I use my mouse and keyboard to do other things?
The most common way to do this is a remote execution (on dedicated server or on virtual machine). All known recipes for pywinauto are collected in the Remote Execution Guide.
More complicated way is trying to use silent methods of pywinauto that don't require active desktop. This is partially mentioned in the above guide, but requires deep knowledge of pywinauto and your application structure. One of the examples was discussed on StackOverflow: https://stackoverflow.com/a/32847266/3648361 This way is not possible for many kinds of applications.
I've never heard about "second mouse/keyboard" approach. Not sure it's technically possible at all.
I'm looking for an equivalent Python library that will work when I run my script on Raspberry Pi. I'm under the impression that pywinauto only works on windows machine.
I want to control some inputs to a GUI launched by my script, using my script. Apart from pywinauto I have no idea how to do this. I thought about using command line to control the software directly, but if there is a simpler way I would really appreciate knowing about it.
Thanks for your time.
ATSPI is an Linux accessibility technology to obtain GUI text/rectangle properties programmatically. See how to find and run ATSPI registry daemon and how to enable ATSPI for the most popular types of GUI apps. Usually it's
$ /usr/libexec/at-spi-registryd &
There is a Python bindings for ATSPI. See this answer for details:
How to install pyatspi?
The pyatspi package has too many dependencies like pygobject etc. It also requires some compilation during installation steps. We think this is not user friendly so we decided to use libatspi.so directly (without any dependencies). This work status can be tracked here: https://github.com/pywinauto/pywinauto/pull/449
There is no exact deadline for pywinauto 0.7.0 with this feature (it's a hobby project), but I would say this summer sounds realistic.
I'm sure many of us have seen vision degradation from too much screen time from programming.
A theory suggests that when they eyes become fixed, tension builds. And that tension causes the vision to slowly degrade.
This software promises to prevent that fixation...
http://www.central-fixation.com/downloads.php
The problem is it's outdated, and Windows only.
I'd like to write a script that will "swing" all open windows according to a set pattern & speed. A script that works with OSX 10.9 and later.
I know Python and Javascript but have no idea where to start on this.
Please help me out.
How is it done? What language is used to manipulate OSX application windows? And/or simply manipulate the whole desktop window space?
I haven't tried to do exactly what you are trying to achieve here, but ANYTHING at all related to manipulating OS X should be done via Automator or AppleScript. If you are running Yosemite, the app is called "Script Editor". Anything older and it's called "AppleScript Editor".
Try this site.
Extract:
tell application "Finder" to set the position of the front Finder window to {94, 134}
I know your question is labeled "python" but I believe that AppleScript is the way to go with this.
You can add AppleScript to an Automator workflow with the "script" object. I'm not sure how to make this run periodically, but one option would be to keep it open in the background. You can do this in AppleScript with the delay command:
(do stuff here)
delay (your delay)
Hope this achieves your purpose.
I have written a program. I don't know if it is important how it is written but you can find it here: http://pastebin.com/Z3ZvVPV8 Basically, it asks you to assign values to variables and will perform calculations depending on what variables you chose, and prints the answer.
I would like to know how I can make the program run in a window other than cmd (I am using Windows Vista 32bit). I don't need much at all in terms of GUI, just a window that is a bit more user friendly/easier to look at when they are using the program.
EDIT: To those suggesting using IDLE, while that would work for me, if others want to use the program they would have to download it, so I was hoping for a way for that not to happen.
Python comes with a sort of default GUI package TkInter you can use it.
Also there is a lot of other GUI packages available.
The Python standard library offers a lot of ways to implemt simple (but also rather complex) GUIs. I'd like to point you at the documentation of TK (tool kit for graphical interfaces) http://docs.python.org/library/tk.html where you will find also some useful example of use.
Py2Exe is a viable option if you really don't need a gui. This will make it run and look like a command prompt, but it will be an .exe file. Here is a quick quote from thier page: "py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation."
Another alternative is to get Portable Python. Here is a quote from thier webpage: "Portable Python is a Python® programming language preconfigured to run directly from any USB storage device, enabling you to have, at any time, a portable programming environment. Just download it, extract to your portable storage device or hard drive and in 10 minutes you are ready to create your next Python® application." After packaging the portable python and your .py or .pyc file then create a .bat file that runs the portable python "Python-Portable.exe" with the correct command line parameters for loading your script. Be sure to use relative paths in the batch file in case they are running it from a flash drive, or something other than the same location as you.
NOTE: This is really not a good way to do this as thier download page states: "Installed size: based on selected packages, between 49MB and 480MB". Also be sure to read the the current Python Software Foundation License, as that is what Portable Python is released under, and it may or may not be legal to package it in a closed source project. I haven't really looked at the license myself to be able to tell you. If you are releasing it as open source, then there would not be an issue though. As a quick side note, if you need that .bat file to be a .exe file then you can use a .bat to .exe converter battoexe.com is one. This is really going the long way about doing the whole thing, but it is an option.
Sources:
Working with Python on and off for 7 years now, a lot that using a portable version on a flash drive, and also dealing with Batch files much longer.