I'm trying to make a python bot for zoom.us, but to join a meeting, zoom tells us to download an application and to join the meeting from there. Is there any python module like selenium but to control desktop apps? I found PyAutoIt, but is there anything better?
Didn't understand entirely what you're planning to do, but maybe pyautogui can be helpful too
You have to download the zoom app for desktop and use the 'pyautogui' module to automate the GUI of zoom app. here is a script that I wrote to automate mine. edit the positions of the app according to your machine
import pyautogui
import time
pyautogui.FAILSAFE = False
class ZoomOpener():
def __init__(self, meeting_id, password):
self.meeting_id = meeting_id
self.password = password
def main(self):
# clicks on zoom logo in the task bar and opens it
time.sleep(1)
pyautogui.click(550, 800, duration=0.2)
# clicks on join button
time.sleep(2)
pyautogui.click(x=550, y=317, clicks=2, interval=0.2)
# types the meeting id
pyautogui.typewrite(self.meeting_id,interval=0.06)
# clicks the join button
time.sleep(2)
pyautogui.click(x=690, y=487)
# types the password
time.sleep(5)
pyautogui.click(x=550, y=317, clicks=2)
pyautogui.typewrite(self.password, interval=0.06)
# clicks the join button
time.sleep(1)
pyautogui.click(x=690, y=487, clicks=1)
# final joining
time.sleep(5)
pyautogui.click(x=900, y=590, clicks=2, interval=2)
if __name__ == '__main__':
time.sleep(10)
zoom = ZoomOpener('9656400024', '123456')
zoom.main()
Related
I am making my own autoclicker. But its can not clicking. I try all alternatives which ones in stackoverflow. Is there a any helper please.
My Code:
import pyautogui
import python_imagesearch.imagesearch
import time
while True:
icon = python_imagesearch.imagesearch.imagesearch("clickme.png", 0.8)
print(icon)
icon_x = icon[0]
icon_y = icon[1]
icon_x = icon_x+5
icon_y = icon_y+5
# time.sleep(1.5)
pyautogui.leftClick(icon_x, icon_y)
time.sleep(0.1)
pyautogui.leftClick(icon_x, icon_y)
time.sleep(0.1)
I am trying the click here.
https://www.tetralark.com/ClickerJs/
It's solved. It is about other games anticheat blocking.
If your code is moving to your image already, you can click in the image by using:
pyautogui.click()
Or you can pass coordinates as Mouse Control Functions says:
pyautogui.click(x=100, y=200) # move to 100, 200, then click the left mouse button.
I would like to know how to do in python/Pyside2:
Create a QSystemTrayIcon with a custom icon, in which:
If I click left button on it, I do a custom action (just print “left click pressed”). No menu should be shown...
If I click right button on it, a context menu appears with an exit action on it, just to close the program.
On MacOS, maybe not in win nor linux, the menu just opens on mouse press... That's why the need of left and right click differentiations
otherwise both actions will be done with left and right click. See note here: On macOS... since the menu opens on mouse press
I need help just implementing the left and right click differentiations in the following code:
from PySide2 import QtWidgets
import sys
class SystrayLauncher(object):
def __init__(self):
w = QtWidgets.QWidget() #just to get the style(), haven't seen other way
icon = w.style().standardIcon(QtWidgets.QStyle.SP_MessageBoxInformation)
self.tray = QtWidgets.QSystemTrayIcon()
self.tray.setIcon(icon)
self.tray.setVisible(True)
self.tray.activated.connect(self.customAction)
# I JUST WANT TO SEE THE MENU WHEN RIGHT CLICK...
self.trayIconMenu = QtWidgets.QMenu()
self.quitAction = QtWidgets.QAction("&Quit", None, triggered=QtWidgets.QApplication.instance().quit)
self.trayIconMenu.addAction(self.quitAction)
self.tray.setContextMenu(self.trayIconMenu)
# JUST WANNA USE THE ACTION WITH LEFT CLICK
def customAction(self, signal):
print "left click pressed"
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
sl = SystrayLauncher()
sys.exit(app.exec_())
Can anyone help me, please?
you can differentiate the click "reason" and decide what to do. Therefore you will need to add a function like follows:
def right_or_left_click(reason):
if reason == QSystemTrayIcon.ActivationReason.Trigger:
print("Left-click detected")
elif reason == QSystemTrayIcon.ActivationReason.Context:
print("Right-click detected")
elif reason == QSystemTrayIcon.ActivationReason.MiddleClick:
print("Middle-click detected")
else:
print("Unknown reason")
self.tray.activated.connect(right_or_left_click)
Then, you can call the desired function on left-click or middle-click. The right-click is occupied by your context menu :)
I have an batch file that I execute that opens a program. A dialog box then appears which I type into it the username and password credentials
The I print the control identifiers and it lists;
SunAwtDialog - 'Login' (L528, T242, R853, B501)
['SunAwtDialog', 'LoginSunAwtDialog', 'Login']
child_window(title="Login", class_name="SunAwtDialog")
So after reading this post. My understanding was to use window + the button and a click method like so;
dlp.SunAwtDialog['Login'].click()
But this keeps throwing an ElementNotFoundError;
ElementNotFoundError: {'best_match': 'SunAwtDialog', 'top_level_only': False, 'parent': <win32_element_info.HwndElementInfo - 'Login', SunAwtDialog, 2164976>, 'backend': 'win32'}
Below is the full snippet of code;
from pywinauto import application
import time
app = application.Application()
app.start(r"C:\\WINDOWS\system32\cmd.exe", wait_for_idle=False)
dlg = app.top_window()
dlg.type_keys('D:{ENTER}')
dlg.type_keys('cd{SPACE}Software\\client{ENTER}')
dlg.type_keys('run_client.bat{ENTER}')
time.sleep(10)
new_app = application.Application().connect(title="iManager")
dlp = new_app.top_window()
#type username + password
dlp.type_keys('user')
dlp.type_keys('{TAB}')
dlp.type_keys('pass')
#print control identifiers
dlp.print_control_identifiers()
#click login[![enter image description here][1]][1]
dlp.SunAwtDialog['Login'].click()
You can see on the image below the "Login" button I want to be able to click. There is also another button next to the "Server" option, but it is not in my control identifiers
A solution that I use for this is using send_keys. Try this:
from pywinauto.keyboard import send_keys
send_keys("{VK_MENU down}" "l" "{VK_MENU up}")
I'm trying to make a little application with appindicator and Gtk. My goal is to display a list of server with link to url of them.
Here is what I try :
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
def main():
indicator = appindicator.Indicator.new(APPINDICATOR_ID, img, appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())
gtk.main()
def build_menu():
menu = gtk.Menu()
value = "label"
item = gtk.MenuItem()
button = gtk.LinkButton("http://url/host/id", label=value)
button.show()
item.add(button)
item.show()
menu.append(item)
menu.show_all()
return menu
if __name__ == "__main__":
main()
That's working and I have no errors. But wen I launch application, I've only menu, with items but no link.
I've seen many exemple with gtk.Window but nothing with a menu for appindicator.
Is there a way to have link in this menu ?
Thanks
I've found a way to do that. I'm not sure it's the best way, but it works.
Instead of create a LinkItem, I've made a function for open url:
def open_url(source):
webbrowser.open("http://url/host/id")
And I call it after, with connect :
item.connect("activate", open_url)
When I run my app and click on my item, it opens url as expected. Here is part of code working:
def build_menu():
menu = gtk.Menu()
value = "label"
item = gtk.MenuItem(value)
item.connect("activate", open_url)
menu.append(item)
menu.show_all()
return menu
As I see in many post on web, appindicator has limited functions compared to normal Gtk application.
I am trying my first things with pywinauto.
Now I want to make use of print_control_identifiers() but I get errors, however I write my code - I cant get any information about GUI objects.
I already tried to generate the code via swapy - had a lot of generated code, but no success.
This is my code so far:
import getpass, fnmatch
from pywinauto import application
currentUser = getpass.getuser()
if fnmatch.fnmatch(currentUser, "axe"):
pwa_app = application.Application()
w_handle = application.findwindows.find_windows(title=u'Login - 0.9.347', class_name='WindowsForms10.Window.8.app.0.141b42a_r11_ad1')[0]
window = pwa_app.window_(handle=w_handle)
window.SetFocus()
ctrl = window['Log In']
ctrl.Click()
else:
print "You need admin rights for that action"
Can you tell me, where I need to use print_control_identifiers()?
Do you have any other GUI automation frameworks that are more up-to-date?
PrintControlIdentifiers() is useful for top level window. If window is top level window specification, then just call
window.PrintControlIdentifiers()
or
pwa_app.Window_(title=u'Login - 0.9.347', top_level_only=True).PrintControlIdentifiers()
A few examples:
Swapy is good to identify the properties. Also, the examples given with pywinauto are quite helpful.
Source: https://pywinauto.googlecode.com/hg/pywinauto/docs/getting_started.html
from pywinauto import application
app = application.Application.Start("Notepad.exe")
app.Notepad.print_control_identifiers()
app.Notepad.MenuSelect("Edit->Replace")
app.Replace.print_control_identifiers()
from pywinauto import application
from pywinauto import application
app = application.Application()
app.Start("Notepad.exe")
Wnd_Main = app.window_(title_re=".*Notepad")
Wnd_Main.MenuSelect("File->Save")
Wnd_Save = app.window_(title_re="Save As")
Wnd_Save.Edit1.SetEditText("Hello World.txt")