Pyautogui for different resolution - python

I have done an automation using python by importing pyautogui module (using coordinates). It is working fine. Now, I am running the same code on my Laptop. It is not working as expected due to change in coordinates. I don't want to change the coordinates according to my Laptop resolution. I need to generalize the code. So that it should work in any system. Please help me. Thanks in advance

Related

Interactive plot with Matplotlib in web browser for anyone to run

I have made a script in Python to visualize the intersection of a line between two points and 2 circles. The code runs really well but I'd like to also be able to share this with people who don't have to install python or library to run it. Like in a web browser.
I have found a library called mpld3 that could do the job but unfortunately the sliders that I used don't work at all, and they are glitched for some reason. The glitch in question
So I was wondering first if mpld3 was a good solution and if so, how can I solve my problem? I really can't find anything online related to my issue so it's really bothering me. Thanks in advance.

Python Screenshot Unable to Pick Up Program

I am trying to take a screenshot of a program via Python for OCR. The screenshot picks up everything except the desired program and its children windows. I am in Windows 7, and the Windows screenshot function works perfectly.
So far I have tried PIL, Pillow, and Desktopmagic - the latter two are based on PIL, so it is no surprise to me they do not work when PIL does not work.
I am open to any ideas that may work.
Additionally, if possible, I would like to understand why this is happening.

Place an image in a specific locaton on a windows desktop using python

I wish to use python to place an image (say jpg or bmp) at a specific location on my Windows 7 desktop. I would also like the ability to drag it around using the mouse and for the python code to store it's final locations coordinates. So when Windows restarts (with the python code configured to run at startup), it reads the stored location and places the image back at its previous location.
Is this possible to do?
If it is, could someone please provide some suggestions on how to do it, as my python experience is pretty limited?
Thanks.
You need to use LVM_SETITEMPOSITION for arranging icons on the desktop.
There are a similar questions:
How can I programmatically manipulate Windows desktop icon
locations?
win32 programming
Python is not the best choice for this job, but if it's required try to look in to - commctrl, win32gui, and pywin32 libraries

Python Raspberry PI PyGame Audio error - just a click [duplicate]

I'm quite new with raspberry pi and am very new but I am trying to play an audio file through a python file on a pi B. I played the audio from the command line using omxplayer and it worked fine but when i run the following code it plays only static.
from pygame import mixer
mixer.init()
wow = mixer.Sound('Wow.mp3')
wow.play()
time.sleep(5)
I tried using mixer.load('Wow.mp3') and other variations but still only get static. I tried putting things in the init like mixer.init(4800, -16, 1, 1024) and using pre_init but to no avail. I also tried adding disable_audio_dither=1 to config.txt. Any and all help would be greatly appreciated thank you very much.
Sometimes if sound is supposed to be playing but isn't, and the speakers are turned all the way up, it will play static instead. This is probably a computer problem, not a pygame problem. Check whether audio plays in other locations. If it does not, it is definitely a computer problem.
If using Linux (you probably are, Raspbian is a variant of Debian which is Linux), and you have identified that it is a computer problem, try initializing ALSA by typing alsactl init as root in the Linux Terminal. If this does not work and the above is true, then you are having some audio problems that will take a bit of research to fix.
If audio does play in other locations, then it is probably a file format issue. It's possible that the bitrate is different, the format is wrong, etc. Also, here is a quote pulled directly from Pygame documentation:
Be aware that MP3 support is limited. On some systems an unsupported format can crash the program, e.g. Debian Linux. Consider using OGG instead.
https://www.pygame.org/docs/ref/music.html
Other than this, there isn't much we can do to help you. A problem like this that isn't fixed by the above is usually a problem specific to very few computer setups. You will probably have to do some personal research.
If you need any more help, please notify me in the comments.

Why is OpenCV python crashing in Windows?

I am running OpenCV2.2 on Windows 7 64-bit.
I built OpenCV using cmake with MinGW 32-bit.
I have no problem with the C/C++ build. However the python bindings seem to have some problems. Most of the python samples are crashing.
The HighGui functions seem to cause trouble. Python crashes when I try to read an image (using imread, LoadImage or LoadImageM), display an image (imshow or ShowImage) or even create and manipulate windows (NamedWindow, MoveWindow, etc).\
WaitKey doesn't crash python but it always returns a -1 immediately, no matter how long the delay I provide. Similarly imgproc functionality listed under "Image Filtering" in the reference seem to crash python. I haven't been able to test it with too many other functions, mainly because I can't load in images and I am forced to test it with matrices i have built myself.
I am currently using python 2.6.6 (32-bit) , but I got the same problem with python 2.7 (32-bit). I also tried building the python wrappers for OpenCV2.1, and I got the same problem. It's very likely a problem specific to my setup. I've been cracking my head against this problem for quite some time now, I would appreciate any help.
Thanking you in advance.
Regards,
Anush.

Categories