Unable to Maximize Zoom Application using pyautogui - python

I have been working on a small project to automatically join a zoom meeting based on the timings mentioned in CSV file.
I am using the pyautogui library and navigating the mouse to specific coordinates.
The issue that I am facing is that everytime the zoom app opens, i manually have to maximize it.
I have used the following code to maximize the Zoom App window but it doesn't seem to work.
subprocess.call("C:\\Users\\USER\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe")
time.sleep(8)
pyautogui.hotkey('win', 'up')
This seem to work pretty fine on other applications except Zoom, can you suggest any alternative way? Thanks.

You could grab the position of the icon used to maximize the window and use:
pyautogui.moveTo(position)
pyautogui.click()
or you could get a screenshot of desktop with zoom opened, cut it (with gimp or anything like that) to show only the "maximize" icon and use
position = pyautogui.locateOnScreen("ImageOfIcon.png")
pyautogui.moveTo(position)
pyautogui.click()

Related

How can I click buttons in a windows GUI program using python?

I am writing a python script that automates running a program and performing different tasks within the program. My main problem is figuring out how to click buttons and interact with the GUI of the program to be controlled.
I am currently using the pyautogui library and using pyautogui.click(X,Y) to advance through prompts and click on different menus and menu items. The problem with this approach is that I am relying on a separate script to inform me of the coordinates of interest in my environment by telling me the coordinates of where my cursor is hovering. This probably will not work on other machines and just seems like a one case solution.
My question is how can I automate using a program in windows (clicking around) without having to hard code the exact position of the items I need to click?
For example, If I need to click a "ok" box to accept some setting, how can I make Windows grab the program window, read through the options and click what I need without any prior knowledge of the position of the dialog box and where the "Ok" button is located?
Code:
import pyautogui as gui
gui.click(x,y)
The way you can do this using pyautogui is with their locating methods. You will need a picture (for example of the OK box) and then you can have pyautogui find it on the screen and give you its coordinates. Check out the official documentation on this.

how to get mouse to click specific(s)

I'm trying to write a code to control where the mouse clicks. currently, I have the code to press Win + X.
I am trying to figure out what would need to be done in order to have the mouse clicks work accurately despite the screen size/number of screens.
import keyboard
winx = keyboard.press_and_release("windows + x" )
As the code stands the current click I need is to click system. I will need to click other things throughout the full code but currently figuring out the best way to click "system" is the goal. I've tried clicking based on the location but because of multiple screens/ the size of the screens this isn't accurate.
Currently looking into how to implement pyautogui's image recognition will update as I go.

Pyautogui click won't register click on window of application on my desktop

My code will locate the window with a picture and then move the mouse to the correct position but the click doesn't actually register on that window. The window does register when I click on it manually (like normal).
img = pyautogui.locateCenterOnScreen(img location)
pyautogui.moveTo(img)
pyautogui.click()
Some applications, like certain video games, have protection against this kind of stuff. The solution is to build an exe and run is as admin. Try that. This tutorial worked for me:
https://towardsdatascience.com/how-to-easily-convert-a-python-script-to-an-executable-file-exe-4966e253c7e9

How to get tootip(infotip) text in python? (a popup text box appearing when a mouse cursor is hovered on)

I am currently working for an automatic screen capture program in Python3. While developing it, I ran into a couple of issues on Windows tooltip(infotip) boxes.
What I need to do is this:
1. First I need to find out whether there is any tooltip(infotip - a small text box appearing when a mouse cursor is hovered on an icon or a button) at a specified mouse coordinates. (e.g.) When a mouse cursor is moved to (300, 300) in the main monitor and hovered for a while, does a tooltip box appear? I hope I can get the result with a boolean variable if possible.
2. (main problem) If there is a tooltip, how can I get the content(text) in it?
I have tried solving the problems using pywinauto module, but as there is not much documentation about it so I am completely stucked... Can anyone help me with this? Using pywinauto module is not necessary if there is an easy way!!
Thanks in advance!!

Taking a print screen of a particular window using PIL using Python

I want to take a print screen of a particular window on my PC by running the python program and it taking that screen shot, before cropping it and comparing its hex value to other hex values in a SQL server.
I have thought about letting it wait 10 seconds whilst I get the other window up and then start taking the print screens continuously until one matches.
I was just wondering if I can use python to maximize that particular window that I want to print screen automatically and then have it take a print screen.
If not, could I take a print screen (a picture) of a window that is minimized? (I think this is impossible)..
Thanks!
If you do a quick Google search, you will find this helpful tutorial that uses PIL to take a screenshot of a desktop:
http://www.blendedtechnologies.com/quick-screenshots-script-python-pil/38
Assuming you're on Windows, you would need to use PyWin32 (or possibly pywinauto) to get the window you want. These two links will help with that:
Get HWND of each Window Python
http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html
Then you could use MoveWindow to resize the window you found before taking the screenshot:
How can I get the window focused on Windows and re-size it?

Categories